Skip to content

Commit

Permalink
commander: refactor module usage output
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng committed Aug 19, 2019
1 parent 4f30103 commit 663adbd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ else
then
set OUTPUT_MODE hil
sensors start -h
commander start --hil
commander start -h
# disable GPS
param set GPS_1_CONFIG 0

Expand Down
29 changes: 26 additions & 3 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,34 @@ int commander_main(int argc, char *argv[])

void usage(const char *reason)
{
if (reason && *reason > 0) {
if (reason) {
PX4_INFO("%s", reason);
}

PX4_INFO("usage: commander {start|stop|status|calibrate|check|arm [-f]|disarm|takeoff|land|transition|mode}\n");
PRINT_MODULE_DESCRIPTION(
R"DESCR_STR(
### Description
The commander module contains the state machine for mode switching and failsafe behavior.
)DESCR_STR");

PRINT_MODULE_USAGE_NAME("commander", "system");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAM_FLAG('h', "Enable HIL mode", true);
PRINT_MODULE_USAGE_COMMAND_DESCR("calibrate", "Run sensor calibration");
PRINT_MODULE_USAGE_ARG("mag|accel|gyro|level|esc|airspeed", "Calibration type", false);
PRINT_MODULE_USAGE_COMMAND_DESCR("check", "Run preflight checks");
PRINT_MODULE_USAGE_COMMAND("arm");
PRINT_MODULE_USAGE_PARAM_FLAG('f', "Force arming (do not run preflight checks)", true);
PRINT_MODULE_USAGE_COMMAND("disarm");
PRINT_MODULE_USAGE_COMMAND("takeoff");
PRINT_MODULE_USAGE_COMMAND("land");
PRINT_MODULE_USAGE_COMMAND_DESCR("transition", "VTOL transition");
PRINT_MODULE_USAGE_COMMAND_DESCR("mode", "Change flight mode");
PRINT_MODULE_USAGE_ARG("manual|acro|offboard|stabilized|rattitude|altctl|posctl|auto:mission|auto:loiter|auto:rtl|auto:takeoff|auto:land|auto:precland",
"Flight mode", false);
PRINT_MODULE_USAGE_COMMAND("lockdown");
PRINT_MODULE_USAGE_ARG("off", "Turn lockdown off", true);
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

void print_status()
Expand Down Expand Up @@ -3634,7 +3657,7 @@ Commander *Commander::instantiate(int argc, char *argv[])
Commander *instance = new Commander();

if (instance) {
if (argc >= 2 && !strcmp(argv[1], "--hil")) {
if (argc >= 2 && !strcmp(argv[1], "-h")) {
instance->enable_hil();
}
}
Expand Down

0 comments on commit 663adbd

Please sign in to comment.