18 lines
521 B
C++
18 lines
521 B
C++
#pragma once
|
|||
|
|
#include <Arduino.h>
|
||
|
|
|
||
|
|
class RobotIMU {
|
||
|
|
public:
|
||
|
|
bool begin(); // returns false if the IMU didn't respond
|
||
|
|
void update(float dt); // no-op if disabled or the IMU never came up
|
||
|
|
float rollDeg() const { return roll_deg_; }
|
||
|
|
float pitchDeg() const { return pitch_deg_; }
|
||
|
|
|
||
|
|
bool enabled = true; // robot-gyro toggle from CmdPacket sets this
|
||
|
|
|
||
|
|
private:
|
||
|
|
float roll_deg_ = 0, pitch_deg_ = 0;
|
||
|
|
bool ok_ = false;
|
||
|
|
|
||
|
|
bool readRaw(float& ax, float& ay, float& az, float& gx, float& gy, float& gz);
|
||
|
|
};
|