iam using dronekit-python to simuate a mission.

mission consist of goto specific gps point and loiter for few seconds.

initially i put the vehicle in guided mode and when it reaches the gps point iam changing it to loiter mode.

but as soon as it changed to loiter mode, the vehicle is suddenly crashing,

how to avoid that ?

code i'm using is

while vehicle.mode.name == "GUIDED" : #stop action if we are no longer in guided mode
remainingDistance = getDistanceInMeters([vehicle.location.global_relative_frame.lat,vehicle.location.global_relative_frame.lon],current)
print("distance to target :: %s "%remainingDistance)
if remainingDistance <= targetDistance * 0.01 : #just below target
print "reached target"
#change the mode to loiter and wait for 10 seconds
vehicle.mode = VehicleMode("LOITER")
while not vehicle.mode.name == "LOITER":
print "Waiting for vehicle to change to LOITER Mode"
print("current vehicle mode is : %s"% vehicle.mode.name)
##Wait for 10 sec

Views: 108

Reply to This

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service