Files
Loongson_2k0300_SmartCar_Fr…/control/imu.hpp

25 lines
594 B
C++

#pragma once
#include "types.hpp"
#include <cstdint>
class YawTracker {
public:
YawTracker();
bool begin(const char* device = IMU_DEVICE, int baud = IMU_BAUDRATE);
void update(float dt);
void calibrate(int samples = 200);
float yaw() const { return _yaw; }
float unbounded_yaw() const { return _unbounded_yaw; }
float gyro_z() const { return _gyro_z; }
bool ready() const { return _ready; }
private:
int _fd;
float _yaw, _unbounded_yaw;
float _gyro_z;
float _gyro_bias;
bool _ready;
int _parseJY62();
};