SITL: add an option to launch SITL from a directory

This commit is contained in:
Pierre Kancir 2016-12-16 18:52:19 +01:00 committed by Francisco Ferreira
parent 021f68897a
commit a6c82a0919

View File

@ -9,6 +9,7 @@ based on sim_vehicle.sh by Andrew Tridgell, October 2011
from __future__ import print_function from __future__ import print_function
import atexit import atexit
import errno
import getpass import getpass
import optparse import optparse
import os 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("-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("", "--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("", "--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) parser.add_option_group(group_sim)
@ -856,6 +858,15 @@ else:
location = find_location_by_name(find_autotest_dir(), cmd_opts.location) location = find_location_by_name(find_autotest_dir(), cmd_opts.location)
progress("Starting up at %s (%s)" % (location, 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: if cmd_opts.hil:
# (unlikely) # (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)]) 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)])