aboutsummaryrefslogtreecommitdiff
path: root/apps/commander/commander.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-10-30 16:44:16 +0100
committerLorenz Meier <lm@inf.ethz.ch>2012-10-30 16:44:16 +0100
commit96dc901caeeb8a09e45f9a071d2f28d5b01148c5 (patch)
tree70334fbecb1f02fcd1974212ebc14a5d1ac89335 /apps/commander/commander.c
parentb1a83be61189a8a5716e81b9c6042e16a741a337 (diff)
downloadpx4-firmware-96dc901caeeb8a09e45f9a071d2f28d5b01148c5.tar.gz
px4-firmware-96dc901caeeb8a09e45f9a071d2f28d5b01148c5.tar.bz2
px4-firmware-96dc901caeeb8a09e45f9a071d2f28d5b01148c5.zip
Fixed mag calibration
Diffstat (limited to 'apps/commander/commander.c')
-rw-r--r--apps/commander/commander.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/commander/commander.c b/apps/commander/commander.c
index d93a48e31..4b49201c7 100644
--- a/apps/commander/commander.c
+++ b/apps/commander/commander.c
@@ -308,7 +308,7 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
uint64_t calibration_interval = 45 * 1000 * 1000;
/* maximum 2000 values */
- const unsigned int calibration_maxcount = 2000;
+ const unsigned int calibration_maxcount = 500;
unsigned int calibration_counter = 0;
/* limit update rate to get equally spaced measurements over time (in ms) */
@@ -353,12 +353,18 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
uint64_t axis_deadline = hrt_absolute_time();
uint64_t calibration_deadline = hrt_absolute_time() + calibration_interval;
- const char axislabels[3] = { 'Z', 'X', 'Y'};
+ const char axislabels[3] = { 'X', 'Z', 'Y'};
int axis_index = -1;
- float *x = malloc(sizeof(float) * calibration_maxcount);
- float *y = malloc(sizeof(float) * calibration_maxcount);
- float *z = malloc(sizeof(float) * calibration_maxcount);
+ float *x = (float*)malloc(sizeof(float) * calibration_maxcount);
+ float *y = (float*)malloc(sizeof(float) * calibration_maxcount);
+ float *z = (float*)malloc(sizeof(float) * calibration_maxcount);
+
+ if (x == NULL || y == NULL || z == NULL) {
+ warnx("mag cal failed: out of memory");
+ mavlink_log_info(mavlink_fd, "mag cal failed: out of memory");
+ return;
+ }
tune_confirm();
sleep(2);
@@ -1095,7 +1101,7 @@ int commander_main(int argc, char *argv[])
daemon_task = task_spawn("commander",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 50,
- 8000,
+ 9000,
commander_thread_main,
(argv) ? (const char **)&argv[2] : (const char **)NULL);
thread_running = true;