Code — salamander-v2 firmware
The firmware runs on an RP2040 (Pico W). Written in MicroPython for speed of iteration — C++ port planned once the control model stabilizes.
Architecture
Three main loops:
- Gait controller — generates sine-wave offsets for each servo pair. The phase offset between front and rear legs is the core parameter that determines gait type (walk vs trot vs bound).
- Spine articulation — drives the vertebrae tendon servo based on current heading error from the IMU.
- Telemetry — pushes sensor state over BLE at 10Hz for the dashboard.
Current issues
The PID tuning for the spine is incomplete. The proportional term alone makes the body oscillate at walking speed. Adding derivative damps it but introduces a lag that makes tight turns sluggish.
The gait controller works well on flat linoleum. On carpet the front legs stall under load and the phase drifts.
Dependencies
machine(RP2040 hardware abstraction)uasyncio(cooperative multitasking)- Custom
imu_driver.pyfor the BNO055 ble_simple_peripheral.pyfrom MicroPython examples, modified