From 590c9040a7d15fa33b2f5d642c4b991a47933733 Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Mon, 19 Dec 2016 22:07:45 +0100 Subject: [PATCH] [nps] add norc option to nps simulator --- sw/simulator/nps/nps_main.h | 1 + sw/simulator/nps/nps_main_common.c | 11 ++++++++--- sw/simulator/nps/nps_main_hitl.c | 4 +++- sw/simulator/nps/nps_main_sitl.c | 4 +++- sw/simulator/nps/nps_radio_control.c | 4 +++- sw/simulator/nps/nps_radio_control.h | 3 ++- sw/simulator/pprzsim-launch | 8 ++++++-- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/sw/simulator/nps/nps_main.h b/sw/simulator/nps/nps_main.h index 56dbeea00b0..18ef8be4715 100644 --- a/sw/simulator/nps/nps_main.h +++ b/sw/simulator/nps/nps_main.h @@ -62,6 +62,7 @@ struct NpsMain { char *js_dev; char *spektrum_dev; int rc_script; + bool norc; char *ivy_bus; }; diff --git a/sw/simulator/nps/nps_main_common.c b/sw/simulator/nps/nps_main_common.c index 3c2d401ba8c..ffa7544e6d3 100644 --- a/sw/simulator/nps/nps_main_common.c +++ b/sw/simulator/nps/nps_main_common.c @@ -154,6 +154,7 @@ bool nps_main_parse_options(int argc, char **argv) nps_main.js_dev = NULL; nps_main.spektrum_dev = NULL; nps_main.rc_script = 0; + nps_main.norc = false; nps_main.ivy_bus = NULL; nps_main.host_time_factor = 1.0; nps_main.fg_fdm = 0; @@ -169,6 +170,7 @@ bool nps_main_parse_options(int argc, char **argv) " -j --js_dev e.g. 1 (default 0)\n" " --spektrum_dev e.g. /dev/ttyUSB0\n" " --rc_script e.g. 0\n" + " --norc e.g. disable RC\n" " --ivy_bus e.g. 127.255.255.255\n" " --time_factor e.g. 2.5\n" " --fg_fdm"; @@ -183,6 +185,7 @@ bool nps_main_parse_options(int argc, char **argv) {"js_dev", 2, NULL, 0}, {"spektrum_dev", 1, NULL, 0}, {"rc_script", 1, NULL, 0}, + {"norc", 0, NULL, 0}, {"ivy_bus", 1, NULL, 0}, {"time_factor", 1, NULL, 0}, {"fg_fdm", 0, NULL, 0}, @@ -214,12 +217,14 @@ bool nps_main_parse_options(int argc, char **argv) case 5: nps_main.rc_script = atoi(optarg); break; case 6: - nps_main.ivy_bus = strdup(optarg); break; + nps_main.norc = true; break; case 7: - nps_main.host_time_factor = atof(optarg); break; + nps_main.ivy_bus = strdup(optarg); break; case 8: - nps_main.fg_fdm = 1; break; + nps_main.host_time_factor = atof(optarg); break; case 9: + nps_main.fg_fdm = 1; break; + case 10: nps_main.fg_port_in = atoi(optarg); break; } break; diff --git a/sw/simulator/nps/nps_main_hitl.c b/sw/simulator/nps/nps_main_hitl.c index 6f40547960b..68562bb01e4 100644 --- a/sw/simulator/nps/nps_main_hitl.c +++ b/sw/simulator/nps/nps_main_hitl.c @@ -79,7 +79,9 @@ void nps_radio_and_autopilot_init(void) { enum NpsRadioControlType rc_type; char *rc_dev = NULL; - if (nps_main.js_dev) { + if (nps_main.norc) { + rc_type = NORC; + } else if (nps_main.js_dev) { rc_type = JOYSTICK; rc_dev = nps_main.js_dev; } else if (nps_main.spektrum_dev) { diff --git a/sw/simulator/nps/nps_main_sitl.c b/sw/simulator/nps/nps_main_sitl.c index ebf28b7058f..bfa84360ca7 100644 --- a/sw/simulator/nps/nps_main_sitl.c +++ b/sw/simulator/nps/nps_main_sitl.c @@ -56,7 +56,9 @@ void nps_radio_and_autopilot_init(void) { enum NpsRadioControlType rc_type; char *rc_dev = NULL; - if (nps_main.js_dev) { + if (nps_main.norc) { + rc_type = NORC; + } else if (nps_main.js_dev) { rc_type = JOYSTICK; rc_dev = nps_main.js_dev; } else if (nps_main.spektrum_dev) { diff --git a/sw/simulator/nps/nps_radio_control.c b/sw/simulator/nps/nps_radio_control.c index 2cfc4224a46..fe9cbf91501 100644 --- a/sw/simulator/nps/nps_radio_control.c +++ b/sw/simulator/nps/nps_radio_control.c @@ -48,6 +48,8 @@ void nps_radio_control_init(enum NpsRadioControlType type, int num_script, char break; case SCRIPT: break; + case NORC: + break; default: break; } @@ -78,7 +80,7 @@ static rc_script scripts[] = { bool nps_radio_control_available(double time) { - if (time >= nps_radio_control.next_update) { + if (time >= nps_radio_control.next_update && nps_radio_control.type != NORC) { nps_radio_control.next_update += RADIO_CONTROL_DT; if (nps_radio_control.type == JOYSTICK) { diff --git a/sw/simulator/nps/nps_radio_control.h b/sw/simulator/nps/nps_radio_control.h index b28e02ad13b..0360936f3cc 100644 --- a/sw/simulator/nps/nps_radio_control.h +++ b/sw/simulator/nps/nps_radio_control.h @@ -31,7 +31,8 @@ enum NpsRadioControlType { SCRIPT, JOYSTICK, - SPEKTRUM + SPEKTRUM, + NORC }; extern void nps_radio_control_init(enum NpsRadioControlType type, int num_script, char *js_dev); diff --git a/sw/simulator/pprzsim-launch b/sw/simulator/pprzsim-launch index 38cffbd8c67..7ab09c628d7 100755 --- a/sw/simulator/pprzsim-launch +++ b/sw/simulator/pprzsim-launch @@ -48,14 +48,16 @@ def main(): help="Host for FlightGear visualization (e.g. 127.0.0.1)") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") + parser.add_option("--norc", dest="norc", action="store_true", + help="Hide the simulated RC") # special options for the fixedwing OCaml sim ocamlsim_opts = OptionGroup(parser, "Simple fixedwing OCaml Simulator Options", "These are only relevant to the simple fixedwing OCaml sim") ocamlsim_opts.add_option("--boot", dest="boot", action="store_true", help="Boot the aircraft on start") - ocamlsim_opts.add_option("--norc", dest="norc", action="store_true", - help="Hide the simulated RC") + #ocamlsim_opts.add_option("--norc", dest="norc", action="store_true", + # help="Hide the simulated RC") ocamlsim_opts.add_option("--noground", dest="noground", action="store_true", help="Disable ground detection") ocamlsim_opts.add_option("--launch", dest="launch", action="store_true", @@ -152,6 +154,8 @@ def main(): if options.rc_script: simargs.append("--rc_script") simargs.append(options.rc_script) + if options.norc: + simargs.append("--norc") if options.ivy_bus: simargs.append("--ivy_bus") simargs.append(options.ivy_bus)