Motor Config

Motors are declared in config/motors.yml. hardware.yml merges that file in, so every motor becomes an attribute on Defs. Each key must be a valid Python identifier. Chassis motors and aux motors are declared the same way, see Motors for the difference. The chassis motors are then named in drive.kinematics in robot.yml .

Motor entry

Maps to libstp.hal.Motor.

KeyTypeDefaultDescription
typestring—Must be Motor.
portinteger—Required. Hardware port number (0–3 on the Wombat).
invertedboolfalseWhen true, all velocity and position commands are negated before sending to hardware. Use this to correct for motors mounted in reverse.
calibrationmappingSee belowMotor calibration data. Sub-keys are described below.

calibration sub-keys

These map directly to fields on the C++ MotorCalibration struct in raccoon-lib/modules/libstp-foundation/include/foundation/motor.hpp.

KeyTypeC++ defaultDescriptionWritten by
ticks_to_radfloat2π / 1440 ≈ 0.004363Converts raw encoder tick counts to radians of shaft rotation. Must be strictly positive. The scaffold placeholder 0.00002 is wrong for most hardware; run raccoon calibrate ticks to measure the real value.raccoon calibrate ticks
vel_lpf_alphafloat0.5IIR low-pass filter coefficient for the BEMF-derived velocity estimate. 1.0 = no filtering (raw); 0.0 = frozen. Must be in [0, 1]. Lower values smooth velocity at the cost of lag.raccoon calibrate autotune
bemf_offsetfloat0.0Per-motor BEMF zero-offset (ADC counts) subtracted on the STM32 before integrating encoder ticks. Corrects for drift so the tick integral stays proportional to wheel angle.raccoon calibrate autotune
pid.kpfloat1.0Proportional gain for the optional per-motor velocity PID loop. The pid block is optional — omit it entirely to disable per-motor closed-loop control.raccoon calibrate autotune
pid.kifloat0.0Integral gain for the per-motor velocity PID.raccoon calibrate autotune
pid.kdfloat0.0Derivative gain for the per-motor velocity PID.raccoon calibrate autotune
static_friction_pctfloat0.0Minimum open-loop PWM duty (as a percent) required to overcome motor stiction, measured during the autotune static-friction phase. 0.0 = unmeasured / not applied.raccoon calibrate autotune

Minimal scaffold entry:

left_motor:
  type: Motor
  port: 0
  inverted: false
  calibration:
    ticks_to_rad: 0.00002
    vel_lpf_alpha: 1.0

After running raccoon calibrate ticks and raccoon calibrate autotune:

left_motor:
  type: Motor
  port: 0
  inverted: false
  calibration:
    ticks_to_rad: 0.004363      # written by: raccoon calibrate ticks
    vel_lpf_alpha: 0.8           # written by: raccoon calibrate autotune
    bemf_offset: -0.0041         # written by: raccoon calibrate autotune
    static_friction_pct: 3.2     # written by: raccoon calibrate autotune
    pid:                         # optional — only present after autotune
      kp: 0.12
      ki: 0.0
      kd: 0.0

Real asymmetric values are normal. The examplebot’s two drive motors had calibrated values of 1.741e-05 (left) and 1.712e-05 (right) — a ~1.7% difference. This is within the normal manufacturing tolerance for hobbyist motors, and the per-motor ticks_to_rad exactly corrects for it so the robot drives straight. Do not assume both motors should have the same value; if you enter the same value for both, you may see the robot drift.

The most common mistake is entering a raw tick count rather than 2 * pi / ticks_per_revolution. If you have a motor with 1440 ticks per revolution, ticks_to_rad = 2 * pi / 1440 ≈ 0.004363. The scaffold placeholder 0.00002 is wrong for most hardware — always run raccoon calibrate ticks to measure the real value.