Hi there,
I have been working on an autonomous vehicle and I will use rc input commands because I want to have control over all the six axises. I have tried to code like the example on the ardusub documentation but it throws an error saying that the function doesnt take 21 arguments. But I am sure that I am giving 18 rc channels. Can you show a working example on sending rc input commands?
Hi @Efe,
That code should work - how are you connecting to the vehicle? Note that Pymavlink does some internal reorganisation depending on how the other components are communicating with it, so you generally need to make sure you’ve received at least one message from the vehicle before you start sending commands to it - it’s common to wait for a heartbeat.
There’s a full program example here if that’s of interest, but make sure to read the notes at the bottom
Here is our error message for rc commands we send target system, target component and 18 rc channels but it says 21 arguments were given.
21 is correct - the extra argument is because rc_channels_override_send
is a method of the master.mav
object, so the object gets passed in as the first argument.
Are you receiving at least one message from the vehicle before you try to send the rc command?
Yes I am waiting for heartbeat in the initalization phase and also I am sending heartbeat messages periodically. I didn’t understand why the error says rc override takes 12 arguments. Could it be something about mavlink version?
RC override used to only accept 12 arguments in MAVLink 1.0, so it is indeed a MAVLink version issue, but that’s supposed to be automatically corrected for by Pymavlink once it receives messages from a vehicle that’s communicating using MAVLink 2.0 (which is the internal reorganisation I mentioned earlier).
Which ArduSub and Pymavlink versions are you using?
I am using pymavlink 2.4.29 so it shouldn’t be a problem but I don’t have pixhawk with me right now. I can tell you the ardusub version tomorrow. Also are there any option that I can test rc_input from QGC ?
my ardusub firmware version is 4.0.3
Hi @Efe, sorry for the delay getting back on this.
I’m not sure what’s going wrong there - I believe I’ve run with a similar setup multiple times previously and not had issues. A few questions:
- How is Pymavlink being connected to your vehicle / autopilot?
- What kind of autopilot board are you using?
- Does the issue get fixed by manually specifying to use MAVLink 2.0 using environment variables?
# specify MAVLink 2.0 - MUST be before Pymavlink import(s) import os os.environ['MAVLINK20'] = '' from pymavlink import mavutil ...
Not directly - QGC (for the most part) commands ArduSub using MANUAL_CONTROL
messages. Internally ArduSub converts the motion control components of that into an RC_OVERRIDE command, but that’s quite roundabout and has some limitations because of scaling and constraints applied during the conversion.
I am using pixhawk flight controller connected to jetson nano via usb. I will try specifying the version as soon as possible.
Hi @Eliot,
Last year I opened up this topic and then I found the solution by decreasing number of rc_channels that I send. When I send only 9 rc_channels it works and 9 channels were enough. But now I also want to control lights when I am using rc_input so I also need the 10. channel do you have any other advices that I could try? Stating the mavlink version as mavlink 2 also didn’t work.
And also I have another question about rc_input, am I able to use stabilize mode with rc_input commands and should I send roll, pitch and yaw as 65535 in order to activate stabilize mode?