uavcan: handle uavcan sensors on multiple buses properly #22880
+82
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved Problem
BUG: When using multiple DroneCAN GNSS sensors, they all get the same device id, as the id is stored in a variable shared by all
sensor_gps
channels.MISSING FEATURE: The previous code always sets the
bus_idx
ofdevice_id
for DroneCAN devices to 0, not taking into account on which CAN bus the device actually is.Solution
Extend
sensor_bridge
channels to also consider the CAN bus index and not only the node ID. This involves changing functions for publishing and getting channels.For GPS, use the node id and bus index from the actual DroneCAN messages, and not a single variable for all GPSes.
Also, make
UavcanSensorBridgeBase
not inherit fromdevice::Device
. We want to remove this, because each sensor bridge represents multiple devices.Because of this, I also has to update all uavcan sensor types, but it is just minor changes. Don't be scared by number of files changed!
Changelog Entry
For release notes:
Alternatives
This considers two DroneCAN nodes with the same node ID but on different buses as different devices. I think this is the best approach. It could also be possible to consider these cases the same device.
Test coverage
Ground tested on a CubeOrange with two Here4 GPS units.
Context
See that GPSes got the same device id earlier, but now they get different IDs
Before:

After:

uavcan_status:
