fix(uavcan/rangefinder): rangefinder does track init-variables now for all instances

This commit is contained in:
Marin Doetterer
2026-07-22 15:07:29 +02:00
committed by Marin D
parent 8424463102
commit ec5b9518ea
2 changed files with 5 additions and 3 deletions

View File

@@ -82,7 +82,9 @@ void UavcanRangefinderBridge::range_sub_cb(const
return;
}
if (!_inited) {
const int8_t channel_idx = get_channel_index_for_node(msg.getSrcNodeID().get());
if (channel_idx >= 0 && !_channel_initialized[channel_idx]) {
uint8_t rangefinder_type = 0;
@@ -107,7 +109,7 @@ void UavcanRangefinderBridge::range_sub_cb(const
rangefinder->set_min_distance(_range_min_m);
rangefinder->set_max_distance(_range_max_m);
_inited = true;
_channel_initialized[channel_idx] = true;
}
// TOO_CLOSE, TOO_FAR and UNDEFINED readings do not carry a usable range

View File

@@ -70,6 +70,6 @@ private:
float _range_min_m{0.0f};
float _range_max_m{0.0f};
bool _inited{false};
bool _channel_initialized[DEFAULT_MAX_CHANNELS] {};
};