2016-01-19 21:26:31 -04:00
|
|
|
#pragma once
|
2015-11-16 00:09:37 -04:00
|
|
|
|
2016-01-19 21:26:31 -04:00
|
|
|
#include <SITL/SITL.h>
|
2015-11-16 00:09:37 -04:00
|
|
|
|
2019-11-10 07:18:48 -04:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
2015-11-16 00:09:37 -04:00
|
|
|
#include "AP_InertialSensor.h"
|
2016-01-19 21:26:31 -04:00
|
|
|
#include "AP_InertialSensor_Backend.h"
|
2015-11-16 00:09:37 -04:00
|
|
|
|
2020-01-03 15:52:33 -04:00
|
|
|
// simulated sensor rates in Hz. This matches a pixhawk1
|
|
|
|
const uint16_t INS_SITL_SENSOR_A[] = { 1000, 1000 };
|
|
|
|
const uint16_t INS_SITL_SENSOR_B[] = { 760, 800 };
|
2015-11-16 00:09:37 -04:00
|
|
|
|
|
|
|
class AP_InertialSensor_SITL : public AP_InertialSensor_Backend
|
|
|
|
{
|
|
|
|
public:
|
2020-01-03 15:52:33 -04:00
|
|
|
AP_InertialSensor_SITL(AP_InertialSensor &imu, const uint16_t sample_rates[]);
|
2015-11-16 00:09:37 -04:00
|
|
|
|
|
|
|
/* update accel and gyro state */
|
2018-11-07 07:26:38 -04:00
|
|
|
bool update() override;
|
2020-01-03 15:52:33 -04:00
|
|
|
void start() override;
|
2015-11-16 00:09:37 -04:00
|
|
|
|
|
|
|
// detect the sensor
|
2020-01-03 15:52:33 -04:00
|
|
|
static AP_InertialSensor_Backend *detect(AP_InertialSensor &imu, const uint16_t sample_rates[]);
|
2015-11-16 00:09:37 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool init_sensor(void);
|
|
|
|
void timer_update();
|
|
|
|
float gyro_drift(void);
|
2020-01-03 15:52:33 -04:00
|
|
|
void generate_accel();
|
|
|
|
void generate_gyro();
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2015-11-16 00:09:37 -04:00
|
|
|
SITL::SITL *sitl;
|
|
|
|
|
2020-01-03 15:52:33 -04:00
|
|
|
const uint16_t gyro_sample_hz;
|
|
|
|
const uint16_t accel_sample_hz;
|
2017-04-30 21:51:15 -03:00
|
|
|
|
2020-01-03 15:52:33 -04:00
|
|
|
uint8_t gyro_instance;
|
|
|
|
uint8_t accel_instance;
|
|
|
|
uint64_t next_gyro_sample;
|
|
|
|
uint64_t next_accel_sample;
|
|
|
|
float gyro_time;
|
|
|
|
float accel_time;
|
|
|
|
float gyro_motor_phase[12];
|
|
|
|
float accel_motor_phase[12];
|
|
|
|
|
|
|
|
static uint8_t bus_id;
|
2015-11-16 00:09:37 -04:00
|
|
|
};
|
2019-11-10 07:18:48 -04:00
|
|
|
#endif // CONFIG_HAL_BOARD
|