From a2d8b554c952f4e70853aff80a5f315b0d3c5ec5 Mon Sep 17 00:00:00 2001 From: Jonas Perolini <74473718+JonasPerolini@users.noreply.github.com> Date: Mon, 26 Oct 2026 11:37:32 +0100 Subject: [PATCH] fix(commander): compile out unusable calibration to fit kakutef7 (#29430) * fix(commander): compile out airspeed calibration without airspeed processing Without CONFIG_SENSORS_VEHICLE_AIRSPEED nothing turns differential pressure into airspeed, so the offset this calibration writes is never applied. Gate it like the magnetometer calibration and answer the command with UNSUPPORTED. This also covers px4_fmu-v2_fixedwing, which inherits the option off from fmu-v2's default config, so its MS4525DO readings already never reach the controllers. main has not linked holybro_kakutef7 since #28764 (24 B over at 1c3c7e5a72). Flash with the CI compiler (GCC 13.2.1), main -> this commit: - holybro_kakutef7: 950,296 -> 947,448 B of 950,272 (99.70 %) - diatone_mamba-f405-mk2: 1,013,721 -> 1,010,889 B (99.52 %) - px4_fmu-v2: 1,028,624 -> 1,025,768 B (99.38 %) - bitcraze_crazyflie: 1,022,720 -> 1,019,896 B (98.81 %) Boards with airspeed processing are unchanged (px4_fmu-v6c is byte-identical). Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas * fix(mavlink): drop MAG_CAL_REPORT from constrained builds without mag Flash constrained builds without CONFIG_SENSORS_VEHICLE_MAGNETOMETER have no magnetometer calibration, so there is nothing to report. Other builds keep the stream: builds without the sensors module, such as the VOXL2 apps side, still report the SLPI's calibration, and only constrained builds may lack a stream that the mode tables list. holybro_kakutef7: 947,448 -> 945,424 B of 950,272 (99.49 %). Assisted-by: Claude:claude-opus-5-5 Signed-off-by: jonas --------- Signed-off-by: jonas Co-authored-by: jonas --- src/modules/commander/CMakeLists.txt | 5 ++++- src/modules/commander/Commander.cpp | 4 ++++ src/modules/commander/worker_thread.cpp | 10 ++++++++++ src/modules/mavlink/mavlink_messages.cpp | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modules/commander/CMakeLists.txt b/src/modules/commander/CMakeLists.txt index 6a3280ba097..ca6ebf55e5b 100644 --- a/src/modules/commander/CMakeLists.txt +++ b/src/modules/commander/CMakeLists.txt @@ -40,6 +40,10 @@ add_subdirectory(MulticopterThrowLaunch) set(SRCS) +if(CONFIG_SENSORS_VEHICLE_AIRSPEED) + list(APPEND SRCS airspeed_calibration.cpp) +endif() + if(CONFIG_SENSORS_VEHICLE_MAGNETOMETER) list(APPEND SRCS mag_calibration.cpp) endif() @@ -51,7 +55,6 @@ px4_add_module( SRCS ${SRCS} accelerometer_calibration.cpp - airspeed_calibration.cpp baro_calibration.cpp calibration_routines.cpp Commander.cpp diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index b8b7b7d77b9..67bcb95f457 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -1525,9 +1525,13 @@ Commander::handle_command(const vehicle_command_s &cmd) } else if ((int)(cmd.param6) == 1 || (int)(cmd.param6) == 2) { // TODO: param6 == 1 is deprecated, but we still accept it for a while (feb 2017) /* airspeed calibration */ +#if defined(CONFIG_SENSORS_VEHICLE_AIRSPEED) answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED); _vehicle_status.calibration_enabled = true; _worker_thread.startTask(WorkerThread::Request::AirspeedCalibration); +#else + answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED); +#endif } else if ((int)(cmd.param7) == 1) { /* do esc calibration */ diff --git a/src/modules/commander/worker_thread.cpp b/src/modules/commander/worker_thread.cpp index 97e8781c236..23a36a1a5af 100644 --- a/src/modules/commander/worker_thread.cpp +++ b/src/modules/commander/worker_thread.cpp @@ -33,7 +33,9 @@ #include "worker_thread.hpp" #include "accelerometer_calibration.h" +#if defined(CONFIG_SENSORS_VEHICLE_AIRSPEED) #include "airspeed_calibration.h" +#endif #include "calibration_routines.h" #include "baro_calibration.h" #include "esc_calibration.h" @@ -146,9 +148,17 @@ void WorkerThread::threadEntry() _ret_value = do_accel_calibration_quick(&_mavlink_log_pub); break; +#if defined(CONFIG_SENSORS_VEHICLE_AIRSPEED) + case Request::AirspeedCalibration: _ret_value = do_airspeed_calibration(&_mavlink_log_pub); break; +#else + + case Request::AirspeedCalibration: + _ret_value = -1; + break; +#endif case Request::ESCCalibration: _ret_value = do_esc_calibration(&_mavlink_log_pub); diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp index aa01df6b311..1f1beedd3ae 100644 --- a/src/modules/mavlink/mavlink_messages.cpp +++ b/src/modules/mavlink/mavlink_messages.cpp @@ -94,7 +94,10 @@ #include "streams/HYGROMETER_SENSOR.hpp" #include "streams/LANDING_TARGET.hpp" #include "streams/LOCAL_POSITION_NED.hpp" +// constrained builds without mag processing have no mag calibration to report +#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER) || !defined(CONSTRAINED_FLASH) #include "streams/MAG_CAL_REPORT.hpp" +#endif #include "streams/MANUAL_CONTROL.hpp" #if defined(MAVLINK_MSG_ID_MANUAL_INPUT_STATUS) #include "streams/MANUAL_INPUT_STATUS.hpp"