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
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
#define INS_SITL_INSTANCES 2
|
|
|
|
|
|
|
|
class AP_InertialSensor_SITL : public AP_InertialSensor_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_InertialSensor_SITL(AP_InertialSensor &imu);
|
|
|
|
|
|
|
|
/* update accel and gyro state */
|
|
|
|
bool update();
|
|
|
|
|
|
|
|
// detect the sensor
|
|
|
|
static AP_InertialSensor_Backend *detect(AP_InertialSensor &imu);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool init_sensor(void);
|
|
|
|
void timer_update();
|
|
|
|
float rand_float(void);
|
|
|
|
float gyro_drift(void);
|
2017-04-30 21:51:15 -03:00
|
|
|
void generate_accel(uint8_t instance);
|
|
|
|
void generate_gyro(uint8_t instance);
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2015-11-16 00:09:37 -04:00
|
|
|
SITL::SITL *sitl;
|
|
|
|
|
2017-04-30 21:51:15 -03:00
|
|
|
// simulated sensor rates in Hz. This matches a pixhawk1
|
|
|
|
const uint16_t gyro_sample_hz[INS_SITL_INSTANCES] { 1000, 760 };
|
|
|
|
const uint16_t accel_sample_hz[INS_SITL_INSTANCES] { 1000, 800 };
|
|
|
|
|
2015-11-16 00:09:37 -04:00
|
|
|
uint8_t gyro_instance[INS_SITL_INSTANCES];
|
|
|
|
uint8_t accel_instance[INS_SITL_INSTANCES];
|
2017-04-30 21:51:15 -03:00
|
|
|
uint64_t next_gyro_sample[INS_SITL_INSTANCES];
|
|
|
|
uint64_t next_accel_sample[INS_SITL_INSTANCES];
|
2015-11-16 00:09:37 -04:00
|
|
|
};
|