Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Scripts/PARACHUTE LANDING APPROACH.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
approach_azimuth = 180
from __future__ import print_function
approach_azimuth = 180

parachute_deploy_altitude = 40

Expand Down Expand Up @@ -40,34 +41,34 @@
hdop = cs.gpshdop

if satellites < 6:
print'GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS'
print ''
print('GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS')
print('')
elif hdop > 4:
print'GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS.'
print ''
print('GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS.')
print('')
else:
print'GPS PASSED.'
print ''
print('GPS PASSED.')
print('')

if descent_delta < 0:

print 'CURRENT ALTITUDE BELOW PARACHUTE DEPLOY ALTITUDE'
print 'NO MISSION CREATED'
print('CURRENT ALTITUDE BELOW PARACHUTE DEPLOY ALTITUDE')
print('NO MISSION CREATED')

elif parachute_deploy_altitude < 20:

print 'PARACHUTE DEPLOY ALTITUDE LESS THAN 20 METERS'
print 'NO MISSION CREATED'
print('PARACHUTE DEPLOY ALTITUDE LESS THAN 20 METERS')
print('NO MISSION CREATED')

elif parachute_deploy_altitude > 100:

print 'PARACHUTE DEPLOY ALTITUDE MORE THAN 100 METERS'
print 'NO MISSION CREATED'
print('PARACHUTE DEPLOY ALTITUDE MORE THAN 100 METERS')
print('NO MISSION CREATED')

elif parachute_deploy_distance_from_home > 100:

print 'PARACHUTE DEPLOY DISTANCE IS MORE THAN 100 FROM HOME'
print 'NO MISSION CREATED'
print('PARACHUTE DEPLOY DISTANCE IS MORE THAN 100 FROM HOME')
print('NO MISSION CREATED')

else:

Expand Down Expand Up @@ -113,7 +114,6 @@
Script.Sleep(1000)
MAV.setWPACK(); #final ack
Script.Sleep(1000)
print 'AUTOGENERATED LANDING APPROACH MISSION'
print('AUTOGENERATED LANDING APPROACH MISSION')



29 changes: 15 additions & 14 deletions Scripts/TAKEOFF.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
launch_altitude = 100
from __future__ import print_function
launch_altitude = 100

cruise_altitude = 200

Expand Down Expand Up @@ -40,29 +41,29 @@
hdop = cs.gpshdop

if satellites < 6:
print'GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS'
print ''
print('GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS')
print('')
elif hdop > 4:
print'GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS.'
print ''
print('GPS FAILED. NO MISSION CREATED. WAIT FOR BETTER GPS.')
print('')
else:
print'GPS PASSED.'
print ''
print('GPS PASSED.')
print('')

if launch_altitude < 50:

print 'LAUNCH ALTITUDE LESS THAN 50 METERS'
print 'NO MISSION CREATED'
print('LAUNCH ALTITUDE LESS THAN 50 METERS')
print('NO MISSION CREATED')

elif launch_altitude >100:

print 'LAUNCH ALTITUDE GREATER THAN 100 METERS'
print 'NO MISSION CREATED'
print('LAUNCH ALTITUDE GREATER THAN 100 METERS')
print('NO MISSION CREATED')

elif cruise_altitude < launch_altitude:

print 'CRUISE ALTITUDE LESS THAN LAUNCH ALTITUDE'
print 'NO MISSION CREATED'
print('CRUISE ALTITUDE LESS THAN LAUNCH ALTITUDE')
print('NO MISSION CREATED')

else:

Expand Down Expand Up @@ -119,4 +120,4 @@
MAV.setWP(wp4,5,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT); #upload wp4
MAV.setWPCurrent(1); #restart mission to waypoint 0
MAV.setWPACK(); #final ack
print 'AUTOGENERATED TAKEOFF MISSION'
print('AUTOGENERATED TAKEOFF MISSION')
7 changes: 4 additions & 3 deletions Scripts/cubeorange.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from __future__ import print_function

import clr
import MissionPlanner
clr.AddReference("MAVLink")
Expand All @@ -9,7 +10,7 @@

import MAVLink

print 'Start Script'
print('Start Script')

MAV.setParam("INS_ACC_ID", 0, True);
MAV.setParam("INS_ACC2_ID", 0, True);
Expand All @@ -19,4 +20,4 @@
MAV.setParam("INS_ACC2_ID", 2883874, True);
MAV.setParam("INS_ACC3_ID", 3015690, True);

print 'Done'
print('Done')
3 changes: 2 additions & 1 deletion Scripts/datetime.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import print_function
c#
import System
c#
dt = System.DateTime.Now
st = dt.ToString("yyyy-MM-ddTHH:mm:ss.fff") + ' setting wp 1'

# python
print st
print(st)
# c#
System.Console.WriteLine(st)
15 changes: 8 additions & 7 deletions Scripts/example1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# cs.???? = currentstate, any variable on the status tab in the planner can be used.
from __future__ import print_function
# cs.???? = currentstate, any variable on the status tab in the planner can be used.
# Script = options are
# Script.Sleep(ms)
# Script.ChangeParam(name,value)
Expand All @@ -8,24 +9,24 @@
# Script.SendRC(channel,pwm,sendnow)
#

print 'Start Script'
print('Start Script')
for chan in range(1,9):
Script.SendRC(chan,1500,False)
Script.SendRC(3,Script.GetParam('RC3_MIN'),True)

Script.Sleep(5000)
while cs.lat == 0:
print 'Waiting for GPS'
print('Waiting for GPS')
Script.Sleep(1000)
print 'Got GPS'
print('Got GPS')
jo = 10 * 13
print jo
print(jo)
Script.SendRC(3,1000,False)
Script.SendRC(4,2000,True)
cs.messages.Clear()
Script.WaitFor('ARMING MOTORS',30000)
Script.SendRC(4,1500,True)
print 'Motors Armed!'
print('Motors Armed!')

Script.SendRC(3,1700,True)
while cs.alt < 50:
Expand Down Expand Up @@ -55,4 +56,4 @@
Script.WaitFor('DISARMING MOTORS',30000)
Script.SendRC(4,1500,True)

print 'Roll complete'
print('Roll complete')
13 changes: 7 additions & 6 deletions Scripts/example10.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import clr
from __future__ import print_function
import clr
import MissionPlanner
clr.AddReference("MAVLink")
from System import Func, Action
import MAVLink

def OtherMethod(message):
print "got HB";
print("got HB");
return True

def MyMethod(message):
Expand All @@ -16,11 +17,11 @@ def MyMethod(message):
def MyPacketHandler(o, message):
try:
if message.msgid == MAVLink.MAVLINK_MSG_ID.STATUSTEXT.value__:
print "STATUSTEXT from MyPacketHandler " + str(message.sysid) + " " + str(message.compid)
print dir(message)
print("STATUSTEXT from MyPacketHandler " + str(message.sysid) + " " + str(message.compid))
print(dir(message))
print(bytes(message.data.text))
except Exception as inst:
print inst
print(inst)

sub = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.HEARTBEAT.value__, Func[MAVLink.MAVLinkMessage, bool] (OtherMethod))
sub2 = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.STATUSTEXT, Func[MAVLink.MAVLinkMessage,
Expand All @@ -32,4 +33,4 @@ def MyPacketHandler(o, message):

import time
while True:
time.sleep(1)
time.sleep(1)
9 changes: 5 additions & 4 deletions Scripts/example2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from __future__ import print_function

import clr
import MissionPlanner
clr.AddReference("MAVLink")
Expand All @@ -9,11 +10,11 @@

import MAVLink

print 'Start Script'
print('Start Script')

def OtherMethod(message):
print "got HB";
print dir(message.data)
print("got HB");
print(dir(message.data))
return True

sub = MAV.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.HEARTBEAT.value__, Func[MAVLink.MAVLinkMessage, bool] (OtherMethod))
Expand Down
23 changes: 12 additions & 11 deletions Scripts/example3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from __future__ import print_function
import sys
import math
import clr
import time
Expand All @@ -25,10 +26,10 @@ def gps_distance(lat1, lon1, lat2, lon2):
c = 2.0 * atan2(sqrt(a), sqrt(1.0-a))
return radius_of_earth * c

print __name__
print(__name__)

# main program
print "Start script"
print("Start script")
######Mission variables######
dist_tolerance = 15 #(m)
ber_tolerance = 45 #heading tolerance
Expand All @@ -43,23 +44,23 @@ def gps_distance(lat1, lon1, lat2, lon2):
target = (-35, 117.98) # gps pos of target in degrees

time.sleep(5) # wait 10 seconds before starting
print 'Starting Mission'
print('Starting Mission')
Script.ChangeMode("Guided") # changes mode to "Guided"
item = MissionPlanner.Utilities.Locationwp() # creating waypoint

alt = 60.000000 # altitude value
Locationwp.lat.SetValue(item,target[0]) # sets latitude
Locationwp.lng.SetValue(item,target[1]) # sets longitude
Locationwp.alt.SetValue(item,alt) # sets altitude
print 'Drop zone set'
print('Drop zone set')
MAV.setGuidedModeWP(item) # tells UAV "go to" the set lat/long @ alt
print 'Going to DZ'
print('Going to DZ')
Good = True
while Good == True:
ground_speed = cs.groundspeed
alt = cs.alt
wp_dist = gps_distance(cs.lat ,cs.lng, math.radians(target[0]), math.radians(target[1]))
print wp_dist
print(wp_dist)
ber_error = cs.ber_error
fall_time = ((2 * alt) / gravity) ** (0.5)
fall_dist = ground_speed * fall_time
Expand All @@ -69,12 +70,12 @@ def gps_distance(lat1, lon1, lat2, lon2):
if (math.fabs(ber_error) <= ber_tolerance):
######Payload Release######
Script.SendRC(payload_servo,1900,True)
print 'Bombs away!'
print('Bombs away!')
else:
print 'Heading outside of threshold, go around!'
print('Heading outside of threshold, go around!')
Good = False
else:
print 'Outside of threshold!'
print('Outside of threshold!')
time.sleep (1.0) #sleep for a second
#Broken out of the loop as Bearing was not right
print 'Bearing was out of tolerance for the Drop - Start run again'
print('Bearing was out of tolerance for the Drop - Start run again')
22 changes: 10 additions & 12 deletions Scripts/example4 wp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from __future__ import print_function
import sys
import math
import clr
import time
Expand All @@ -24,22 +25,19 @@
wp2 = Locationwp().Set(-35,117.89,50, id)
wp3 = Locationwp().Set(-35,117.85,20, id)

print "set wp total"
print("set wp total")
MAV.setWPTotal(5)
print "upload home - reset on arm"
print("upload home - reset on arm")
MAV.setWP(home,0,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT);
print "upload to"
print("upload to")
MAV.setWP(to,1,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT);
print "upload wp1"
print("upload wp1")
MAV.setWP(wp1,2,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT);
print "upload wp2"
print("upload wp2")
MAV.setWP(wp2,3,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT);
print "upload wp3"
print("upload wp3")
MAV.setWP(wp3,4,MAVLink.MAV_FRAME.GLOBAL_RELATIVE_ALT);
print "final ack"
print("final ack")
MAV.setWPACK();

print "done"



print("done")
7 changes: 4 additions & 3 deletions Scripts/example5 inject data.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

from __future__ import print_function

import clr
import MissionPlanner
clr.AddReference("MAVLink")
from System import Byte
from System import Array
import MAVLink

print 'Start Script'
print('Start Script')

key = Array[Byte]([0x13, 0x00, 0x00, 0x00, 0x08, 0x00])

MAV.BaseStream.Write(key,0,len(key))
MAV.BaseStream.Write(key,0,len(key))
Loading