Running python script via mission planner

Hi all, I’m a newbie so please be gentle.
I want to write a script to do the following:
Once the drone is connected to mission planner via telemetry do the following:
1.change mode to guided.
2. Arm
3. Take off to 10m
4. Fly to give LAT LONG cooards.

Is it possible to run this kind of a script threw mission planner?
If so, where do I start?

Thanks in advanced

Hi
Yes it possible

start point is here : https://ardupilot.org/planner/docs/using-python-scripts-in-mission-planner.html

1 Like

and also examples in the MP install directory, called scripts

Hello, i made a Python Script, but i dont know how to set it in Missionplanner up.
`import time
print ‘Start Script’
start1 = 0
gewicht = 1500.0
treibstoff = 4000.0
SchubTu = 5500.0
a = 0.0310092305937341
b = 0.832677475073945
Zeit = time.clock
Schub1 = 0
Schub2 = 0
Steuerhebel = 0
Startstatus = 0
DH = 0
hoeenregelung = 0
while True:
Script.Sleep(200)
if start1 == 0:
aktuel = cs.alt
if aktuel < 0.5 and aktuel > -0.5:
Startwert = aktuel
DH = aktuel
start1 = 1
Zeit = time.clock()
while True:
puffer = cs.ch7out
#check ob Schub im Wertebreich Liegt
if puffer < 1950 and puffer > 1050:
Schub1 = puffer
Steuerhebel = puffer
puffer = cs.ch6out
#check ob Schalter im Wertebreich Liegt
if puffer < 1950 and puffer > 1050:
Schalter = puffer
#Schubanpassung berechnung
if Schub1 > 1550.0 :
Schubanpassung = (Schub1 - 1550.0) / 5.0
elif Schub1 < 1470.0 :
Schubanpassung = (Schub1 - 1750) / 5.0
else:
Schubanpassung = 0
if (DH - cs.alt) > 0.35:
hoeenregelung = -1.0
elif ( cs.alt - DH ) > 0.35:
hoeenregelung = 1.0
else:
hoeenregelung = 0
DH = cs.alt
print "Abweivchung neutrallage. ", Schubanpassung
#Status schalter pos 2
if Schalter < 1300 :
Script.SendRC(5,2000,True)
Startstatus = 1
print ‘Schalter in Position 2’
elif Schalter < 1700 :
print ‘Schalter in Position 1’
if Startstatus == 1 and Steuerhebel > 1150:
#Programm Turbuinensteuerung
Schub2 = (gewicht / SchubTu + treibstoff / SchubTu) * 100.0
treibstoff = treibstoff - ((time.clock() - Zeit)) * (a * Schub2 + b )
Zeit = time.clock()
val = 1000 + 10.0 * Schub2
val = val + 2.0 * Schubanpassung
if val > 1999 :
val = 2000
Schub2 = (val - 1000.0) / 10.0
Script.SendRC(5,val,True)
if hoeenregelung == 1:
gewicht = gewicht - 50.0
elif hoeenregelung == -1.0:
gewicht = gewicht + 50.0
else:
Script.SendRC(5,1000,True)
else:
Script.SendRC(5,800,True)
print ‘Schalter in Position 0’
print "Schub ist. ", Schub2
print "aktueller Treibstoff. ", treibstoff
Script.Sleep(200)

`