Hi @ivanchen, welcome to the forum
The error occurs because your mavlink thinks it needs to communicate using the mavlink 1 protocol (pymavlink default), but ardusub actually uses mavlink 2 (newer and improved), so our documentation is tailored to mavlink 2 examples. If you run
master.wait_heartbeat() right after you create the mavlink connection then it will detect that the autopilot is using mavlink 2 and will switch to the correct function.
More generally, for turning on the lights I’d recommend instead using the
set_servo function (e.g.
master.set_servo(output_channel_number, pwm)) - it’s simpler since you directly set by the output servo channel rather than the input channel, and is less to type. We’re currently in the process of revamping our pymavlink docs, so that should be available in an example soon
For now, note that the output servo channels are directly based on the pixhawk outputs. The ‘Lights’ input channel (for controlling via QGC and
rc_channels_override) is 9 but can be assigned to various output ports depending on your preference/setup. By default the lumens are plugged in to port AUX 2, which servo output 10 (8 MAIN, +2 AUX), so for turning on the lights there you would use
from pymavlink import mavutil
# assuming connecting from surface computer
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
# wait a heartbeat to confirm connection and determine mavlink
# protocol version
# turn on the lights (servo output 10, AUX 2) to half (1500us pwm)
time.sleep(5) # leave them on for 5 seconds
master.set_servo(10, 1100) # turn them off again