From d3dd4a21e2d4b3a25e4ab577574c1b0a72a9df9e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 9 Feb 2015 13:56:53 +0100 Subject: commander: Support commandline sensor calibration --- src/modules/commander/commander.cpp | 29 ++++++++++++++++++++++++++--- src/modules/commander/module.mk | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 8f491acae..f2e72dd0c 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2013-2014 PX4 Development Team. All rights reserved. + * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,7 +36,7 @@ * Main fail-safe handling. * * @author Petri Tanskanen - * @author Lorenz Meier + * @author Lorenz Meier * @author Thomas Gubler * @author Julian Oes * @author Anton Babushkin @@ -318,6 +318,29 @@ int commander_main(int argc, char *argv[]) exit(0); } + if (!strcmp(argv[1], "calibrate")) { + if (argc > 2) { + int calib_ret = OK; + if (!strcmp(argv[2], "mag")) { + calib_ret = do_mag_calibration(mavlink_fd); + } else if (!strcmp(argv[2], "accel")) { + calib_ret = do_accel_calibration(mavlink_fd); + } else if (!strcmp(argv[2], "gyro")) { + calib_ret = do_gyro_calibration(mavlink_fd); + } else { + warnx("argument %s unsupported.", argv[2]); + } + + if (calib_ret) { + errx(1, "calibration failed, exiting."); + } else { + exit(0); + } + } else { + warnx("missing argument"); + } + } + if (!strcmp(argv[1], "check")) { int mavlink_fd_local = open(MAVLINK_LOG_DEVICE, 0); int checkres = prearm_check(&status, mavlink_fd_local); @@ -350,7 +373,7 @@ void usage(const char *reason) fprintf(stderr, "%s\n", reason); } - fprintf(stderr, "usage: daemon {start|stop|status} [-p ]\n\n"); + fprintf(stderr, "usage: commander {start|stop|status|calibrate|check|arm|disarm}\n\n"); exit(1); } diff --git a/src/modules/commander/module.mk b/src/modules/commander/module.mk index 0e2a5356b..4a1369aba 100644 --- a/src/modules/commander/module.mk +++ b/src/modules/commander/module.mk @@ -48,7 +48,7 @@ SRCS = commander.cpp \ rc_calibration.cpp \ airspeed_calibration.cpp -MODULE_STACKSIZE = 1200 +MODULE_STACKSIZE = 5000 MAXOPTIMIZATION = -Os -- cgit v1.2.3