2021-09-30 05:35:51 -03:00
|
|
|
// Created by Asa Davis and Davis Schenkenberger on 23rd September 21.
|
2021-09-23 19:26:03 -03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SIM_Aircraft.h"
|
|
|
|
|
|
|
|
#include <SITL/SITL.h>
|
|
|
|
#include "SIM_SerialDevice.h"
|
|
|
|
|
|
|
|
namespace SITL
|
|
|
|
{
|
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
class MicroStrain : public SerialDevice
|
2021-09-23 19:26:03 -03:00
|
|
|
{
|
2023-11-20 22:17:20 -04:00
|
|
|
// This class implements the common MicroStrain driver support.
|
2021-09-23 19:26:03 -03:00
|
|
|
public:
|
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
MicroStrain();
|
2021-09-23 19:26:03 -03:00
|
|
|
|
|
|
|
// update state
|
|
|
|
void update(void);
|
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
protected:
|
2023-08-04 18:31:14 -03:00
|
|
|
struct MicroStrain_Packet {
|
2021-09-23 19:26:03 -03:00
|
|
|
uint8_t header[4];
|
|
|
|
uint8_t payload[256];
|
|
|
|
uint8_t checksum[2];
|
|
|
|
|
|
|
|
size_t payload_size = 0;
|
|
|
|
};
|
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
uint32_t last_imu_pkt_ms;
|
|
|
|
uint32_t last_gnss_pkt_ms;
|
|
|
|
uint32_t last_filter_pkt_ms;
|
2021-09-23 19:26:03 -03:00
|
|
|
|
2023-08-04 18:31:14 -03:00
|
|
|
void generate_checksum(MicroStrain_Packet&);
|
2021-09-23 19:26:03 -03:00
|
|
|
|
2023-08-04 18:31:14 -03:00
|
|
|
void send_packet(MicroStrain_Packet);
|
2021-09-23 19:26:03 -03:00
|
|
|
void send_imu_packet();
|
2023-11-20 22:17:20 -04:00
|
|
|
virtual void send_gnss_packet() = 0;
|
|
|
|
virtual void send_filter_packet() = 0;
|
2021-09-23 19:26:03 -03:00
|
|
|
|
2023-08-04 18:31:14 -03:00
|
|
|
void put_float(MicroStrain_Packet&, float);
|
|
|
|
void put_double(MicroStrain_Packet&, double);
|
|
|
|
void put_int(MicroStrain_Packet&, uint16_t);
|
2021-09-23 19:26:03 -03:00
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
// get timeval using simulation time
|
|
|
|
static void simulation_timeval(struct timeval *tv);
|
|
|
|
|
2021-09-23 19:26:03 -03:00
|
|
|
uint64_t start_us;
|
|
|
|
};
|
|
|
|
|
2023-11-20 22:17:20 -04:00
|
|
|
class MicroStrain5 : public MicroStrain
|
|
|
|
{
|
|
|
|
// This is a specialization for the 3DM-GX5-GNSS/INS
|
|
|
|
private:
|
|
|
|
void send_gnss_packet() override;
|
|
|
|
void send_filter_packet() override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class MicroStrain7 : public MicroStrain
|
|
|
|
{
|
|
|
|
// This is a specialization for the 3DM-GQ7-GNSS/INS
|
|
|
|
private:
|
|
|
|
void send_gnss_packet() override;
|
|
|
|
void send_filter_packet() override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-09-30 05:35:51 -03:00
|
|
|
}
|
|
|
|
|