Guided mode to loiter mode

Hi,

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"
break
sleep(2)
#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"
sleep(1)
print("current vehicle mode is : %s"% vehicle.mode.name)
##Wait for 10 sec
sleep(5)

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity