mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
Mission test update
This commit is contained in:
parent
be1007d032
commit
31cb62620f
@ -168,18 +168,15 @@ def circle(mavproxy, mav, maxaltchange=10, holdtime=90, timeout=35):
|
|||||||
|
|
||||||
def fly_mission(mavproxy, mav, height_accuracy=-1, target_altitude=None):
|
def fly_mission(mavproxy, mav, height_accuracy=-1, target_altitude=None):
|
||||||
'''fly a mission from a file'''
|
'''fly a mission from a file'''
|
||||||
print("Fly a mission")
|
|
||||||
global homeloc
|
global homeloc
|
||||||
global num_wp
|
global num_wp
|
||||||
mavproxy.send('wp set 1\n')
|
print("test: Fly a mission from 0 to %u" % num_wp)
|
||||||
|
mavproxy.send('wp set 0\n')
|
||||||
mavproxy.send('switch 4\n') # auto mode
|
mavproxy.send('switch 4\n') # auto mode
|
||||||
wait_mode(mav, 'AUTO')
|
wait_mode(mav, 'AUTO')
|
||||||
|
|
||||||
#wait_altitude(mav, 30, 40)
|
#wait_altitude(mav, 30, 40)
|
||||||
ret = wait_waypoint(mav, 0, num_wp, timeout=90)
|
ret = wait_waypoint(mav, 0, num_wp, timeout=90)
|
||||||
|
print("test: MISSION COMPLETE: passed=%s" % ret)
|
||||||
print("MISSION COMPLETE: passed=%s" % ret)
|
|
||||||
|
|
||||||
# wait here until ready
|
# wait here until ready
|
||||||
mavproxy.send('switch 5\n')
|
mavproxy.send('switch 5\n')
|
||||||
wait_mode(mav, 'LOITER')
|
wait_mode(mav, 'LOITER')
|
||||||
@ -192,20 +189,30 @@ def fly_mission(mavproxy, mav, height_accuracy=-1, target_altitude=None):
|
|||||||
# return False
|
# return False
|
||||||
|
|
||||||
|
|
||||||
def load_mission(mavproxy, mav, filename):
|
def load_mission_from_file(mavproxy, mav, filename):
|
||||||
'''load a mission from a file'''
|
'''load a mission from a file'''
|
||||||
global num_wp
|
global num_wp
|
||||||
|
wploader = mavwp.MAVWPLoader()
|
||||||
|
wploader.load(filename)
|
||||||
|
num_wp = wploader.count()
|
||||||
|
print("loaded mission with %u waypoints" % num_wp)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def upload_mission_from_file(mavproxy, mav, filename):
|
||||||
|
'''Upload a mission from a file to APM'''
|
||||||
|
global num_wp
|
||||||
mavproxy.send('wp load %s\n' % filename)
|
mavproxy.send('wp load %s\n' % filename)
|
||||||
mavproxy.expect('flight plan received')
|
mavproxy.expect('flight plan received')
|
||||||
mavproxy.send('wp list\n')
|
mavproxy.send('wp list\n')
|
||||||
mavproxy.expect('Requesting [0-9]+ waypoints')
|
mavproxy.expect('Requesting [0-9]+ waypoints')
|
||||||
|
return True
|
||||||
|
|
||||||
wploader = mavwp.MAVWPLoader()
|
def save_mission_to_file(mavproxy, mav, filename):
|
||||||
wploader.load(filename)
|
global num_wp
|
||||||
num_wp = wploader.count()
|
mavproxy.send('wp save %s\n' % filename)
|
||||||
print("loaded mission")
|
mavproxy.expect('Saved ([0-9]+) waypoints')
|
||||||
for i in range(num_wp):
|
num_wp = int(mavproxy.match.group(1))
|
||||||
print wploader.wp(i)
|
print("num_wp: %d" % num_wp)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setup_rc(mavproxy):
|
def setup_rc(mavproxy):
|
||||||
@ -294,33 +301,50 @@ def fly_ArduCopter(viewerip=None):
|
|||||||
if not takeoff(mavproxy, mav):
|
if not takeoff(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
print("# Fly A square")
|
||||||
if not fly_square(mavproxy, mav):
|
if not fly_square(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
# save the stored mission
|
||||||
|
print("# Save out the C7 mission")
|
||||||
|
if not save_mission_to_file(mavproxy, mav, os.path.join(testdir, "ch7_mission.txt")):
|
||||||
|
failed = True
|
||||||
|
|
||||||
|
# Loiter for 10 seconds
|
||||||
|
print("# Loiter for 10 seconds")
|
||||||
if not loiter(mavproxy, mav):
|
if not loiter(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
#Fly a circle for 60 seconds
|
#Fly a circle for 60 seconds
|
||||||
|
print("# Fly a Circle")
|
||||||
if not circle(mavproxy, mav):
|
if not circle(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
# fly the stored mission
|
# save the stored mission
|
||||||
|
print("# Fly CH 7 saved mission")
|
||||||
if not fly_mission(mavproxy, mav,height_accuracy = 0.5, target_altitude=10):
|
if not fly_mission(mavproxy, mav,height_accuracy = 0.5, target_altitude=10):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
#fly_mission(mavproxy, mav, os.path.join(testdir, "mission_ttt.txt"), height_accuracy=0.2)
|
print("# Upload mission1")
|
||||||
|
if not upload_mission_from_file(mavproxy, mav, os.path.join(testdir, "mission1.txt")):
|
||||||
if not load_mission(mavproxy, mav, os.path.join(testdir, "mission1.txt")):
|
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
# this grabs our mission count
|
||||||
|
print("# store mission1 locally")
|
||||||
|
if not load_mission_from_file(mavproxy, mav, os.path.join(testdir, "mission1.txt")):
|
||||||
|
failed = True
|
||||||
|
|
||||||
|
print("# Fly mission 1")
|
||||||
if not fly_mission(mavproxy, mav,height_accuracy = 0.5, target_altitude=10):
|
if not fly_mission(mavproxy, mav,height_accuracy = 0.5, target_altitude=10):
|
||||||
failed = True
|
failed = True
|
||||||
else:
|
else:
|
||||||
print("Flew mission_ttt OK")
|
print("Flew mission1 OK")
|
||||||
|
|
||||||
|
print("# Land")
|
||||||
if not land(mavproxy, mav):
|
if not land(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
print("# disarm motors")
|
||||||
if not disarm_motors(mavproxy, mav):
|
if not disarm_motors(mavproxy, mav):
|
||||||
failed = True
|
failed = True
|
||||||
except pexpect.TIMEOUT, e:
|
except pexpect.TIMEOUT, e:
|
||||||
|
Loading…
Reference in New Issue
Block a user