Files
PX4-Autopilot/msg/SensorsStatusGnss.msg
Jacob DahlandAndrea Bernasconi d04e5623f6 feat(gnss): compare receivers in sensors, limit divergence in commander (#29604)
* feat(sensors/gnss): report how far each receiver is from the selected one

Commander compared the receivers itself, reading the sensors module's antenna offsets and comparing samples taken at different times. The sensors module has the receiver-to-slot matching and the corrected sample times, so it now publishes each receiver's disagreement with the selected one on sensors_status_gnss, horizontally and vertically.

The other receiver is moved along its velocity to the selected sample's time. The antenna baseline is rotated with the attitude, so swapped or misplaced antennas show once the primary estimator's heading is aligned. Before that only the distances are compared, since the yaw is arbitrary.

Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Assisted-by: Claude:claude-opus-5-5

* feat(commander): limit the GNSS divergence with COM_GNSS_H_MAX and COM_GNSS_V_MAX

The divergence gate came from the receivers' reported accuracy floored with EKF2_GPS_P_NOISE, so it was hard to predict and read another module's parameter. Commander now takes the disagreement from sensors_status_gnss and applies fixed horizontal and vertical limits. Three times the receivers' combined reported accuracy still widens them, so standalone receivers don't warn on default parameters.

Before arming a divergence is reported at once and clears after 2 s of agreement. In flight it has to persist for 2 s.

Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Assisted-by: Claude:claude-opus-5-5

* fix(commander): keep the GNSS divergence limits fixed

Widening the limits to three times the receivers' combined reported accuracy made them floors, not limits. With the default GNSS_REQ_EPH and GNSS_REQ_EPV the gate opened to 12.7 m horizontally and 21 m vertically before arming, and to about 210 m in flight once a receiver fell back to the relaxed checks. The limits now apply as set, with defaults of 5 m and 10 m so standalone receivers don't warn.

Assisted-by: Claude:claude-opus-5-5

* fix(commander): don't take an unknown GNSS disagreement for agreement

The sensors module leaves the disagreement unknown when the two latest samples are more than 0.5 s apart, while both receivers stay healthy. Commander treated that as nothing to compare, so a divergence before arming cleared for that check and an arm request could pass, and in flight the 2 s timer restarted. It happens on any gap over 0.5 s from a healthy receiver, and on 2 Hz receivers whose latencies differ. An unknown disagreement now keeps the state and its timer. A divergence still clears at once when there is no healthy pair to compare.

Assisted-by: Claude:claude-opus-5-5

* docs(commander): swapped GNSS antennas hide behind a moving-base heading

The moving-base heading takes its offset from the same antenna positions. With swapped antennas the heading turns by 180°, and the expected baseline turns with it, so the divergence check sees agreement.

Assisted-by: Claude:claude-opus-5-5

* docs(commander): reword the moving-base heading caveat

The sentence didn't say plainly that a moving-base heading from the same receivers stops the check from detecting swapped antennas.

Assisted-by: Claude:claude-opus-5-5

* docs(commander): fold the moving-base caveat into the swapped-antenna conditions

The caveat read as a repeat of the alignment sentence. It is one more condition for detecting swapped antennas, so it now sits with the others.

Assisted-by: Claude:claude-opus-5-5

* refactor(gnss): rotate the antenna baseline with the attitude as it is

The heading gate kept a limit below twice the antenna baseline from reporting a divergence before the heading aligned. With a mag the heading aligns before the receivers turn healthy. A heading from the same two receivers can't reveal swapped antennas anyway. The gate also never opened with an external INS, since only EKF2 publishes estimator_status_flags. Dropping it saves 168 B of flash on fmu-v2. The attitude age limit goes with it, since the last published attitude is a better guess than level and facing north.

Assisted-by: Claude:claude-opus-5-5

---------

Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
2026-11-19 11:28:20 -07:00

26 lines
2.2 KiB
Plaintext

# Per-receiver GNSS health and check diagnostics
#
# Published by the sensors module. Describes the latest sample of each receiver: to gate on a sample, use vehicle_gnss.usable.
uint64 timestamp # [us] Time since system start
uint32 device_id_selected # [-] Receiver that vehicle_gnss carries
uint8 MAX_RECEIVERS = 4 # Length of the per-receiver arrays
uint32[4] device_ids # [-] One entry per receiver, 0 where unused
int8[4] order # [-] Fixed position of the receiver: 0 for the preferred one, otherwise for the first to publish, then in order of first publication. Changes only with the preference, -1 until the receiver publishes
bool[4] healthy # Usable within the last 2 s: passed its checks for long enough and published without gaps. The selection fails over from a receiver that isn't
float32[4] availability # [-] Fraction of recent time the receiver passed its checks and published without gaps, 0 to 1
float32[4] inconsistency_horizontal # [m] [@invalid NaN] Horizontal distance from where the selected receiver and the antenna positions put the receiver, at the time of the selected sample. 0 for the selected receiver
float32[4] inconsistency_vertical # [m] [@invalid NaN] Vertical distance from where the selected receiver and the antenna positions put the receiver, at the time of the selected sample. 0 for the selected receiver
uint16[4] failed_strict_checks # [-] Enabled checks the latest sample fails at the strict thresholds, VehicleGnss CHECK_* bits
uint16[4] failed_relaxed_checks # [-] Enabled checks the latest sample fails at the relaxed thresholds, VehicleGnss CHECK_* bits
bool[4] strict # The strict checks decide whether its samples are usable, as VehicleGnss strict
float32[4] drift_rate_horizontal # [m/s] Horizontal position drift rate at rest
float32[4] drift_rate_vertical # [m/s] Vertical position drift rate at rest
float32[4] speed_horizontal_filtered # [m/s] Filtered horizontal speed at rest
float32[4] kinematic_inconsistency_horizontal # [m/s] Rate of change of the horizontal position minus the horizontal velocity, filtered, checked against GNSS_REQ_HKIN
# TOPICS sensors_status_gnss