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

Tunes per-axis velocity PID gains via step-response identification. More...

#include <velocity_tune.hpp>

Public Member Functions

 VelocityTuner (drive::Drive &drive, odometry::IOdometry &odometry)
VelocityTuneResult tuneAxis (const std::string &axis, double max_velocity, const VelocityTuneConfig &cfg) const
 Tune a single velocity axis.
std::map< std::string, VelocityTuneResult > tune (const std::vector< std::string > &axes, const std::map< std::string, double > &max_velocities, const VelocityTuneConfig &cfg) const
 Tune multiple axes in sequence.

Detailed Description

Tunes per-axis velocity PID gains via step-response identification.

For each axis (vx, vy, wz) VelocityTuner:

  1. Records a baseline open-loop-equivalent step response with the existing gains and computes its ISE.
  2. Fits a FOPDT plant model using the inflection-tangent method (with a rise-time fallback).
  3. Derives CHR (Chien–Hrones–Reswick) PID gains from the model.
  4. Applies the candidate gains, records a second step response, and accepts the new gains only if the tuned ISE is strictly lower than the baseline ISE. Otherwise the original gains are restored.
Note
VelocityTuner holds non-owning references to Drive and IOdometry. The caller must ensure both objects outlive the VelocityTuner.

Definition at line 30 of file velocity_tune.hpp.

Constructor & Destructor Documentation

◆ VelocityTuner()

libstp::autotune::VelocityTuner::VelocityTuner ( drive::Drive & drive,
odometry::IOdometry & odometry )
Parameters
driveChassis drive controller (reference, not owned).
odometryOdometry source (reference, not owned).

Member Function Documentation

◆ tune()

std::map< std::string, VelocityTuneResult > libstp::autotune::VelocityTuner::tune ( const std::vector< std::string > & axes,
const std::map< std::string, double > & max_velocities,
const VelocityTuneConfig & cfg ) const
nodiscard

Tune multiple axes in sequence.

Axes not present in max_velocities are skipped with a warning.

Parameters
axesAxis names to tune (e.g. {"vx", "wz"}).
max_velocitiesMap from axis name to max physical velocity.
cfgShared tuning configuration.
Returns
Map from axis name to VelocityTuneResult.

◆ tuneAxis()

VelocityTuneResult libstp::autotune::VelocityTuner::tuneAxis ( const std::string & axis,
double max_velocity,
const VelocityTuneConfig & cfg ) const
nodiscard

Tune a single velocity axis.

Parameters
axisOne of "vx", "vy", or "wz".
max_velocityMaximum physical velocity for this axis (m/s or rad/s); typically obtained from DriveCharacterizer.
cfgTuning configuration.
Returns
VelocityTuneResult with plant params, gains, ISE metrics, and whether the new gains were accepted.

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