2016-01-19 21:26:31 -04:00
|
|
|
#pragma once
|
2015-11-16 00:09:37 -04:00
|
|
|
|
|
|
|
#include "AP_InertialSensor.h"
|
2021-10-29 22:15:49 -03:00
|
|
|
|
|
|
|
#if AP_SIM_INS_ENABLED
|
|
|
|
|
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
|
|
|
|
2021-10-29 22:15:49 -03:00
|
|
|
#include <SITL/SITL.h>
|
|
|
|
|
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();
|
2021-01-08 06:50:24 -04:00
|
|
|
float get_temperature(void);
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2021-07-30 07:14:29 -03:00
|
|
|
SITL::SIM *sitl;
|
2015-11-16 00:09:37 -04:00
|
|
|
|
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;
|
2022-08-18 04:21:43 -03:00
|
|
|
float gyro_motor_phase[32];
|
|
|
|
float accel_motor_phase[32];
|
2021-01-10 17:08:00 -04:00
|
|
|
uint32_t temp_start_ms;
|
2020-01-03 15:52:33 -04:00
|
|
|
|
|
|
|
static uint8_t bus_id;
|
2015-11-16 00:09:37 -04:00
|
|
|
};
|
2021-10-29 22:15:49 -03:00
|
|
|
#endif // AP_SIM_INS_ENABLED
|