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

Tunes motion PID gains (distance, lateral, heading) via Hooke-Jeeves coordinate descent. More...

#include <motion_tune.hpp>

Public Member Functions

 MotionTuner (drive::Drive &drive, odometry::IOdometry &odometry, motion::UnifiedMotionPidConfig &pid_config)
std::map< std::string, MotionTuneResult > tune (const std::vector< std::string > &params, const MotionTuneConfig &cfg) const
 Tune multiple parameters in sequence.
MotionTuneResult tuneParam (const std::string &param_name, const MotionTuneConfig &cfg) const
 Tune a single motion PID parameter.
void requestPauseAfterTrial () const noexcept
 Queue a pause that takes effect after the current trial completes.
void resume () const noexcept
 Cancel a queued pause or resume from an active pause.
std::string pauseState () const
 Current operator-control state: "running", "stop_queued", or "stopped".

Detailed Description

Tunes motion PID gains (distance, lateral, heading) via Hooke-Jeeves coordinate descent.

For each parameter the tuner:

  1. Runs a real closed-loop motion trial and scores the result by combining settle time, overshoot, and final error.
  2. Iteratively perturbs kp and kd, keeping improvements, shrinking step size on no-improvement until deltas drop below the minimum threshold.

The UnifiedMotionPidConfig referenced on construction is mutated in-place during every trial (the gains are written directly before each motion is created) and, after tuning, retains the best-found gains. Callers should persist the config themselves after tune() returns.

Note
MotionTuner holds non-owning references to Drive, IOdometry, and UnifiedMotionPidConfig. All three objects must outlive the tuner.

Definition at line 37 of file motion_tune.hpp.

Constructor & Destructor Documentation

◆ MotionTuner()

libstp::autotune::MotionTuner::MotionTuner ( drive::Drive & drive,
odometry::IOdometry & odometry,
motion::UnifiedMotionPidConfig & pid_config )
Parameters
driveChassis drive controller (reference, not owned).
odometryOdometry source (reference, not owned).
pid_configMotion PID config to tune in place (reference, not owned).

Member Function Documentation

◆ pauseState()

std::string libstp::autotune::MotionTuner::pauseState ( ) const
nodiscard

Current operator-control state: "running", "stop_queued", or "stopped".

◆ requestPauseAfterTrial()

void libstp::autotune::MotionTuner::requestPauseAfterTrial ( ) const
noexcept

Queue a pause that takes effect after the current trial completes.

◆ resume()

void libstp::autotune::MotionTuner::resume ( ) const
noexcept

Cancel a queued pause or resume from an active pause.

◆ tune()

std::map< std::string, MotionTuneResult > libstp::autotune::MotionTuner::tune ( const std::vector< std::string > & params,
const MotionTuneConfig & cfg ) const
nodiscard

Tune multiple parameters in sequence.

Valid param names are "distance", "lateral", and "heading". The pid_config is updated with the best-found gains for each parameter.

Parameters
paramsList of parameter names to tune.
cfgTuning configuration.
Returns
Map from parameter name to MotionTuneResult.

◆ tuneParam()

MotionTuneResult libstp::autotune::MotionTuner::tuneParam ( const std::string & param_name,
const MotionTuneConfig & cfg ) const
nodiscard

Tune a single motion PID parameter.

Parameters
param_nameOne of "distance", "lateral", or "heading".
cfgTuning configuration.
Returns
MotionTuneResult with initial/final gains and scores.

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