mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 14:03:33 +08:00
Drivers: Distance Sensors: Add proper device IDs
Add new DeviceBusType_SERIAL to Device::DeviceId union Add DRV_DIST_DEVTYPE's for all distance sensors Change distance_sensor_s.id to distance_sensor_s.device_id Modify all distance_sensor drivers to apply 'proper' device_id
This commit is contained in:
committed by
Daniel Agar
parent
adf2d2f73a
commit
85796fbd84
@@ -147,6 +147,7 @@ public:
|
||||
DeviceBusType_SPI = 2,
|
||||
DeviceBusType_UAVCAN = 3,
|
||||
DeviceBusType_SIMULATION = 4,
|
||||
DeviceBusType_SERIAL = 5,
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -41,6 +41,7 @@ PX4Rangefinder::PX4Rangefinder(const uint32_t device_id, const uint8_t device_or
|
||||
|
||||
set_device_id(device_id);
|
||||
set_orientation(device_orientation);
|
||||
set_rangefinder_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER); // Default to type LASER
|
||||
}
|
||||
|
||||
PX4Rangefinder::~PX4Rangefinder()
|
||||
@@ -50,17 +51,15 @@ PX4Rangefinder::~PX4Rangefinder()
|
||||
|
||||
void PX4Rangefinder::set_device_type(uint8_t device_type)
|
||||
{
|
||||
// TODO: range finders should have device ids
|
||||
// current DeviceStructure
|
||||
union device::Device::DeviceId device_id;
|
||||
device_id.devid = _distance_sensor_pub.get().device_id;
|
||||
|
||||
// // current DeviceStructure
|
||||
// union device::Device::DeviceId device_id;
|
||||
// device_id.devid = _distance_sensor_pub.get().device_id;
|
||||
// update to new device type
|
||||
device_id.devid_s.devtype = device_type;
|
||||
|
||||
// // update to new device type
|
||||
// device_id.devid_s.devtype = devtype;
|
||||
|
||||
// // copy back to report
|
||||
// _distance_sensor_pub.get().device_id = device_id.devid;
|
||||
// copy back to report
|
||||
_distance_sensor_pub.get().device_id = device_id.devid;
|
||||
}
|
||||
|
||||
void PX4Rangefinder::set_orientation(const uint8_t device_orientation)
|
||||
|
||||
@@ -45,10 +45,11 @@ public:
|
||||
const uint8_t device_orientation = distance_sensor_s::ROTATION_DOWNWARD_FACING);
|
||||
~PX4Rangefinder();
|
||||
|
||||
void set_device_type(uint8_t device_type);
|
||||
//void set_error_count(uint64_t error_count) { _distance_sensor_pub.get().error_count = error_count; }
|
||||
// Set the MAV_DISTANCE_SENSOR type (LASER, ULTRASOUND, INFRARED, RADAR)
|
||||
void set_rangefinder_type(uint8_t rangefinder_type) { _distance_sensor_pub.get().type = rangefinder_type; };
|
||||
|
||||
void set_device_id(const uint8_t device_id) { _distance_sensor_pub.get().id = device_id; };
|
||||
void set_device_id(const uint8_t device_id) { _distance_sensor_pub.get().device_id = device_id; };
|
||||
void set_device_type(const uint8_t device_type);
|
||||
|
||||
void set_fov(const float fov) { set_hfov(fov); set_vfov(fov); }
|
||||
void set_hfov(const float fov) { _distance_sensor_pub.get().h_fov = fov; }
|
||||
|
||||
Reference in New Issue
Block a user