2020-09-05 04:06:22 -03:00
|
|
|
|
2016-01-19 00:27:29 -04:00
|
|
|
#pragma once
|
2013-10-07 21:07:59 -03:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2014-07-06 23:03:57 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
2013-10-07 21:07:59 -03:00
|
|
|
|
2016-01-19 01:07:09 -04:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <Filter/Filter.h>
|
|
|
|
#include <Filter/LowPassFilter2p.h>
|
2013-10-07 21:07:59 -03:00
|
|
|
|
2016-01-19 00:27:29 -04:00
|
|
|
#include "AP_InertialSensor.h"
|
2016-01-19 21:26:31 -04:00
|
|
|
#include "AP_InertialSensor_Backend.h"
|
2016-01-19 00:27:29 -04:00
|
|
|
|
2014-10-15 20:55:18 -03:00
|
|
|
class AP_InertialSensor_L3G4200D : public AP_InertialSensor_Backend
|
2013-10-07 21:07:59 -03:00
|
|
|
{
|
|
|
|
public:
|
2016-01-19 01:07:09 -04:00
|
|
|
AP_InertialSensor_L3G4200D(AP_InertialSensor &imu,
|
2020-09-05 04:06:22 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev_gyro,
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev_accel);
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-19 01:07:09 -04:00
|
|
|
virtual ~AP_InertialSensor_L3G4200D();
|
|
|
|
|
|
|
|
// probe the sensor on I2C bus
|
|
|
|
static AP_InertialSensor_Backend *probe(AP_InertialSensor &imu,
|
2020-09-05 04:06:22 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev_gyro,
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev_accel);
|
2013-10-07 21:07:59 -03:00
|
|
|
|
2020-09-05 04:06:22 -03:00
|
|
|
|
|
|
|
|
2014-10-15 20:55:18 -03:00
|
|
|
/* update accel and gyro state */
|
2016-11-03 21:06:19 -03:00
|
|
|
bool update() override;
|
2014-10-15 20:55:18 -03:00
|
|
|
|
2016-11-03 21:06:19 -03:00
|
|
|
void start(void) override;
|
2014-10-15 23:14:56 -03:00
|
|
|
|
2020-09-05 04:06:22 -03:00
|
|
|
|
2013-10-07 21:07:59 -03:00
|
|
|
private:
|
2020-09-05 04:06:22 -03:00
|
|
|
bool _accel_init();
|
|
|
|
bool _gyro_init();
|
2016-01-19 00:29:56 -04:00
|
|
|
bool _init_sensor();
|
2020-09-05 04:06:22 -03:00
|
|
|
void _accumulate_gyro();
|
|
|
|
void _accumulate_accel();
|
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev_gyro;
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev_accel;
|
|
|
|
|
|
|
|
void _set_filter_frequency(uint8_t filter_hz);
|
|
|
|
|
|
|
|
// Low Pass filters for gyro and accel
|
|
|
|
LowPassFilter2pVector3f _accel_filter;
|
|
|
|
LowPassFilter2pVector3f _gyro_filter;
|
2015-03-19 18:55:25 -03:00
|
|
|
|
2020-09-05 04:06:22 -03:00
|
|
|
enum Rotation _rotation;
|
2013-10-07 21:07:59 -03:00
|
|
|
};
|
2020-09-05 04:06:22 -03:00
|
|
|
#endif // __AP_INERTIAL_SENSOR_L3G4200D2_H__
|