Files
mangavalkandClaude Opus 5.5 ad77b06c36 Initial import: robot firmware + PlatformIO two-env scaffold
Robot-side firmware (Teensy 4.0) imported unchanged as extracted.
platformio.ini defines [env:robot] (teensy40) and [env:remote]
(teensy41); scripts/select_src_dir.py points each env at its own
sketch folder so robot/ and remote/ stay Arduino-style sketches.

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

26 lines
722 B
C

#pragma once
// Rate-limited setpoint smoother. Every place a discrete command can jump
// (body pose axes, gait speed, the sit/stand blend) gets one of these instead
// of using the raw commanded value directly.
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; }
};