Hi, I need some help with creating a python script, that I would like to run from missionplanner. The purpose is to determine the snow depth below the copter using a rangefinder. To do this I have to subtract the rangefinders measurement and the terrain height at the copters current position from the vehicles GPS altitude.
I would like to use gdallocationinfo to get the terrain height, but don´t know how to execute it from MissionPlanners IronPython (how to import gdal). Any help would be appreciated.
Here is the first sketch:
#!/usr/bin/ipy
import clr
#from osgeo import gdalclr.AddReference(“MissionPlanner”)
import MissionPlanner
clr.AddReference(“MissionPlanner.Utilities”) # includes the Utilities class
clr.AddReference(“MAVLink”) # includes the Utilities class
import MAVLink######################
print ‘Script gestartet’
#check if copter is armed
while True:if (cs.armed): #get position from drone lon, lat, alt pos = [cs.lat, cs.lng, cs.alt] #get laser distance or just use rope length ropeLen = 20 #get alt from geotiff at current location tiffalt = gdallocationinfo -valonly -wgs84 file.tif pos[1] pos[0] #tiffalt = 123 #calculate and print snow depth snow = pos[2] - ropeLen - tiffalt print snow Script.Sleep(1000) else: print 'Nicht im Flug' Script.Sleep(10000)
print ‘Script beendet’