Guided mode to loiter mode


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 == "GUIDED" : #stop action if we are no longer in guided mode
remainingDistance = getDistanceInMeters([,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 == "LOITER":
print "Waiting for vehicle to change to LOITER Mode"
print("current vehicle mode is : %s"%
##Wait for 10 sec

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

Join diydrones

Email me when people reply –


Liam left a comment on Agricultural UAVs
I'm Liam from T-MOTOR. I would like to reach out to see if there is any possibility for us to work together.
We are a propulsion system manufacturer who offers motors, propellers and ESCs for all kinds of drone applications which vary from secur…"
Richard Cox left a comment on Australia
"Anyone in the DIYDRONES Australian subgroup based in Alice Springs, NT?
I am experimenting with Ardupilot (standard Arduplane), Pixhawk 4 FC in a 4-ch
RC "AXN Floater Jet" foamy plane..."
Omar Sykes left a comment on Australia
"Hi everyone, I am looking for someone who is good at drone building, repair and software in Adelaide. Please give me a call on 0477 319 219."
Jørn Ramnæs liked VIDEO LINK's profile
May 28
Mark Harrison left a comment on Moderators
"Wow, Ning2 looks really great on mobile. I had sort of drifted away as my browse-time went more on my phone, so this is great."
May 28