AP_Baro: added averaging to PX4 baro driver

This commit is contained in:
Andrew Tridgell 2013-01-04 21:08:20 +11:00
parent 38f56be2c4
commit 4fe7ad6267
2 changed files with 14 additions and 8 deletions

View File

@ -20,16 +20,19 @@ extern const AP_HAL::HAL& hal;
// Public Methods //////////////////////////////////////////////////////////////
bool AP_Baro_PX4::init(void)
{
_baro_fd = open(BARO_DEVICE_PATH, O_RDONLY);
if (_baro_fd < 0) {
hal.scheduler->panic("Unable to open " BARO_DEVICE_PATH);
}
if (_baro_fd == -1) {
_baro_fd = open(BARO_DEVICE_PATH, O_RDONLY);
if (_baro_fd < 0) {
hal.scheduler->panic("Unable to open " BARO_DEVICE_PATH);
}
/* set the driver to poll at 150Hz */
ioctl(_baro_fd, SENSORIOCSPOLLRATE, 150);
/* set the driver to poll at 150Hz */
ioctl(_baro_fd, SENSORIOCSPOLLRATE, 150);
// average over up to 10 samples
ioctl(_baro_fd, SENSORIOCSQUEUEDEPTH, 10);
// average over up to 10 samples
ioctl(_baro_fd, SENSORIOCSQUEUEDEPTH, 10);
hal.console->printf("AP_Baro_PX4: init done fd=%d\n", _baro_fd);
}
return true;
}

View File

@ -8,6 +8,9 @@
class AP_Baro_PX4 : public AP_Baro
{
public:
AP_Baro_PX4() : AP_Baro() {
_baro_fd = -1;
}
bool init();
uint8_t read();
float get_pressure();