Hi @JiaXu_Zhang, welcome to the forum
RC inputs are not the same as RC outputs.
- Have you configured your output 9 channel to correspond to Lights1 inputs (by setting
SERVO9_FUNCTION
toRCIN9
, or via the Lights page in QGroundControl)? - Does it work to control the lights using QGroundControl?
- Is there a reason you’ve changed the
set_rc_channel_pwm
function to use zero-based indexing for the channel-id, and only provide 12 values instead of the 18 used in our example?
That shouldn’t be necessary. Both lights control and mode changing are working fine for me on Pymavlink 2.4.37
(I just updated it to the latest version).
Note that if you’re using BlueOS there may be issues with changing mode if you have not explicitly waited for an autopilot heartbeat, because there are other MAVLink components on the same system.