Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/autotest/sailboat.py
Views: 1798
'''1Drive a Sailboat in SITL23AP_FLAKE8_CLEAN45'''67from __future__ import print_function89import os1011from rover import AutoTestRover1213from vehicle_test_suite import AutoTestTimeoutException14from vehicle_test_suite import PreconditionFailedException1516# get location of scripts17testdir = os.path.dirname(os.path.realpath(__file__))181920def log_name(self):21return "Sailboat"222324class AutoTestSailboat(AutoTestRover):2526def vehicleinfo_key(self):27return "Rover"2829def init(self):30if self.frame is None:31self.frame = 'sailboat'32super(AutoTestSailboat, self).init()3334def DriveRTL(self, timeout=120):35'''Drive an RTL Mission'''36self.wait_ready_to_arm()37self.arm_vehicle()3839self.load_mission("rtl.txt")40self.change_mode("AUTO")4142tstart = self.get_sim_time()43while True:44now = self.get_sim_time_cached()45if now - tstart > timeout:46raise AutoTestTimeoutException("Didn't see wp 3")47m = self.mav.recv_match(type='MISSION_CURRENT',48blocking=True,49timeout=1)50self.progress("MISSION_CURRENT: %s" % str(m))51if m.seq == 3:52break5354self.drain_mav()5556m = self.assert_receive_message('NAV_CONTROLLER_OUTPUT', timeout=1)5758wp_dist_min = 559if m.wp_dist < wp_dist_min:60raise PreconditionFailedException(61"Did not start at least %f metres from destination (is=%f)" %62(wp_dist_min, m.wp_dist))6364self.progress("NAV_CONTROLLER_OUTPUT.wp_dist looks good (%u >= %u)" %65(m.wp_dist, wp_dist_min,))6667# wait for mission to complete68self.wait_statustext("Mission Complete", timeout=70)6970# sailboat loiters around RTL point indefinitely:71self.wait_groundspeed(0.5, 3, timeout=20, minimum_duration=10)7273self.disarm_vehicle()7475self.progress("RTL Mission OK")7677def DriveMission(self):78'''sail a simple mission'''79self.drive_mission("balancebot1.txt", strict=False)8081def tests(self):82'''return list of all tests'''83ret = ([])8485ret.extend([86self.DriveRTL,87self.DriveMission,88])89return ret9091def default_mode(self):92return 'MANUAL'939495