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

Orchestrates the full auto-tune pipeline in a single C++ entry point so phase-to-phase state coherence is guaranteed. More...

#include <auto_tuner.hpp>

Public Types

using ConfirmCallback = std::function<void(const std::string& phase_key)>

Public Member Functions

 AutoTuner (drive::Drive &drive, odometry::IOdometry &odometry, motion::UnifiedMotionPidConfig &motion_pid_config)
void setConfirmCallback (ConfirmCallback cb)
 Install a callback invoked before every phase in tuneAll().
AutoTuneResult tuneAll (const AutoTuneConfig &cfg)
std::map< int, VelLpfResult > runVelLpfPhase (const VelLpfConfig &cfg)
std::map< int, StaticFrictionResult > runStaticFrictionPhase (const StaticFrictionConfig &cfg)
std::map< int, FirmwarePidResult > runFirmwarePidPhase (const FirmwarePidConfig &cfg, std::optional< std::map< int, int > > max_bemf_speeds=std::nullopt)
EncoderCalResult runEncoderCalibrationPhase (const EncoderCalConfig &cfg)
std::map< std::string, AxisResult > runCharacterizePhase (const std::vector< std::string > &axes, const CharacterizeConfig &cfg)
std::map< std::string, VelocityTuneResult > runVelocityPhase (const std::vector< std::string > &axes, const std::map< std::string, double > &max_velocities, const VelocityTuneConfig &cfg)
std::map< std::string, MotionTuneResult > runMotionPhase (const std::vector< std::string > &params, const MotionTuneConfig &cfg)
ToleranceResult runTolerancesPhase (const std::map< std::string, MotionTuneResult > &motion_results, const MotionTuneConfig &motion_cfg, const ToleranceConfig &cfg)

Detailed Description

Orchestrates the full auto-tune pipeline in a single C++ entry point so phase-to-phase state coherence is guaranteed.

Every phase reads its inputs straight from the live IMotor, Drive, and UnifiedMotionPidConfig instances and writes its results back to those same objects before returning. Python wrappers do not need to shuttle calibration values between phases.

Execution order (each phase depends on the one before it):

  1. vel_lpf — per-motor IIR alpha (drives velocity feedback)
  2. static_friction — kS for feedforward / minimum-command
  3. firmware_pid — STM32 MAV-mode inner PID
  4. encoder_cal — global ticks_to_rad scale (republishes kinematics)
  5. characterize — physical drive limits (max v, accel, decel)
  6. velocity — chassis-axis velocity PID
  7. motion — distance / heading PID
  8. tolerances — derived from motion residuals

Definition at line 109 of file auto_tuner.hpp.

Member Typedef Documentation

◆ ConfirmCallback

using libstp::autotune::AutoTuner::ConfirmCallback = std::function<void(const std::string& phase_key)>

Per-phase confirmation callback (invoked before the phase runs).

Definition at line 113 of file auto_tuner.hpp.

Constructor & Destructor Documentation

◆ AutoTuner()

libstp::autotune::AutoTuner::AutoTuner ( drive::Drive & drive,
odometry::IOdometry & odometry,
motion::UnifiedMotionPidConfig & motion_pid_config )

Member Function Documentation

◆ runCharacterizePhase()

std::map< std::string, AxisResult > libstp::autotune::AutoTuner::runCharacterizePhase ( const std::vector< std::string > & axes,
const CharacterizeConfig & cfg )

◆ runEncoderCalibrationPhase()

EncoderCalResult libstp::autotune::AutoTuner::runEncoderCalibrationPhase ( const EncoderCalConfig & cfg)

◆ runFirmwarePidPhase()

std::map< int, FirmwarePidResult > libstp::autotune::AutoTuner::runFirmwarePidPhase ( const FirmwarePidConfig & cfg,
std::optional< std::map< int, int > > max_bemf_speeds = std::nullopt )

◆ runMotionPhase()

std::map< std::string, MotionTuneResult > libstp::autotune::AutoTuner::runMotionPhase ( const std::vector< std::string > & params,
const MotionTuneConfig & cfg )

◆ runStaticFrictionPhase()

std::map< int, StaticFrictionResult > libstp::autotune::AutoTuner::runStaticFrictionPhase ( const StaticFrictionConfig & cfg)

◆ runTolerancesPhase()

ToleranceResult libstp::autotune::AutoTuner::runTolerancesPhase ( const std::map< std::string, MotionTuneResult > & motion_results,
const MotionTuneConfig & motion_cfg,
const ToleranceConfig & cfg )

◆ runVelLpfPhase()

std::map< int, VelLpfResult > libstp::autotune::AutoTuner::runVelLpfPhase ( const VelLpfConfig & cfg)

◆ runVelocityPhase()

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

◆ setConfirmCallback()

void libstp::autotune::AutoTuner::setConfirmCallback ( ConfirmCallback cb)

Install a callback invoked before every phase in tuneAll().

The callback receives a stable phase key — one of "vel_lpf", "static_friction", "firmware_pid", "encoder_cal", "characterize", "velocity", "motion", "tolerances" — so callers can show prompts, record telemetry, or skip phases at runtime.

For phases that command motion on multiple axes/params the key is extended with a colon suffix, e.g. "characterize:forward", "velocity:vx", "motion:heading".

◆ tuneAll()

AutoTuneResult libstp::autotune::AutoTuner::tuneAll ( const AutoTuneConfig & cfg)

Run every phase enabled in cfg, in dependency order.


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