Problems with python scripts and altitude

Hi everyone

I am writing a python script to go to a waypoint using Mission Planner, I define the latitude, longitude and altitude and set the guided mode in the script. The latitude and longitude works fine, but the altitude it doesn’t work and starts to drop inmedeatly, no matter what altitude I set.

Here is the code:

import sys
import clr
import time
import MissionPlanner #import *
clr.AddReference(“MissionPlanner.Utilities”) # includes the Utilities class
from MissionPlanner.Utilities import Locationwp
print ‘Starting Mission’
Script.ChangeMode(“Guided”)
print ‘Guided Mode’
item = MissionPlanner.Utilities.Locationwp()
lat = -35.363261
lng = 149.165235
alt = 60.000000
MissionPlanner.Utilities.Locationwp.lat.SetValue(item,lat)
MissionPlanner.Utilities.Locationwp.lng.SetValue(item,lng)
MissionPlanner.Utilities.Locationwp.alt.SetValue(item,alt)
print ‘WP 1 Defined’
MAV.setGuidedModeWP(item)
print ‘Going to WP 1’
time.sleep(150)

I have no problems using Guided Mode in the software, but with the python script the altitude drops

Is there any parameters I should check to fix this problem?

Thank You

your 60? is that feet or meters?

your code looks ok, so just looking at other possible issues

Meters. I have tried using a IRIS+ copter and a SITL simulation, and in both the altitude drops :frowning:

Hi, Tomas

I have the same problem.
The drone starts the mission, and immediately returns to launch.
Have you solved this problem? If yes, please tell me how.

Thank you

I think ive found the issue here ill push a new beta in the next few days

i use dronkit i do not have this problem try that

So I don’t totally understand everything here…but is there a chance that your location is already below 60 meters? I know when creating a flight plan you select “Relative” for altitute. I don’t see anything like that in the script.

According to https://elevationmap.net/canberra-model-aeroplane-club-10423-monaro-hwy-jerrabomberra-act-2619-australia
Your terrain height is 583m

the issue in this case was a MP bug, fixed in beta

1 Like