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>
27 lines
779 B
C
27 lines
779 B
C
#pragma once
|
|
|
|
// Rate-limited setpoint smoother - identical to robot/SmoothedValue.h (kept
|
|
// as a copy rather than moved to shared/ so the robot sketch stays untouched).
|
|
// Used for UI-driven setpoints that would otherwise step: speed scale and
|
|
// the remote-tilt fade.
|
|
struct SmoothedValue {
|
|
float current = 0;
|
|
float target = 0;
|
|
float max_rate; // units per second
|
|
|
|
explicit SmoothedValue(float rate = 100.0f) : max_rate(rate) {}
|
|
|
|
void setTarget(float t) { target = t; }
|
|
|
|
float update(float dt) {
|
|
float delta = target - current;
|
|
float max_step = max_rate * dt;
|
|
if (delta > max_step) delta = max_step;
|
|
else if (delta < -max_step) delta = -max_step;
|
|
current += delta;
|
|
return current;
|
|
}
|
|
|
|
void reset(float v) { current = target = v; }
|
|
};
|