libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::foundation::MotorCalibration Struct Reference

Calibration constants commonly needed for motor encoder conversions. More...

#include <motor.hpp>

Public Member Functions

 MotorCalibration ()=default
 MotorCalibration (double ticks_to_rad, double vel_lpf_alpha, std::optional< PidGains > pid=std::nullopt, double bemf_offset=0.0, double static_friction_pct=0.0)
void validate () const

Public Attributes

double ticks_to_rad {2.0 * std::numbers::pi / kDefaultEncoderTicksPerRev}
double vel_lpf_alpha {0.5}
double bemf_offset {0.0}
std::optional< PidGains > pid {}
double static_friction_pct {0.0}

Detailed Description

Calibration constants commonly needed for motor encoder conversions.

Definition at line 31 of file motor.hpp.

Constructor & Destructor Documentation

◆ MotorCalibration() [1/2]

libstp::foundation::MotorCalibration::MotorCalibration ( )
default

◆ MotorCalibration() [2/2]

libstp::foundation::MotorCalibration::MotorCalibration ( double ticks_to_rad,
double vel_lpf_alpha,
std::optional< PidGains > pid = std::nullopt,
double bemf_offset = 0.0,
double static_friction_pct = 0.0 )
inline

Definition at line 48 of file motor.hpp.

Member Function Documentation

◆ validate()

void libstp::foundation::MotorCalibration::validate ( ) const
inline

Throws std::invalid_argument if the calibration would silently corrupt odometry. ticks_to_rad must be strictly positive (zero would divide by zero downstream); vel_lpf_alpha is an IIR weight and must lie in [0, 1].

Definition at line 65 of file motor.hpp.

Member Data Documentation

◆ bemf_offset

double libstp::foundation::MotorCalibration::bemf_offset {0.0}

Per-motor BEMF zero-offset (ADC counts) subtracted on the STM32 before integrating ticks, so the tick integral stays proportional to wheel angle. Calibrated by auto_tune_bemf_velocity against the calibration board (0 = no correction).

Definition at line 39 of file motor.hpp.

◆ pid

std::optional<PidGains> libstp::foundation::MotorCalibration::pid {}

Definition at line 40 of file motor.hpp.

◆ static_friction_pct

double libstp::foundation::MotorCalibration::static_friction_pct {0.0}

Static-friction threshold (PWM %): the minimum open-loop duty that overcomes stiction, measured by auto_tune static_friction. Stored as a per-motor calibration record (0 = unmeasured).

Definition at line 44 of file motor.hpp.

◆ ticks_to_rad

double libstp::foundation::MotorCalibration::ticks_to_rad {2.0 * std::numbers::pi / kDefaultEncoderTicksPerRev}

Definition at line 33 of file motor.hpp.

◆ vel_lpf_alpha

double libstp::foundation::MotorCalibration::vel_lpf_alpha {0.5}

Definition at line 34 of file motor.hpp.


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