2026-09-28 15:36:37 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
|
class RobotIMU {
|
|
|
|
|
public:
|
|
|
|
|
bool begin(); // returns false if the IMU didn't respond
|
2026-11-17 14:42:37 +01:00
|
|
|
void update(float dt); // no-op if the IMU never came up
|
2026-09-28 15:36:37 +02:00
|
|
|
float rollDeg() const { return roll_deg_; }
|
|
|
|
|
float pitchDeg() const { return pitch_deg_; }
|
2026-11-17 14:42:37 +01:00
|
|
|
bool ok() const { return ok_; }
|
2026-09-28 15:36:37 +02:00
|
|
|
|
2026-11-17 14:42:37 +01:00
|
|
|
// Robot-gyro toggle from CmdPacket. The attitude is estimated either way
|
|
|
|
|
// (the remote shows it); robot.ino only levels the body while it's set.
|
|
|
|
|
bool enabled = true;
|
2026-09-28 15:36:37 +02:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
};
|