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

Liam left a comment on Agricultural UAVs
"Hi
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…"
yesterday
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..."
Tuesday
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."
Tuesday
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
More…