mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-29 20:20:56 +08:00
fix(commander): build mag calibration only with CONFIG_SENSORS_VEHICLE_MAGNETOMETER (#28555)
Boards that compile the magnetometer pipeline out still linked 8.6 KB of calibration that could never run. holybro_kakutef7 is one of them and sits at 100 % of flash on main. The calibration commands answer UNSUPPORTED there.
This commit is contained in:
1 parent
29120280ac
commit
6dc89338a8
3 files changed
+33
-6
No files matched your search
@@ -38,11 +38,18 @@ add_subdirectory(HealthAndArmingChecks)
|
||||
add_subdirectory(ModeUtil)
|
||||
add_subdirectory(MulticopterThrowLaunch)
|
||||
|
||||
set(SRCS)
|
||||
|
||||
if(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
list(APPEND SRCS mag_calibration.cpp)
|
||||
endif()
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__commander
|
||||
MAIN commander
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
${SRCS}
|
||||
accelerometer_calibration.cpp
|
||||
airspeed_calibration.cpp
|
||||
baro_calibration.cpp
|
||||
@@ -56,7 +63,6 @@ px4_add_module(
|
||||
ModeManagement.cpp
|
||||
level_calibration.cpp
|
||||
lm_fit.cpp
|
||||
mag_calibration.cpp
|
||||
rc_calibration.cpp
|
||||
Safety.cpp
|
||||
UserModeIntention.cpp
|
||||
@@ -79,5 +85,7 @@ px4_add_module(
|
||||
atmosphere
|
||||
)
|
||||
|
||||
px4_add_unit_gtest(SRC mag_calibration_test.cpp LINKLIBS modules__commander)
|
||||
if(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
px4_add_unit_gtest(SRC mag_calibration_test.cpp LINKLIBS modules__commander)
|
||||
endif()
|
||||
px4_add_functional_gtest(SRC ModeManagementTest.cpp LINKLIBS modules__commander)
|
||||
@@ -1459,9 +1459,13 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
|
||||
} else if ((int)(cmd.param2) == 1) {
|
||||
/* magnetometer calibration */
|
||||
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
_vehicle_status.calibration_enabled = true;
|
||||
_worker_thread.startTask(WorkerThread::Request::MagCalibration);
|
||||
#else
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED);
|
||||
#endif
|
||||
|
||||
} else if ((int)(cmd.param3) == 1) {
|
||||
/* baro calibration */
|
||||
@@ -1564,6 +1568,7 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
"Calibration denied: not supported in SIH mode");
|
||||
|
||||
} else {
|
||||
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
|
||||
// parameter 1: Heading (degrees)
|
||||
// parameter 3: Latitude (degrees)
|
||||
@@ -1586,6 +1591,9 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
_vehicle_status.calibration_enabled = true;
|
||||
_worker_thread.setMagQuickData(heading_radians, latitude, longitude);
|
||||
_worker_thread.startTask(WorkerThread::Request::MagCalibrationQuick);
|
||||
#else
|
||||
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
#include "esc_calibration.h"
|
||||
#include "gyro_calibration.h"
|
||||
#include "level_calibration.h"
|
||||
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
#include "mag_calibration.h"
|
||||
#endif
|
||||
#include "rc_calibration.h"
|
||||
|
||||
#include <px4_platform_common/events.h>
|
||||
@@ -111,10 +113,23 @@ void WorkerThread::threadEntry()
|
||||
_ret_value = do_gyro_calibration(&_mavlink_log_pub);
|
||||
break;
|
||||
|
||||
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
|
||||
|
||||
case Request::MagCalibration:
|
||||
_ret_value = do_mag_calibration(&_mavlink_log_pub);
|
||||
break;
|
||||
|
||||
case Request::MagCalibrationQuick:
|
||||
_ret_value = do_mag_calibration_quick(&_mavlink_log_pub, _heading_radians, _latitude, _longitude);
|
||||
break;
|
||||
#else
|
||||
|
||||
case Request::MagCalibration:
|
||||
case Request::MagCalibrationQuick:
|
||||
_ret_value = -1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Request::RCTrimCalibration:
|
||||
_ret_value = do_trim_calibration(&_mavlink_log_pub);
|
||||
break;
|
||||
@@ -139,10 +154,6 @@ void WorkerThread::threadEntry()
|
||||
_ret_value = do_esc_calibration(&_mavlink_log_pub);
|
||||
break;
|
||||
|
||||
case Request::MagCalibrationQuick:
|
||||
_ret_value = do_mag_calibration_quick(&_mavlink_log_pub, _heading_radians, _latitude, _longitude);
|
||||
break;
|
||||
|
||||
case Request::BaroCalibration:
|
||||
_ret_value = do_baro_calibration(&_mavlink_log_pub);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user