From a6c82a091978cf7ccaf95ef575dce97b94bc342f Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Fri, 16 Dec 2016 18:52:19 +0100 Subject: [PATCH] SITL: add an option to launch SITL from a directory --- Tools/autotest/sim_vehicle.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tools/autotest/sim_vehicle.py b/Tools/autotest/sim_vehicle.py index ff4f9de734..854086aec7 100755 --- a/Tools/autotest/sim_vehicle.py +++ b/Tools/autotest/sim_vehicle.py @@ -9,6 +9,7 @@ based on sim_vehicle.sh by Andrew Tridgell, October 2011 from __future__ import print_function import atexit +import errno import getpass import optparse import os @@ -750,6 +751,7 @@ group_sim.add_option("-w", "--wipe-eeprom", action='store_true', default=False, group_sim.add_option("-m", "--mavproxy-args", default=None, type='string', help="additional arguments to pass to mavproxy.py") group_sim.add_option("", "--strace", action='store_true', default=False, help="strace the ArduPilot binary") group_sim.add_option("", "--model", type='string', default=None, help="Override simulation model to use") +group_sim.add_option("", "--use-dir", type='string', default=None, help="Store SITL state and output in named directory") parser.add_option_group(group_sim) @@ -856,6 +858,15 @@ else: location = find_location_by_name(find_autotest_dir(), cmd_opts.location) progress("Starting up at %s (%s)" % (location, cmd_opts.location)) +if cmd_opts.use_dir is not None: + new_dir = cmd_opts.use_dir + try: + os.makedirs(os.path.realpath(new_dir)) + except OSError as exception: + if exception.errno != errno.EEXIST: + raise + os.chdir(new_dir) + if cmd_opts.hil: # (unlikely) run_in_terminal_window(find_autotest_dir(), "JSBSim", [os.path.join(find_autotest_dir(), "jsb_sim/runsim.py"), "--home", location, "--speedup=" + str(cmd_opts.speedup)])