Robot: Teensy 3.6 with the old robot's servo wiring and calibration

- LEGACY/Hexapod_Teensy/: old robot sketch (reference only).
- platformio.ini: robot env targets teensy36 (owner-confirmed board).
- Config.h: per-servo SERVOS table (pin, pulse at 0 deg, signed
  us/deg, pulse limits) built from the old sketch's pins, ranges, trims
  and the old Unity servo directions. Rear-left/front-left coxa offsets
  set to 0: the owner re-horns those two servos (the old +-90 left them
  at the end of travel; the sim showed them clamping).
- ServoDriver: 18 servos on hardware PWM (50 Hz, 16-bit); the Teensy 3.6
  Servo library stops at 12.
- Radio on CE 39 / CSN 15 with SPI SCK on pin 14.
- sim: analogWrite/PWM shims, pulses decoded through SERVOS (API v6).
- Docs: CLAUDE.md, READMEs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-01 15:53:55 +02:00
1 parent a961fa721b
commit 5ff85c4eb8
21 files changed
+795 -80

No files matched your search

+21 -18
View File
@@ -1,4 +1,4 @@
# Hexapod robot firmware (Teensy 4.0)
# Hexapod robot firmware (Teensy 3.6)
This is the **robot-side** firmware. It is fully functional on its own
(driven by the serial test harness below) and receives commands from the
@@ -10,8 +10,8 @@ sketches compile against.
From the repo root (PlatformIO): `pio run -e robot`, flash with
`pio run -e robot -t upload`, monitor with `pio device monitor -e robot`.
RF24 is pulled in automatically via `lib_deps`; Servo ships with the Teensy
framework.
RF24 is pulled in automatically via `lib_deps`. Servos are driven by the
Teensy's hardware PWM directly, so no servo library is needed.
Arduino IDE also works if you copy `shared/HexapodProtocol/` into your
sketchbook `libraries/` folder and install **RF24** by TMRh20.
@@ -31,15 +31,18 @@ still a placeholder. Check all of it against the real robot:
- `LEG_CLEARANCE_MM`: how close neighbouring legs may get. Walking speed
and body pose are scaled down to keep it, so set it to about one leg's
width.
- `SERVO_PINS` — must be PWM-capable pins on your Teensy 4.0 wiring
- `SERVO_US_AT_0DEG` / `SERVO_US_PER_DEG` — calibrate per servo, they vary
batch to batch
- `RADIO_CE_PIN` / `RADIO_CSN_PIN` — your nRF24 wiring. Address, channel,
data rate, PA level and payload size are in `shared/HexapodProtocol` so
they can't drift from the remote.
- **Pin conflict:** `SERVO_PINS` leg 3 uses pins 11 and 12, which are the
Teensy 4.0's SPI MOSI/MISO that the nRF24 needs. Move those two servos
before wiring the radio.
- `SERVOS`: one entry per servo with pin, pulse at 0°, signed µs per
degree (sign = direction) and pulse limits. It's prefilled from the old
robot sketch (`LEGACY/Hexapod_Teensy/config.h`): pins, ranges, trims, and
directions from the old Unity servo mapping. Check every joint's
direction on the bench.
- **Before powering up:** re-mount the rear-left and front-left coxa servo
horns 90° so those legs point straight out at servo center. The old code
needed ±90° offsets there, which left the servos at the end of their
travel.
- `RADIO_CE_PIN` / `RADIO_CSN_PIN` / `RADIO_SCK_PIN`: 39 / 15 / 14, as in
the old sketch. Address, channel, data rate, PA level and payload size
are in `shared/HexapodProtocol` so they can't drift from the remote.
## Bench-check checklist (do this before the first stand-up)
@@ -69,12 +72,12 @@ for your build:
each foot opposite to the commanded motion. The smoke test checks that
`+vx` moves the body forward and `+yaw_rate` turns it left (CCW). On
the bench, confirm `w` walks forward and `z` turns left.
6. **Per-servo calibration**. `ServoDriver` uses one
`SERVO_US_AT_0DEG` / `SERVO_US_PER_DEG` for all 18 servos, so servo
center = joint angle 0 (tibia *straight*). On this build the knee servo
center is the tibia at 90° to the femur, and the left side is mirrored
(per the old Unity/servo code). That needs a per-joint offset and
direction before the real robot will stand.
6. **Per-servo calibration** (`Config.h` `SERVOS`). Arm the robot,
stand it on a box, and move one joint at a time (or watch the sim next
to it): each servo must turn the way the sim shows. To flip a direction,
flip that entry's `dir`. Also check that a femur moves the commanded
angle: its old range gives only ≈6.7 µs/° against ≈10.4 for coxa and
tibia.
## Testing in the simulation