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
|
|
|
|
|
|
|
//usage:
|
|
|
|
//PARAMS:
|
2021-09-30 05:35:51 -03:00
|
|
|
// param set AHRS_EKF_TYPE 11
|
|
|
|
// param set EAHRS_TYPE 2
|
|
|
|
// param set SERIAL4_PROTOCOL 36
|
|
|
|
// param set SERIAL4_BAUD 115
|
2023-08-04 18:31:14 -03:00
|
|
|
// sim_vehicle.py -v ArduPlane -D --console --map -A --uartE=sim:MicroStrain
|
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-08-04 18:31:14 -03:00
|
|
|
class MicroStrain : public SerialDevice
|
2021-09-23 19:26:03 -03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2023-08-04 18:31:14 -03:00
|
|
|
MicroStrain();
|
2021-09-23 19:26:03 -03:00
|
|
|
|
|
|
|
// update state
|
|
|
|
void update(void);
|
|
|
|
|
|
|
|
private:
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t last_imu_pkt_us;
|
|
|
|
uint32_t last_gnss_pkt_us;
|
|
|
|
uint32_t last_filter_pkt_us;
|
|
|
|
|
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();
|
|
|
|
void send_gnss_packet();
|
|
|
|
void send_filter_packet();
|
|
|
|
|
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
|
|
|
|
|
|
|
uint64_t start_us;
|
|
|
|
};
|
|
|
|
|
2021-09-30 05:35:51 -03:00
|
|
|
}
|
|
|
|
|