SET_ALT fixes and tightening#11491
SET_ALT fixes and tightening#11491xznhj8129 wants to merge 2 commits intoiNavFlight:maintenance-10.xfrom
Conversation
Review Summary by QodoFix SET_ALT feature guard and tighten acceptance policy
WalkthroughsDescription• Fix SET_ALT feature guard from USE_BARO to USE_GPS • Tighten altitude target acceptance policy with additional safety checks • Refactor MSP SET_ALT command parsing for clarity and safety • Add checks for mixer rate, autoland, send-to, and RTH states Diagramflowchart LR
A["MSP SET_ALT Command"] -->|Feature Guard| B["USE_GPS instead of USE_BARO"]
A -->|Parse & Validate| C["Extract datum and altitude"]
C -->|Enhanced Checks| D["navigationSetAltitudeTargetWithDatum"]
D -->|Safety Conditions| E["Verify flight state and altitude status"]
E -->|Accept/Reject| F["MSP_RESULT_ACK or MSP_RESULT_ERROR"]
File Changes1. src/main/fc/fc_msp.c
|
Code Review by Qodo
|
| #ifdef USE_GPS | ||
| case MSP2_INAV_SET_ALT_TARGET: | ||
| if (dataSize != (sizeof(int32_t) + sizeof(uint8_t))) { |
There was a problem hiding this comment.
2. Msp set_alt gps-gated 🐞 Bug ≡ Correctness
MSP2_INAV_SET_ALT_TARGET is now compiled only when USE_GPS is defined, which removes MSP altitude-target control from barometer-only builds. This is a functional regression because navigationSetAltitudeTargetWithDatum() supports NAV_WP_TAKEOFF_DATUM without requiring GPS origin.
Agent Prompt
### Issue description
`MSP2_INAV_SET_ALT_TARGET` is now wrapped in `#ifdef USE_GPS`, which disables MSP altitude-target changes for barometer-only builds even though `navigationSetAltitudeTargetWithDatum()` supports `NAV_WP_TAKEOFF_DATUM` without GPS.
### Issue Context
`navigationSetAltitudeTargetWithDatum()` only requires `posControl.gpsOrigin.valid` for the MSL datum path; the takeoff datum path is GPS-independent. Also, altitude estimation can be valid without a GPS fix.
### Fix Focus Areas
- Update the compile guard to allow non-GPS altitude sources (e.g., `#if defined(USE_BARO) || defined(USE_GPS)`), or otherwise ensure the handler is available whenever `navigationSetAltitudeTargetWithDatum()` is linked.
- src/main/fc/fc_msp.c[4221-4236]
- src/main/navigation/navigation.c[5204-5236]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| #ifdef USE_GPS | ||
| if (msg.command == MAV_CMD_DO_CHANGE_ALTITUDE) { | ||
| const float altitudeMeters = msg.param1; | ||
| const uint8_t frame = (uint8_t)msg.frame; |
There was a problem hiding this comment.
3. Mavlink set_alt gps-gated 🐞 Bug ≡ Correctness
MAV_CMD_DO_CHANGE_ALTITUDE handling is now compiled only when USE_GPS is defined, causing barometer-only builds to always respond UNSUPPORTED to altitude-change commands. This breaks the MAV_FRAME_GLOBAL_RELATIVE_ALT path which maps to takeoff datum and does not require GPS origin.
Agent Prompt
### Issue description
`MAV_CMD_DO_CHANGE_ALTITUDE` support is now wrapped in `#ifdef USE_GPS`, which disables the command even for takeoff-datum (relative altitude) changes that do not require GPS origin.
### Issue Context
The MAVLink handler maps `MAV_FRAME_GLOBAL_RELATIVE_ALT` / `_INT` to `NAV_WP_TAKEOFF_DATUM` and then calls `navigationSetAltitudeTargetWithDatum()`. That navigation function only requires GPS origin for MSL datum.
### Fix Focus Areas
- Change the compile guard to include barometer-only builds (e.g., `#if defined(USE_BARO) || defined(USE_GPS)`) or otherwise align it with when altitude control is available.
- src/main/telemetry/mavlink.c[1218-1257]
- src/main/navigation/navigation.c[5204-5236]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Test firmware build ready — commit Download firmware for PR #11491 228 targets built. Find your board's
|
|
Looking at the qodo comments, I'm not too concerned about the type conversion. do see a couple places in the code that handle altitude use: |
Addresses some issues reported in #11364 and tightens safety around MSP SET_ALT