I hope this question makes sense, I am just diving into learning MAVLink now and want to understand how to send commands one after another from a single script.
I am writing the script with pymavlink and simulating the results with SITL. This is my first attempt at this.
I send 4 commands,
- Change to guided mode
- Arm
- Take off
- Move forward
I found if I write these one after another in one script, they don’t get executed, I am assume because the copter hasn’t finished processing the last command.
So I tried to add an if block to tested for the result of the acknowledgement message with
msg = the_connection.recv_match(type='COMMAND_ACK', blocking=True)
if(msg.result == 0):
# send next command
But this didn’t work either. So I am currently using time.sleep(4)
between commands, but I think there must be a better way to check if copter is ready to execute next command.
Is there a better way to do this, thank you