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>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-09-28 15:36:37 +02:00
commit ad77b06c36
27 files changed
+1107

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include "Kinematics.h"
#include "Config.h"
struct GaitPattern {
float duty_factor; // fraction of the cycle each leg spends in stance
float leg_phase_offset[6]; // each leg's phase offset within the cycle, 0..1
};
extern const GaitPattern GAIT_TRIPOD;
extern const GaitPattern GAIT_WAVE;
struct Twist {
float vx = 0, vy = 0; // mm/s, body frame
float omega = 0; // rad/s, body frame
};
class GaitEngine {
public:
void begin();
void setRequestedPattern(const GaitPattern* p) { requested_pattern_ = p; }
void setCycleDuration(float sec) { cycle_sec_ = sec; }
// Advances every leg by dt under the current twist and pattern, writing each
// leg's target foot position (body frame) into out[6].
void update(float dt, const Twist& twist, FootTarget out[6]);
bool legInStance(int i) const { return leg_phase_[i] < legs_pattern_[i]->duty_factor; }
private:
float leg_phase_[6];
const GaitPattern* legs_pattern_[6];
const GaitPattern* requested_pattern_ = &GAIT_TRIPOD;
float cycle_sec_ = DEFAULT_CYCLE_SEC;
};