Skip to content

Commit

Permalink
[nps] add norc option to nps simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Dec 19, 2016
1 parent e577814 commit 590c904
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions sw/simulator/nps/nps_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct NpsMain {
char *js_dev;
char *spektrum_dev;
int rc_script;
bool norc;
char *ivy_bus;
};

Expand Down
11 changes: 8 additions & 3 deletions sw/simulator/nps/nps_main_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -169,6 +170,7 @@ bool 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"
" --norc e.g. disable RC\n"
" --ivy_bus <ivy bus> e.g. 127.255.255.255\n"
" --time_factor <factor> e.g. 2.5\n"
" --fg_fdm";
Expand All @@ -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},
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion sw/simulator/nps/nps_main_hitl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion sw/simulator/nps/nps_main_sitl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion sw/simulator/nps/nps_radio_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion sw/simulator/nps/nps_radio_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions sw/simulator/pprzsim-launch
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 590c904

Please sign in to comment.