mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[simulator] NPS: add --time_factor command line option
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#define SIM_DT (1./SYS_TIME_FREQUENCY)
|
||||
#define DISPLAY_DT (1./30.)
|
||||
#define HOST_TIMEOUT_MS 40
|
||||
#define HOST_TIME_FACTOR 1.
|
||||
|
||||
static struct {
|
||||
double real_initial_time;
|
||||
@@ -117,7 +116,6 @@ static void nps_main_init(void) {
|
||||
gettimeofday (&t, NULL);
|
||||
nps_main.real_initial_time = time_to_double(&t);
|
||||
nps_main.scaled_initial_time = time_to_double(&t);
|
||||
nps_main.host_time_factor = HOST_TIME_FACTOR;
|
||||
|
||||
nps_ivy_init(nps_main.ivy_bus);
|
||||
nps_fdm_init(SIM_DT);
|
||||
@@ -257,6 +255,7 @@ static bool_t nps_main_parse_options(int argc, char** argv) {
|
||||
nps_main.spektrum_dev = NULL;
|
||||
nps_main.rc_script = 0;
|
||||
nps_main.ivy_bus = NULL;
|
||||
nps_main.host_time_factor = 1.0;
|
||||
|
||||
static const char* usage =
|
||||
"Usage: %s [options]\n"
|
||||
@@ -268,7 +267,8 @@ static bool_t nps_main_parse_options(int argc, char** argv) {
|
||||
" -j --js_dev <optional joystick index> e.g. 1 (default 0)\n"
|
||||
" --spektrum_dev <spektrum device> e.g. /dev/ttyUSB0\n"
|
||||
" --rc_script <number> e.g. 0\n"
|
||||
" --ivy_bus <ivy bus> e.g. 127.255.255.255\n";
|
||||
" --ivy_bus <ivy bus> e.g. 127.255.255.255\n"
|
||||
" --time_factor <factor> e.g. 2.5\n";
|
||||
|
||||
|
||||
while (1) {
|
||||
@@ -281,6 +281,7 @@ static bool_t nps_main_parse_options(int argc, char** argv) {
|
||||
{"spektrum_dev", 1, NULL, 0},
|
||||
{"rc_script", 1, NULL, 0},
|
||||
{"ivy_bus", 1, NULL, 0},
|
||||
{"time_factor", 1, NULL, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
int option_index = 0;
|
||||
@@ -308,6 +309,8 @@ static bool_t nps_main_parse_options(int argc, char** argv) {
|
||||
nps_main.rc_script = atoi(optarg); break;
|
||||
case 6:
|
||||
nps_main.ivy_bus = strdup(optarg); break;
|
||||
case 7:
|
||||
nps_main.host_time_factor = atof(optarg); break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ def main():
|
||||
help="Spektrum device to use (e.g. /dev/ttyUSB0)")
|
||||
nps_opts.add_option("--rc_script", type="int", action="store", metavar="NO",
|
||||
help="Number of RC script to use")
|
||||
nps_opts.add_option("--time_factor", type="float", action="store", metavar="factor",
|
||||
help="Time factor (default 1.0)")
|
||||
|
||||
# special options for the JSBSim sim (without sensor models)
|
||||
#jsbsim_opts = OptionGroup(parser, "JSBSim options",
|
||||
@@ -138,6 +140,9 @@ def main():
|
||||
if options.ivy_bus:
|
||||
simargs.append("--ivy_bus")
|
||||
simargs.append(options.ivy_bus)
|
||||
if options.time_factor:
|
||||
simargs.append("--time_factor")
|
||||
simargs.append(str(options.time_factor))
|
||||
else:
|
||||
parser.error("Please specify a valid sim type.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user