libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::autotune::VelLpfTuner Class Reference

Tunes the per-motor encoder-velocity LPF alpha (MotorCalibration::vel_lpf_alpha). More...

#include <vel_lpf_tune.hpp>

Public Member Functions

 VelLpfTuner (const std::vector< hal::motor::IMotor * > &motors)
VelLpfResult tuneMotor (hal::motor::IMotor *motor, const VelLpfConfig &cfg) const
std::map< int, VelLpfResult > tune (const VelLpfConfig &cfg) const
 Spin all motors forward together, sample simultaneously, tune each.

Detailed Description

Tunes the per-motor encoder-velocity LPF alpha (MotorCalibration::vel_lpf_alpha).

For each candidate alpha the tuner replays the raw BEMF stream through an in-memory IIR filter (filt = (1-a)*filt + a*raw) and scores the result by combining (a) variance of the filtered series (noise) and (b) lag, measured as the standard deviation of the per-sample difference.

Crucially, the BEMF must be sampled while the motor is spinning: the LPF filters the running velocity estimate, and a motor at standstill produces only deadzone noise (nothing to tune). tune() therefore spins every drive motor forward at cfg.spin_percent, lets them settle, samples all motors simultaneously during one straight run, then stops and scores each.

Definition at line 26 of file vel_lpf_tune.hpp.

Constructor & Destructor Documentation

◆ VelLpfTuner()

libstp::autotune::VelLpfTuner::VelLpfTuner ( const std::vector< hal::motor::IMotor * > & motors)
explicit

Member Function Documentation

◆ tune()

std::map< int, VelLpfResult > libstp::autotune::VelLpfTuner::tune ( const VelLpfConfig & cfg) const
nodiscard

Spin all motors forward together, sample simultaneously, tune each.

◆ tuneMotor()

VelLpfResult libstp::autotune::VelLpfTuner::tuneMotor ( hal::motor::IMotor * motor,
const VelLpfConfig & cfg ) const
nodiscard

Spin a single motor, capture its running BEMF, and tune its alpha. (Standalone helper; the chassis curves since only one wheel drives.)


The documentation for this class was generated from the following file:
  • /home/runner/work/raccoon-lib/raccoon-lib/modules/libstp-autotune/include/autotune/vel_lpf_tune.hpp