Occasional Mavlink Messages not sending/being recieved

I am using multiple servos and controlling them from the standalone UI that I built. This is my function for sending messages:

def sendMav(channel, pwm):
global msg
#Compiles and sends a mavling message to the corresponding channel and pwm
msg = vehicle.message_factory.command_long_encode(0, 0, mavutil.mavlink.MAV_CMD_DO_SET_SERVO, 0, channel, pwm, 0, 0, 0, 0,0)

I am trying to actuate multiple servos in a short amount of time with this. The short sleep is meant to space the messages a little bit. This code works 90% of the time, but every so often the servo does not move. I am using a DIJI modem to send messages. Do you know why some messages do not seem to be received? Also, is there an easy way to read the pmw of a channel (ex. 9) so that I can continue to send a message to a servo until I see it moves? Thank you for your time

Instead, you can wait for COMMAND_ACK from the vehicle and send the command until you get COMMAND_ACK.

1 Like