CRSF telemetry: selectable altitude source for the GPS frame (ESTIMATED/MSL) - #11850
CRSF telemetry: selectable altitude source for the GPS frame (ESTIMATED/MSL)#11850raphaelhunziker1202-stack wants to merge 2 commits into
Conversation
…s_alt_source) The altitude field of the CRSF GPS frame (0x02) so far carried INAV's estimated altitude relative to the arming point, while the CRSF specification intends this field to carry the GPS altitude (MSL), which is also what Betaflight sends and what the GAlt sensor on EdgeTX/OpenTX radios is expected to show. Add a new setting `crsf_gps_alt_source`: - ESTIMATED (default): estimated altitude above the arming point, identical to the previous behaviour - MSL: raw GNSS altitude above mean sea level The relative altitude remains available via the barometer/vario frame (Alt sensor) regardless of this setting. PG_TELEMETRY_CONFIG version bumped 8 -> 9.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
PR Summary by QodoAdd selectable CRSF GPS altitude source
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
| if (telemetryConfig()->crsfGpsAltSource == CRSF_GPS_ALT_MSL) { | ||
| altitudeCm = gpsSol.llh.alt; |
There was a problem hiding this comment.
2. Synthetic altitude labeled raw 🐞 Bug ≡ Correctness
The MSL branch reads the post-processed gpsSol.llh.alt, which GPS-fix estimation overwrites with gpsOrigin.alt + baro.BaroAlt during an eligible GPS outage. Radios can therefore receive synthetic barometric altitude despite the setting being documented as raw GNSS MSL.
Agent Prompt
## Issue description
Ensure CRSF MSL telemetry uses a safely retained raw GNSS altitude rather than the processed GPS solution that fix estimation may overwrite.
## Issue Context
`gpsSolDRV` contains driver data but is explicitly unsafe to access asynchronously. Introduce or use a safe snapshot/accessor with clearly defined no-fix behavior rather than reading `gpsSolDRV` directly from telemetry code.
## Fix Focus Areas
- src/main/telemetry/crsf.c[242-251]
- src/main/io/gps.c[83-92]
- src/main/io/gps.c[264-327]
- src/main/io/gps.c[344-351]
- src/main/io/gps.h[124-160]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The intermediate integer-centimeter step rounded negative estimated altitudes differently than the previous float expression (by up to 1 m). Use the original expression verbatim for the ESTIMATED path so the default behaviour is unchanged, and drop raw from the MSL description since gpsSol may carry the estimated fix when GPS fix estimation is enabled.
|
Addressed the automated review findings in 9eb30e9:
|
Problem
The altitude field of the CRSF GPS frame (0x02) currently carries INAV's estimated altitude relative to the arming point (
getEstimatedActualPosition(Z)). The CRSF specification intends this field to carry the GPS altitude — Betaflight sendsgpsSol.llh.alt(MSL) here, and theGAltsensor on EdgeTX/OpenTX radios is generally understood as "GPS altitude, sea level is zero" (which is exactly how INAV's own docs describeGAltfor SmartPort telemetry indocs/Telemetry.md).As a result there is currently no way to see the aircraft's MSL altitude on the handset via CRSF, and the GPS frame duplicates information that is already sent in the barometer/vario frame (
Altsensor).Solution
A new setting, kept deliberately minimal in scope (only the GPS frame altitude field is touched):
ESTIMATED(default): estimated altitude above the arming point — identical to the previous behaviour, nothing changes for existing users.MSL: raw GNSS altitude above mean sea level (gpsSol.llh.alt).The relative altitude remains available on the handset via the barometer/vario frame (
Altsensor) regardless of this setting, so no information is lost when selectingMSL.This follows up on the discussion in #10934, where extending the CRSF telemetry to the TBS standard stalled — and where @MrD-RC asked for a CLI option to keep the legacy behaviour selectable. This PR implements only the altitude-source part of that, as an opt-in with the legacy behaviour as default.
Implementation notes
PG_TELEMETRY_CONFIGversion bumped 8 → 9 (struct member added).docs/Settings.mdentry added to match the generated format.MSLreports 0 m (rawgpsSol.llh.alt), consistent with the other raw GPS fields in this frame.Testing