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ïŒ
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.
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.
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.