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

Tunes the per-motor firmware-side velocity PID (STM32 MAV mode). More...

#include <firmware_pid_tune.hpp>

Public Member Functions

 FirmwarePidTuner (const std::vector< hal::motor::IMotor * > &motors, hal::imu::IIMU *imu=nullptr)
FirmwarePidResult tuneMotor (hal::motor::IMotor *motor, int max_bemf_speed, const FirmwarePidConfig &cfg) const
 Tune a single motor.
std::map< int, FirmwarePidResult > tune (const std::map< int, int > &max_bemf_speeds, const FirmwarePidConfig &cfg) const
 Tune every motor passed at construction.

Detailed Description

Tunes the per-motor firmware-side velocity PID (STM32 MAV mode).

For each motor the tuner records a baseline step response in BEMF units, fits a FOPDT plant model, derives CHR PID gains, pushes them to the firmware via IMotor::setFirmwarePidGains() and re-runs the step response. Gains are accepted only if the tuned ISE is strictly smaller than the baseline ISE.

Note
FirmwarePidTuner holds non-owning pointers to the supplied motors; the caller must ensure each motor outlives the tuner.

Definition at line 25 of file firmware_pid_tune.hpp.

Constructor & Destructor Documentation

◆ FirmwarePidTuner()

libstp::autotune::FirmwarePidTuner::FirmwarePidTuner ( const std::vector< hal::motor::IMotor * > & motors,
hal::imu::IIMU * imu = nullptr )
explicit
Parameters
motorsNon-owning list of motors to tune.
imuOptional IMU pointer — when non-null, every CSV dump includes the gyro/accel/heading readings sampled in the same tight loop as the motors.

Member Function Documentation

◆ tune()

std::map< int, FirmwarePidResult > libstp::autotune::FirmwarePidTuner::tune ( const std::map< int, int > & max_bemf_speeds,
const FirmwarePidConfig & cfg ) const
nodiscard

Tune every motor passed at construction.

Motors without an entry in max_bemf_speeds are skipped with a warning.

Parameters
max_bemf_speedsMap from port -> max BEMF speed.
cfgShared tuning configuration.
Returns
Map from port -> tuning result.

◆ tuneMotor()

FirmwarePidResult libstp::autotune::FirmwarePidTuner::tuneMotor ( hal::motor::IMotor * motor,
int max_bemf_speed,
const FirmwarePidConfig & cfg ) const
nodiscard

Tune a single motor.

Parameters
motorMotor to tune.
max_bemf_speedSteady-state BEMF (firmware velocity units) at full power for this motor — typically derived from a DriveCharacterizer-style sweep.
cfgTuning configuration.

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