From 984f07d8c4ca8721e1fc737760dc6702037be827 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 2 Mar 2016 02:02:49 +0100 Subject: [PATCH] Commander: Relax mag offset to maximum --- src/modules/commander/mag_calibration.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp index 0ad06cc18d..6856b858f3 100644 --- a/src/modules/commander/mag_calibration.cpp +++ b/src/modules/commander/mag_calibration.cpp @@ -522,15 +522,13 @@ calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mag &sphere_radius[cur_mag]); if (!PX4_ISFINITE(sphere_x[cur_mag]) || !PX4_ISFINITE(sphere_y[cur_mag]) || !PX4_ISFINITE(sphere_z[cur_mag])) { - mavlink_and_console_log_critical(mavlink_fd, "[cal] ERROR: Please retry"); mavlink_and_console_log_emergency(mavlink_fd, "ERROR: Retry calibration (sphere NaN, #%u)", cur_mag); result = calibrate_return_error; } - if (sqrtf(sphere_x[cur_mag] * sphere_x[cur_mag] + - sphere_y[cur_mag] * sphere_y[cur_mag] + sphere_z[cur_mag] * sphere_z[cur_mag]) - > MAG_MAX_OFFSET_LEN) { - mavlink_and_console_log_critical(mavlink_fd, "[cal] ERROR: Replace %s", (internal[cur_mag]) ? "board" : "GPS unit"); + if (fabsf(sphere_x[cur_mag]) > MAG_MAX_OFFSET_LEN || + fabsf(sphere_y[cur_mag]) > MAG_MAX_OFFSET_LEN || + fabsf(sphere_z[cur_mag]) > MAG_MAX_OFFSET_LEN) { mavlink_and_console_log_emergency(mavlink_fd, "ERROR: Replace %s, fault in mag #%u", (internal[cur_mag]) ? "board" : "GPS unit", cur_mag); mavlink_and_console_log_emergency(mavlink_fd, "Excessive offsets: %8.4f, %8.4f, %8.4f", (double)sphere_x[cur_mag], (double)sphere_y[cur_mag], (double)sphere_z[cur_mag]);