UavcanNode: Add sensor_type to range_sensor pub.

This commit is contained in:
JacobCrabill 2020-05-14 13:55:09 -07:00 committed by Nuno Marques
parent 76de299302
commit 328477f0be
1 changed files with 20 additions and 1 deletions

View File

@ -389,7 +389,26 @@ void UavcanNode::Run()
range_sensor.sensor_id = i;
range_sensor.range = dist.current_distance;
range_sensor.field_of_view = dist.h_fov;
// sensor type
switch (dist.type) {
case distance_sensor_s::MAV_DISTANCE_SENSOR_LASER:
range_sensor.sensor_type = uavcan::equipment::range_sensor::Measurement::SENSOR_TYPE_LIDAR;
break;
case distance_sensor_s::MAV_DISTANCE_SENSOR_ULTRASOUND:
range_sensor.sensor_type = uavcan::equipment::range_sensor::Measurement::SENSOR_TYPE_SONAR;
break;
case distance_sensor_s::MAV_DISTANCE_SENSOR_RADAR:
range_sensor.sensor_type = uavcan::equipment::range_sensor::Measurement::SENSOR_TYPE_RADAR;
break;
case distance_sensor_s::MAV_DISTANCE_SENSOR_INFRARED:
default:
range_sensor.sensor_type = uavcan::equipment::range_sensor::Measurement::SENSOR_TYPE_UNDEFINED;
break;
}
// reading_type
if (dist.current_distance >= dist.max_distance) {