mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 16:48:52 +08:00
drivers helper classes remove empty publication (forced advertise)
- this is no longer necessary with all publications outside of ISRs
This commit is contained in:
@@ -50,10 +50,6 @@ PX4Accelerometer::PX4Accelerometer(uint32_t device_id, uint8_t priority, enum Ro
|
||||
// set software low pass filter for controllers
|
||||
updateParams();
|
||||
configure_filter(_param_imu_accel_cutoff.get());
|
||||
|
||||
// force initial publish to allocate uORB buffer
|
||||
// TODO: can be removed once all drivers are in threads
|
||||
_sensor_accel_pub.update();
|
||||
}
|
||||
|
||||
PX4Accelerometer::~PX4Accelerometer()
|
||||
@@ -63,7 +59,8 @@ PX4Accelerometer::~PX4Accelerometer()
|
||||
}
|
||||
}
|
||||
|
||||
int PX4Accelerometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
int
|
||||
PX4Accelerometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case ACCELIOCSSCALE: {
|
||||
@@ -85,7 +82,8 @@ int PX4Accelerometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Accelerometer::set_device_type(uint8_t devtype)
|
||||
void
|
||||
PX4Accelerometer::set_device_type(uint8_t devtype)
|
||||
{
|
||||
// current DeviceStructure
|
||||
union device::Device::DeviceId device_id;
|
||||
@@ -98,13 +96,15 @@ void PX4Accelerometer::set_device_type(uint8_t devtype)
|
||||
_sensor_accel_pub.get().device_id = device_id.devid;
|
||||
}
|
||||
|
||||
void PX4Accelerometer::set_sample_rate(unsigned rate)
|
||||
void
|
||||
PX4Accelerometer::set_sample_rate(unsigned rate)
|
||||
{
|
||||
_sample_rate = rate;
|
||||
_filter.set_cutoff_frequency(_sample_rate, _filter.get_cutoff_freq());
|
||||
}
|
||||
|
||||
void PX4Accelerometer::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
void
|
||||
PX4Accelerometer::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
{
|
||||
sensor_accel_s &report = _sensor_accel_pub.get();
|
||||
report.timestamp = timestamp;
|
||||
@@ -145,7 +145,8 @@ void PX4Accelerometer::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Accelerometer::print_status()
|
||||
void
|
||||
PX4Accelerometer::print_status()
|
||||
{
|
||||
PX4_INFO(ACCEL_BASE_DEVICE_PATH " device instance: %d", _class_device_instance);
|
||||
PX4_INFO("sample rate: %d Hz", _sample_rate);
|
||||
|
||||
@@ -43,10 +43,6 @@ PX4Barometer::PX4Barometer(uint32_t device_id, uint8_t priority) :
|
||||
_class_device_instance = register_class_devname(BARO_BASE_DEVICE_PATH);
|
||||
|
||||
_sensor_baro_pub.get().device_id = device_id;
|
||||
|
||||
// force initial publish to allocate uORB buffer
|
||||
// TODO: can be removed once all drivers are in threads
|
||||
_sensor_baro_pub.update();
|
||||
}
|
||||
|
||||
PX4Barometer::~PX4Barometer()
|
||||
@@ -56,7 +52,8 @@ PX4Barometer::~PX4Barometer()
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Barometer::set_device_type(uint8_t devtype)
|
||||
void
|
||||
PX4Barometer::set_device_type(uint8_t devtype)
|
||||
{
|
||||
// current DeviceStructure
|
||||
union device::Device::DeviceId device_id;
|
||||
@@ -69,7 +66,8 @@ void PX4Barometer::set_device_type(uint8_t devtype)
|
||||
_sensor_baro_pub.get().device_id = device_id.devid;
|
||||
}
|
||||
|
||||
void PX4Barometer::update(hrt_abstime timestamp, float pressure)
|
||||
void
|
||||
PX4Barometer::update(hrt_abstime timestamp, float pressure)
|
||||
{
|
||||
sensor_baro_s &report = _sensor_baro_pub.get();
|
||||
|
||||
@@ -81,7 +79,8 @@ void PX4Barometer::update(hrt_abstime timestamp, float pressure)
|
||||
_sensor_baro_pub.update();
|
||||
}
|
||||
|
||||
void PX4Barometer::print_status()
|
||||
void
|
||||
PX4Barometer::print_status()
|
||||
{
|
||||
PX4_INFO(BARO_BASE_DEVICE_PATH " device instance: %d", _class_device_instance);
|
||||
|
||||
|
||||
@@ -50,10 +50,6 @@ PX4Gyroscope::PX4Gyroscope(uint32_t device_id, uint8_t priority, enum Rotation r
|
||||
// set software low pass filter for controllers
|
||||
updateParams();
|
||||
configure_filter(_param_imu_gyro_cutoff.get());
|
||||
|
||||
// force initial publish to allocate uORB buffer
|
||||
// TODO: can be removed once all drivers are in threads
|
||||
_sensor_gyro_pub.update();
|
||||
}
|
||||
|
||||
PX4Gyroscope::~PX4Gyroscope()
|
||||
@@ -63,7 +59,8 @@ PX4Gyroscope::~PX4Gyroscope()
|
||||
}
|
||||
}
|
||||
|
||||
int PX4Gyroscope::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
int
|
||||
PX4Gyroscope::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case GYROIOCSSCALE: {
|
||||
@@ -85,7 +82,8 @@ int PX4Gyroscope::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Gyroscope::set_device_type(uint8_t devtype)
|
||||
void
|
||||
PX4Gyroscope::set_device_type(uint8_t devtype)
|
||||
{
|
||||
// current DeviceStructure
|
||||
union device::Device::DeviceId device_id;
|
||||
@@ -98,13 +96,15 @@ void PX4Gyroscope::set_device_type(uint8_t devtype)
|
||||
_sensor_gyro_pub.get().device_id = device_id.devid;
|
||||
}
|
||||
|
||||
void PX4Gyroscope::set_sample_rate(unsigned rate)
|
||||
void
|
||||
PX4Gyroscope::set_sample_rate(unsigned rate)
|
||||
{
|
||||
_sample_rate = rate;
|
||||
_filter.set_cutoff_frequency(_sample_rate, _filter.get_cutoff_freq());
|
||||
}
|
||||
|
||||
void PX4Gyroscope::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
void
|
||||
PX4Gyroscope::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
{
|
||||
sensor_gyro_s &report = _sensor_gyro_pub.get();
|
||||
report.timestamp = timestamp;
|
||||
@@ -145,7 +145,8 @@ void PX4Gyroscope::update(hrt_abstime timestamp, float x, float y, float z)
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Gyroscope::print_status()
|
||||
void
|
||||
PX4Gyroscope::print_status()
|
||||
{
|
||||
PX4_INFO(GYRO_BASE_DEVICE_PATH " device instance: %d", _class_device_instance);
|
||||
PX4_INFO("sample rate: %d Hz", _sample_rate);
|
||||
|
||||
@@ -45,10 +45,6 @@ PX4Magnetometer::PX4Magnetometer(uint32_t device_id, uint8_t priority, enum Rota
|
||||
|
||||
_sensor_mag_pub.get().device_id = device_id;
|
||||
_sensor_mag_pub.get().scaling = 1.0f;
|
||||
|
||||
// force initial publish to allocate uORB buffer
|
||||
// TODO: can be removed once all drivers are in threads
|
||||
_sensor_mag_pub.update();
|
||||
}
|
||||
|
||||
PX4Magnetometer::~PX4Magnetometer()
|
||||
@@ -58,7 +54,8 @@ PX4Magnetometer::~PX4Magnetometer()
|
||||
}
|
||||
}
|
||||
|
||||
int PX4Magnetometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
int
|
||||
PX4Magnetometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case MAGIOCSSCALE: {
|
||||
@@ -94,7 +91,8 @@ int PX4Magnetometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
|
||||
}
|
||||
}
|
||||
|
||||
void PX4Magnetometer::set_device_type(uint8_t devtype)
|
||||
void
|
||||
PX4Magnetometer::set_device_type(uint8_t devtype)
|
||||
{
|
||||
// current DeviceStructure
|
||||
union device::Device::DeviceId device_id;
|
||||
@@ -107,7 +105,8 @@ void PX4Magnetometer::set_device_type(uint8_t devtype)
|
||||
_sensor_mag_pub.get().device_id = device_id.devid;
|
||||
}
|
||||
|
||||
void PX4Magnetometer::update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
|
||||
void
|
||||
PX4Magnetometer::update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
|
||||
{
|
||||
sensor_mag_s &report = _sensor_mag_pub.get();
|
||||
report.timestamp = timestamp;
|
||||
@@ -136,7 +135,8 @@ void PX4Magnetometer::update(hrt_abstime timestamp, int16_t x, int16_t y, int16_
|
||||
_sensor_mag_pub.update();
|
||||
}
|
||||
|
||||
void PX4Magnetometer::print_status()
|
||||
void
|
||||
PX4Magnetometer::print_status()
|
||||
{
|
||||
PX4_INFO(MAG_BASE_DEVICE_PATH " device instance: %d", _class_device_instance);
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
PX4Rangefinder::PX4Rangefinder(uint32_t device_id, uint8_t priority, uint8_t rotation) :
|
||||
CDev(nullptr),
|
||||
_distance_sensor_pub{ORB_ID(distance_sensor), priority},
|
||||
_rotation{rotation}
|
||||
_distance_sensor_pub{ORB_ID(distance_sensor), priority}
|
||||
{
|
||||
_class_device_instance = register_class_devname(RANGE_FINDER_BASE_DEVICE_PATH);
|
||||
|
||||
|
||||
@@ -66,8 +66,6 @@ private:
|
||||
|
||||
uORB::PublicationData<distance_sensor_s> _distance_sensor_pub;
|
||||
|
||||
const uint8_t _rotation;
|
||||
|
||||
int _class_device_instance{-1};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user