mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 07:09:48 +08:00
multi diff pres sensor publication and logging
This commit is contained in:
committed by
Lorenz Meier
parent
8db2883d84
commit
b2a81ed35b
@@ -2,3 +2,4 @@ uint64 error_count # Number of errors detected by driver
|
||||
float32 differential_pressure_raw_pa # Raw differential pressure reading (may be negative)
|
||||
float32 differential_pressure_filtered_pa # Low pass filtered differential pressure reading
|
||||
float32 temperature # Temperature provided by sensor, -1000.0f if unknown
|
||||
uint32 device_id # unique device ID for the sensor that does not change between power cycles
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
* @author Simon Wilks <simon@px4.io>
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
*
|
||||
* Driver for the Eagle Tree Airspeed V3 connected via I2C.
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
@@ -86,6 +85,7 @@ Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const cha
|
||||
_collect_phase(false),
|
||||
_diff_pres_offset(0.0f),
|
||||
_airspeed_pub(nullptr),
|
||||
_airspeed_orb_class_instance(-1),
|
||||
_subsys_pub(nullptr),
|
||||
_class_instance(-1),
|
||||
_conversion_interval(conversion_interval),
|
||||
@@ -138,20 +138,17 @@ Airspeed::init()
|
||||
/* register alternate interfaces if we have to */
|
||||
_class_instance = register_class_devname(AIRSPEED_BASE_DEVICE_PATH);
|
||||
|
||||
/* publication init */
|
||||
if (_class_instance == CLASS_DEVICE_PRIMARY) {
|
||||
/* advertise sensor topic, measure manually to initialize valid report */
|
||||
measure();
|
||||
differential_pressure_s arp;
|
||||
_reports->get(&arp);
|
||||
|
||||
/* advertise sensor topic, measure manually to initialize valid report */
|
||||
struct differential_pressure_s arp;
|
||||
measure();
|
||||
_reports->get(&arp);
|
||||
/* measurement will have generated a report, publish */
|
||||
_airspeed_pub = orb_advertise_multi(ORB_ID(differential_pressure), &arp, &_airspeed_orb_class_instance,
|
||||
ORB_PRIO_HIGH - _class_instance);
|
||||
|
||||
/* measurement will have generated a report, publish */
|
||||
_airspeed_pub = orb_advertise(ORB_ID(differential_pressure), &arp);
|
||||
|
||||
if (_airspeed_pub == nullptr) {
|
||||
PX4_WARN("uORB started?");
|
||||
}
|
||||
if (_airspeed_pub == nullptr) {
|
||||
PX4_WARN("uORB started?");
|
||||
}
|
||||
|
||||
ret = OK;
|
||||
|
||||
@@ -134,6 +134,8 @@ protected:
|
||||
float _diff_pres_offset;
|
||||
|
||||
orb_advert_t _airspeed_pub;
|
||||
int _airspeed_orb_class_instance;
|
||||
|
||||
orb_advert_t _subsys_pub;
|
||||
|
||||
int _class_instance;
|
||||
|
||||
@@ -91,6 +91,13 @@
|
||||
#define DRV_MAG_DEVTYPE_BMM150 0x43
|
||||
#define DRV_BARO_DEVTYPE_BMP285 0x44
|
||||
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_ETS3 0x45
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_MS4525 0x46
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_MS5525 0x47
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP31 0x48
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP32 0x49
|
||||
#define DRV_DIFF_PRESS_DEVTYPE_SDP33 0x50
|
||||
|
||||
/*
|
||||
* ioctl() definitions
|
||||
*
|
||||
|
||||
@@ -116,7 +116,7 @@ extern "C" __EXPORT int ets_airspeed_main(int argc, char *argv[]);
|
||||
ETSAirspeed::ETSAirspeed(int bus, int address, const char *path) : Airspeed(bus, address,
|
||||
CONVERSION_INTERVAL, path)
|
||||
{
|
||||
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_MS4525;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -177,6 +177,7 @@ ETSAirspeed::collect()
|
||||
report.differential_pressure_filtered_pa = diff_pres_pa_raw;
|
||||
report.differential_pressure_raw_pa = diff_pres_pa_raw;
|
||||
report.temperature = -1000.0f;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
/* publish it */
|
||||
|
||||
@@ -139,6 +139,7 @@ MEASAirspeed::MEASAirspeed(int bus, int address, const char *path) : Airspeed(bu
|
||||
_t_system_power(-1),
|
||||
system_power{}
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_MS4525;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -247,6 +248,7 @@ MEASAirspeed::collect()
|
||||
report.temperature = temperature;
|
||||
report.differential_pressure_filtered_pa = _filter.apply(diff_press_pa_raw) - _diff_pres_offset;
|
||||
report.differential_pressure_raw_pa = diff_press_pa_raw - _diff_pres_offset;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
/* publish it */
|
||||
|
||||
@@ -118,6 +118,7 @@ MS5525::init_ms5525()
|
||||
C6 = prom[6];
|
||||
|
||||
Tref = int64_t(C5) * (1UL << Q5);
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_MS5525;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -255,6 +256,7 @@ MS5525::collect()
|
||||
.differential_pressure_raw_pa = diff_press_pa_raw - _diff_pres_offset,
|
||||
.differential_pressure_filtered_pa = _filter.apply(diff_press_pa_raw) - _diff_pres_offset,
|
||||
.temperature = temperature_c,
|
||||
.device_id = _device_id.devid
|
||||
};
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
|
||||
@@ -102,6 +102,20 @@ SDP3X::init_sdp3x()
|
||||
|
||||
_scale = (((uint16_t)val[6]) << 8) | val[7];
|
||||
|
||||
switch (_scale) {
|
||||
case SDP3X_SCALE_PRESSURE_SDP31:
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_SDP31;
|
||||
break;
|
||||
|
||||
case SDP3X_SCALE_PRESSURE_SDP32:
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_SDP32;
|
||||
break;
|
||||
|
||||
case SDP3X_SCALE_PRESSURE_SDP33:
|
||||
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_SDP33;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -141,6 +155,7 @@ SDP3X::collect()
|
||||
report.temperature = temperature_c;
|
||||
report.differential_pressure_filtered_pa = _filter.apply(diff_press_pa_raw) - _diff_pres_offset;
|
||||
report.differential_pressure_raw_pa = diff_press_pa_raw - _diff_pres_offset;
|
||||
report.device_id = _device_id.devid;
|
||||
|
||||
if (_airspeed_pub != nullptr && !(_pub_blocked)) {
|
||||
orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &report);
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
#define SDP3X_RESET_CMD 0x06
|
||||
#define SDP3X_CONT_MEAS_AVG_MODE 0x3615
|
||||
|
||||
#define SDP3X_SCALE_PRESSURE_SDP31 20
|
||||
#define SDP3X_SCALE_PRESSURE_SDP32 5
|
||||
#define SDP3X_SCALE_PRESSURE_SDP33 60
|
||||
|
||||
#define PATH_SDP3X "/dev/sdp3x"
|
||||
|
||||
// Measurement rate is 20Hz
|
||||
|
||||
Reference in New Issue
Block a user