Home        Store        Learn        Blog

RC Override Control Not Working

Hello,
I an trying to control the BlueRov2 with following code:

# Import mavutil
from pymavlink import mavutil

# Create the connection
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
# Wait a heartbeat before sending commands
master.wait_heartbeat()

# Create a function to send RC values
# More information about Joystick channels
# here: https://www.ardusub.com/operators-manual/rc-input-and-output.html#rc-inputs
def set_rc_channel_pwm(channel_id, pwm=1500):
    """ Set RC channel pwm value
    Args:
        channel_id (TYPE): Channel ID
        pwm (int, optional): Channel pwm value 1100-1900
    """
    if channel_id < 1 or channel_id > 18:
        print("Channel does not exist.")
        return

    # Mavlink 2 supports up to 18 channels:
    # https://mavlink.io/en/messages/common.html#RC_CHANNELS_OVERRIDE
    rc_channel_values = [65535 for _ in range(18)]
    rc_channel_values[channel_id - 1] = pwm
    master.mav.rc_channels_override_send(
        master.target_system,                # target_system
        master.target_component,             # target_component
        *rc_channel_values)                  # RC channel list, in microseconds.


# Set some roll
set_rc_channel_pwm(2, 1600)

But it didn’t work,It makes an error that “rc_channels_override_send() takes at most 12 arguments (21 given)”.What the solution to this problem?

1 Like

Hi @qaq,

Make sure to be running the latest version of companion and ArduSub, remember to flash the default parameters after that.

The problem that you see is related to an old protocol version that is not used anymore, the ROV uses now mavlink2 and from your error message it appears that you are still using mavlink1.

1 Like

Using pymavlink requires mavproxy. I saw a reply in other questions that mavproxy does not support mavlink 2. Isn’t this a conflict?

1 Like

Hi @qaq, welcome to the forum :slight_smile:

Not sure where you read that (if you provide a link I can close the post/topic) but mavproxy and pymavlink both definitely support mavlink 2 :slight_smile:

When I flash the default parameters at the version of 4.2.0,It shows 2 errors that
Sending MNT_RC_IN_TILT = 8.0 FAIL!
Sending MNT_TYPE = 1.0 FAIL!

How to solve these?

Thank you so much!

Try changing the parameter SERIAL0_PROTOCOL to 2 (mavlink2), then restart the autopilot.

I think you were a little misdirected by @patrickelectric recommendation to get the latest version of ardusub. He meant the latest stable version which is 4.0.3.

What you should do now:

  • update companion (to companion 0.0.28)
  • click ‘flash factory default firmware’ (ardusub 4.0.3)
  • restart the vehicle

The problem for your rc override script is that the autopilot is not using ma
vlink2. This can be changed by setting the SERIAL0_PROTOCOL parameter to 2 (mavlink2). Or, you can give the function only 8 rc channels in the mavlink1 style.

1 Like