fix(uavcan): publish non-valid range readings with quality 0 (#27963)

The rangefinder bridge published TOO_CLOSE, TOO_FAR and UNDEFINED
readings with signal_quality -1 (unknown) and the raw wire range, so
consumers treated them as usable measurements. DroneCAN rangefinder
nodes commonly report an out-of-range sentinel value in the range field
for these reading types (e.g. max_distance + 1 for TOO_FAR); flight
logs show the EKF fusing a node's 101 m TOO_FAR sentinel as terrain
distance at 45-113 m AGL.

Per the distance_sensor uORB convention (0 = invalid signal), mark all
non-VALID_RANGE readings as quality 0 so downstream consumers reject
them.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
Jacob Dahl
2026-07-19 10:14:50 -06:00
committed by GitHub
parent 6120aa53df
commit d11b996d89

View File

@@ -110,7 +110,10 @@ void UavcanRangefinderBridge::range_sub_cb(const
_inited = true;
}
int8_t quality = -1;
// TOO_CLOSE, TOO_FAR and UNDEFINED readings do not carry a usable range
// value: publish them as invalid (0) rather than unknown (-1), which
// consumers like the EKF would otherwise accept and fuse.
int8_t quality = 0;
if (msg.reading_type == uavcan::equipment::range_sensor::Measurement::READING_TYPE_VALID_RANGE) {
quality = 100;