I execute the following code in my MissionPlanner Python script:
MAV.setMode("Guided")
print "Mode " + cs.mode
print "First"
MAV.doCommand(MAVLink.MAV_CMD.DO_SET_ROI, 0, 0, 0, 0, 41.053184,
-75.511862, 569)
time.sleep(5)
print "Second"
MAV.doCommand(MAVLink.MAV_CMD.DO_SET_ROI, 0, 0, 0, 0, 41.053630,
-75.515075, 569)
time.sleep(5)
print "Third"
MAV.doCommand(MAVLink.MAV_CMD.DO_SET_ROI, 0, 0, 0, 0, 41.055364,
-75.513406, 569)
time.sleep(5)
print "Fourth"
MAV.doCommand(MAVLink.MAV_CMD.DO_SET_ROI, 0, 0, 0, 0, 41.057604,
-75.512762, 569)
time.sleep(5)
MAV.doCommand(MAVLink.MAV_CMD.DO_SET_ROI, 0, 0, 0, 0, 41.059639,
-75.512434, 569)
Script.ChangeMode("PosHold")
print "Mode " + cs.mode
However, the cs.mode
is showing the prior mode.
I’m guessing that the mode change hasn’t actually occurred yet and we have some sort of race condition. What can I while
with in order to wait for the mode to actually change. Should I keep checking cs.mode
for the desired change to happen, or is there a better way? Perhaps a wait handle of sorts? Thanks!