• wiki ○ hub
WORKBENCH · 2026.04.13 · 45% · PID tuning incomplete · firmware and control loops

code

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:

  1. 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).
  2. Spine articulation — drives the vertebrae tendon servo based on current heading error from the IMU.
  3. 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.py for the BNO055
  • ble_simple_peripheral.py from MicroPython examples, modified
READING site: hub