AP_Baro: added averaging to PX4 baro driver
This commit is contained in:
parent
38f56be2c4
commit
4fe7ad6267
@ -20,16 +20,19 @@ extern const AP_HAL::HAL& hal;
|
|||||||
// Public Methods //////////////////////////////////////////////////////////////
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
bool AP_Baro_PX4::init(void)
|
bool AP_Baro_PX4::init(void)
|
||||||
{
|
{
|
||||||
_baro_fd = open(BARO_DEVICE_PATH, O_RDONLY);
|
if (_baro_fd == -1) {
|
||||||
if (_baro_fd < 0) {
|
_baro_fd = open(BARO_DEVICE_PATH, O_RDONLY);
|
||||||
hal.scheduler->panic("Unable to open " BARO_DEVICE_PATH);
|
if (_baro_fd < 0) {
|
||||||
}
|
hal.scheduler->panic("Unable to open " BARO_DEVICE_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
/* set the driver to poll at 150Hz */
|
/* set the driver to poll at 150Hz */
|
||||||
ioctl(_baro_fd, SENSORIOCSPOLLRATE, 150);
|
ioctl(_baro_fd, SENSORIOCSPOLLRATE, 150);
|
||||||
|
|
||||||
// average over up to 10 samples
|
// average over up to 10 samples
|
||||||
ioctl(_baro_fd, SENSORIOCSQUEUEDEPTH, 10);
|
ioctl(_baro_fd, SENSORIOCSQUEUEDEPTH, 10);
|
||||||
|
hal.console->printf("AP_Baro_PX4: init done fd=%d\n", _baro_fd);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
class AP_Baro_PX4 : public AP_Baro
|
class AP_Baro_PX4 : public AP_Baro
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
AP_Baro_PX4() : AP_Baro() {
|
||||||
|
_baro_fd = -1;
|
||||||
|
}
|
||||||
bool init();
|
bool init();
|
||||||
uint8_t read();
|
uint8_t read();
|
||||||
float get_pressure();
|
float get_pressure();
|
||||||
|
Loading…
Reference in New Issue
Block a user