feat(ekf2): Fusion-Control of sensors over MAVLink#26739
Conversation
💡 Commit messages could be improvedNot blocking, but these commit messages could use some cleanup.
See the commit message convention for details. This comment will be automatically removed once the issues are resolved. |
3d7df89 to
b01d6c8
Compare
|
Rebased to clean up an error picked up from main |
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 1896 byte (0.09 %)]px4_fmu-v6x [Total VM Diff: 1928 byte (0.1 %)]Updated: 2026-04-02T14:06:00 |
b01d6c8 to
17b0435
Compare
17b0435 to
8d53692
Compare
sfuhrer
left a comment
There was a problem hiding this comment.
I would consider removing all the _CTRL parameters that are simple bools. They are now redundant with the new bitmask you introduce here. You'd though need to add parameter translations from the _CTRL to the bitmask.
ab41d53 to
6686413
Compare
bresch
left a comment
There was a problem hiding this comment.
Why not simply: if enabled, then use _param_ekf2_xxx_ctrl, otherwise stop the fusion?
For example, if baro is disabled by the manufacturer, it should not be possible to enable it through that mavlink command.
And why storing the fusion control bitmask in a parameter? I would argue that it should start as configured by the _ctrl parameter and then it could be disabled and re-enabled (if it was configured in _ctrl) using mavlink
ac3810a to
8ad8d34
Compare
…t only as reference
abd0345 to
8d0fa65
Compare
Split FusionSensor into available (CTRL param != disabled) and enabled (runtime-toggleable). intended() = enabled && available. EKF core aid sources now set available themselves and use intended() or _params directly for CTRL-level checks. Remove drag/imu from FusionControl, add aspd/rngbcn. Add AGP sourceFusingBitmask() for active-status.
Add EKF2_SENS_EN bitmask parameter (replaces EKF2_EN_BOOT) with per-sensor enable bits. initFusionControl reads SENS_EN while disarmed. handleSensorFusionCommand sets FusionSensor.enabled via VEHICLE_CMD_ESTIMATOR_SENSOR_ENABLE. syncSensEnParam writes back to param on disarm. Update EstimatorFusionControl.msg to bool intended/active fields. Update VehicleCommand.msg FUSION_SOURCE enum.
Add MAVLink stream that maps EstimatorFusionControl uORB message to ESTIMATOR_SENSOR_FUSION_STATUS, exposing per-sensor intended/active bitmasks to the GCS.
EkfWrapper now holds a FusionControl pointer and enables all sensors by default. Sensor-specific enable methods also set fc.enabled = true.
…R_SENSOR_FUSION_STATUS, MAV_CMD_ESTIMATOR_SENSOR_ENABLE
d8ca7e7 to
bd2990e
Compare
Solved Problem
There is no way to enable or disable individual EKF2 sensor fusion sources at runtime without changing parameters. This leads to the issue that the GCS needs to know or cache the default values of a sensor with different options.
Solution
Add a MAVLink command and status message so a GCS can enable/disable sensor fusion sources with a simple on/off command, without needing to know the underlying parameter values.
MAV_CMD_SET_ESTIMATOR_SENSOR_FUSION(43005): Enable or disable a sensor source (GPS, OF, EV, AGP, BARO, RNG, DRAG, MAG, ASPD) at runtime. The CTRL param values are preserved and applied when the source is re-enabled.ESTIMATOR_SENSOR_FUSION_STATUS: MAVLink message reporting which sources are intended (enabled) and which are actively fusing, streamed at 1 Hz.EKF2_SENS_EN: New bitmask parameter tracking which sources are enabled. Updated automatically by the MAVLink command, persists across reboots.Internally, a
FusionControlstruct sits between the parameters and the EKF core. The EKF reads_fc.<sensor>.intendedinstead of the CTRL params directly. When a source is disabled, its intended value is forced to the disabled state while the actual CTRL param remains unchanged.The message format is prepared for dual-GPS support (
gps_intended[2],gps_activebitmask) even though only one GPS instance is wired internally for now.Changelog Entry
For release notes:
Test coverage
Context
New MAVLink definitions (not yet merged):
MAV_CMD_SET_ESTIMATOR_SENSOR_FUSION(43005)ESTIMATOR_SENSOR_FUSION_SOURCEenum (values 1–9) + Ranging-Beacon (todo)ESTIMATOR_SENSOR_FUSION_STATUSmessage (id 514)TODO:
Add support for ranging beacons as soon as sensor is approved in new MAVLink message (id 513)