Files
hexapod-robot/2026-current/remote/RemoteIMU.h
T
mangavalkandClaude Opus 5.5 91dac16fca Draft: shared protocol, remote firmware, project docs
Not yet verified on hardware.

- shared/HexapodProtocol: CmdPacket (now 20 bytes, adds remote_roll /
  remote_pitch), FLAG_* bits and radio settings as the single protocol
  definition; static payload size = sizeof(CmdPacket) on both radios.
- robot: use the shared protocol; vx = forward (harness w/x <-> q/e);
  InputMapper adds remote tilt on top of the right stick when
  FLAG_REMOTE_GYRO is set, and robot.ino no longer zeroes stick
  roll/pitch when it's off.
- remote (Teensy 4.1): Sticks (calibration, EEPROM), RemoteIMU,
  RemoteState (interlocks, link-loss disarm, smoothing), PacketBuilder,
  RadioLink, NextionUI, SerialConsole.
- CLAUDE.md, README.md, remote/README.md, remote/NEXTION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:14:00 +02:00

29 lines
1.0 KiB
C++

#pragma once
#include <Arduino.h>
// Handset attitude from an MPU6050: same complementary filter as the robot's
// RobotIMU, plus a mounting-orientation remap, boot-time gyro bias capture,
// and a "level" reference so the operator's natural holding angle reads as 0.
class RemoteIMU {
public:
bool begin(); // false if the IMU didn't respond; hold the remote still during this
void update(float dt); // no-op if the IMU never came up
bool ok() const { return ok_; }
// Tilt relative to the zeroed level pose, degrees, handset frame
// (+roll = right side down, +pitch = far edge down).
float rollDeg() const { return roll_deg_ - zero_roll_; }
float pitchDeg() const { return pitch_deg_ - zero_pitch_; }
void zeroLevel() { zero_roll_ = roll_deg_; zero_pitch_ = pitch_deg_; }
private:
float roll_deg_ = 0, pitch_deg_ = 0;
float zero_roll_ = 0, zero_pitch_ = 0;
float gyro_bias_[3] = {};
bool ok_ = false;
// Reads and remaps into the handset frame. Accel in g, gyro in deg/s.
bool readRaw(float a[3], float g[3]);
};