2017-06-21 14:39:07 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Compass.h"
|
|
|
|
#include "AP_Compass_Backend.h"
|
|
|
|
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
|
|
|
#include <SITL/SITL.h>
|
|
|
|
#include <AP_Math/vectorN.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AP_Declination/AP_Declination.h>
|
|
|
|
|
2019-11-20 03:18:10 -04:00
|
|
|
#define MAX_SITL_COMPASSES 3
|
2017-06-21 14:39:07 -03:00
|
|
|
|
|
|
|
class AP_Compass_SITL : public AP_Compass_Backend {
|
|
|
|
public:
|
2018-08-06 19:21:27 -03:00
|
|
|
AP_Compass_SITL();
|
2017-06-21 14:39:07 -03:00
|
|
|
|
2019-02-21 19:06:10 -04:00
|
|
|
void read(void) override;
|
2017-06-21 14:39:07 -03:00
|
|
|
|
|
|
|
private:
|
2019-11-20 03:18:10 -04:00
|
|
|
uint8_t _compass_instance[MAX_SITL_COMPASSES];
|
|
|
|
uint8_t _num_compass;
|
2021-07-30 07:13:08 -03:00
|
|
|
SITL::SIM *_sitl;
|
2017-06-21 14:39:07 -03:00
|
|
|
|
|
|
|
// delay buffer variables
|
|
|
|
struct readings_compass {
|
|
|
|
uint32_t time;
|
|
|
|
Vector3f data;
|
|
|
|
};
|
|
|
|
uint8_t store_index;
|
|
|
|
uint32_t last_store_time;
|
|
|
|
static const uint8_t buffer_length = 50;
|
|
|
|
VectorN<readings_compass,buffer_length> buffer;
|
|
|
|
|
|
|
|
void _timer();
|
|
|
|
uint32_t _last_sample_time;
|
|
|
|
|
2020-05-12 15:05:33 -03:00
|
|
|
void _setup_eliptical_correcion(uint8_t i);
|
2018-07-16 23:56:44 -03:00
|
|
|
|
|
|
|
Matrix3f _eliptical_corr;
|
|
|
|
Vector3f _last_dia;
|
|
|
|
Vector3f _last_odi;
|
2020-08-27 23:26:58 -03:00
|
|
|
Vector3f _last_data[MAX_SITL_COMPASSES];
|
2017-06-21 14:39:07 -03:00
|
|
|
};
|
|
|
|
#endif // CONFIG_HAL_BOARD
|