uavcan: Add device IDs to baro, flow publishers

Can now see proper UAVCAN bus and unique device ID for barometer
instances; optical flow will also have the UAVCAN node ID assigned as
sensor ID.
This commit is contained in:
JacobCrabill
2020-02-28 11:08:04 -08:00
committed by Daniel Agar
parent 71e4a36ba4
commit 79dc313260
2 changed files with 7 additions and 2 deletions
+4 -2
View File
@@ -85,6 +85,9 @@ UavcanBarometerBridge::air_pressure_sub_cb(const
{
sensor_baro_s report{};
// Set the devid address to the UAVCAN node ID (so we get a unique address)
_device_id.devid_s.address = (uint8_t)(msg.getSrcNodeID().get() & 0xFF);
/*
* FIXME HACK
* This code used to rely on msg.getMonotonicTimestamp().toUSec() instead of HRT.
@@ -97,8 +100,7 @@ UavcanBarometerBridge::air_pressure_sub_cb(const
report.pressure = msg.static_pressure / 100.0F; // Convert to millibar
report.error_count = 0;
/* TODO get device ID for sensor */
report.device_id = 0;
report.device_id = _device_id.devid;
publish(msg.getSrcNodeID().get(), &report);
}
+3
View File
@@ -67,6 +67,9 @@ UavcanFlowBridge::flow_sub_cb(const uavcan::ReceivedDataStructure<com::hex::equi
{
optical_flow_s flow{};
// We're only given an 8 bit field for sensor ID; just use the UAVCAN node ID
flow.sensor_id = (uint8_t)(msg.getSrcNodeID().get() & 0xFF);
flow.timestamp = hrt_absolute_time();
flow.integration_timespan = 1.e6f * msg.integration_interval; // s -> micros
flow.pixel_flow_x_integral = msg.flow_integral[0];