sl-controls created pull request seb/saltylab-firmware#19

sl-controls
Sat, 28 Feb 2026 17:15:57 -0500

19#feat: motor driver layer — differential drive, steer ramp, estop#

Summary

Adds motor_driver.c/h as a layer between the balance PID and the raw hoverboard UART driver.

Differential drive mixing: balance_cmd → speed channel, steer_cmd → steer channel (ready for RC/autonomous yaw input)

Steer-only ramping: ramps steer at MOTOR_STEER_RAMP_RATE (20 counts/ms) to prevent yaw torque disturbing balance. Balance PID output is not ramped — it keeps full immediate authority.

Headroom clamping: reduces steer so |speed|+|steer| <= MOTOR_CMD_MAX, ensuring ESC never clips the balance command

Emergency stop: latches on BALANCE_TILT_FAULT, clears on BALANCE_DISARMED; zero-send stays in the 50Hz ESC tick to avoid flooding UART at 1kHz

main.c: replaces bare hoverboard_send() calls with motor_driver_update()

config.h: adds MOTOR_CMD_MAX=1000, MOTOR_STEER_RAMP_RATE=20

Test plan

Build passes (no new warnings)

Disarmed: ESC receives 0,0 at 50Hz — no timeout

Armed: speed tracks bal.motor_cmd, steer ramps from 0 when steer_cmd applied

Tilt fault: estop latches, both channels zero

Re-disarm: estop clears, ready to re-arm

Headroom: with speed=900, steer clamped to ≤100

🤖 Generated with Claude Code