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/run_mission.py
Views: 1798
#!/usr/bin/env python312'''3Run a mission in SITL45AP_FLAKE8_CLEAN6'''78import vehicle_test_suite9import os10import sys11import argparse1213from pysim import util141516class RunMission(vehicle_test_suite.TestSuite):17def __init__(self, vehicle_binary, model, mission_filepath, speedup=None, sim_rate_hz=None):18super(RunMission, self).__init__(vehicle_binary)19self.mission_filepath = mission_filepath20self.model = model21self.speedup = speedup22self.sim_rate_hz = sim_rate_hz2324if self.speedup is None:25self.speedup = 1002627def vehicleinfo_key(self):28'''magically guess vehicleinfo_key from filepath'''29path = self.binary.lower()30if "plane" in path:31return "ArduPlane"32if "copter" in path:33return "ArduCopter"34raise ValueError("Can't determine vehicleinfo_key from binary path")3536def run(self):37self.start_SITL(38binary=self.binary,39model=self.model,40sitl_home=self.sitl_home_string_from_mission_filepath(self.mission_filepath),41speedup=self.speedup,42sim_rate_hz=self.sim_rate_hz,43defaults_filepath=self.model_defaults_filepath(self.model),44)45self.get_mavlink_connection_going()4647# hack; Plane defaults are annoying... we should do better48# here somehow.49if self.vehicleinfo_key() == "ArduPlane":50self.set_parameter("RTL_AUTOLAND", 1)5152self.load_mission_from_filepath(self.mission_filepath, strict=False)53self.change_mode('AUTO')54self.set_streamrate(1)55self.wait_ready_to_arm()56self.arm_vehicle()57self.wait_disarmed(timeout=600)58self.stop_SITL()596061if __name__ == "__main__":62''' main program '''63os.environ['PYTHONUNBUFFERED'] = '1'6465if sys.platform != "darwin":66os.putenv('TMPDIR', util.reltopdir('tmp'))6768parser = argparse.ArgumentParser("run_mission.py")69parser.add_argument(70'vehicle_binary',71type=str,72help='vehicle binary to use'73)74parser.add_argument(75'model',76type=str,77help='vehicle model to use'78)79parser.add_argument(80'mission_filepath',81type=str,82help='mission file path'83)84parser.add_argument(85'--speedup',86type=int,87help='simulation speedup',88default=None,89)90parser.add_argument(91'--sim-rate-hz',92type=int,93help='simulation physics rate',94default=None,95)9697args = parser.parse_args()9899x = RunMission(100args.vehicle_binary,101args.model,102args.mission_filepath,103speedup=args.speedup,104sim_rate_hz=args.sim_rate_hz105)106x.run()107108109