libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::drive::Drive Class Referencefinal

#include <drive.hpp>

Public Member Functions

 Drive (std::unique_ptr< kinematics::IKinematics > kinematics, const ChassisVelocityControlConfig &vel_config, hal::imu::IIMU &imu)
void setVelocity (const foundation::ChassisVelocity &v_body)
kinematics::MotorCommands update (double dt)
foundation::ChassisVelocity estimateState () const
std::size_t wheelCount () const
void softStop ()
void hardStop ()
void setVelocityControlConfig (const ChassisVelocityControlConfig &config)
const ChassisVelocityControlConfig & getVelocityControlConfig () const
void resetVelocityControllers ()
kinematics::IKinematics & getKinematics ()
const kinematics::IKinematics & getKinematics () const
double getWheelRadius () const
std::vector< hal::motor::IMotor * > getMotors ()
hal::imu::IIMU & getImu ()
const hal::imu::IIMU & getImu () const
void applyPowerCommand (const foundation::ChassisVelocity &direction, int power_percent)

Detailed Description

Chassis-space drive controller.

Drive closes the loop on desired body velocity by combining feedback from a kinematics model and an IMU, then forwarding corrected commands to the drivetrain-specific IKinematics implementation.

Definition at line 35 of file drive.hpp.

Constructor & Destructor Documentation

◆ Drive()

libstp::drive::Drive::Drive ( std::unique_ptr< kinematics::IKinematics > kinematics,
const ChassisVelocityControlConfig & vel_config,
hal::imu::IIMU & imu )
Parameters
kinematicsOwned drivetrain kinematics implementation.
vel_configInitial per-axis velocity-controller gains.
imuIMU used for yaw-rate feedback.

Member Function Documentation

◆ applyPowerCommand()

void libstp::drive::Drive::applyPowerCommand ( const foundation::ChassisVelocity & direction,
int power_percent )
inline

Convenience wrapper around IKinematics::applyPowerCommand().

Definition at line 88 of file drive.hpp.

◆ estimateState()

foundation::ChassisVelocity libstp::drive::Drive::estimateState ( ) const
nodiscard

Estimate current body-frame velocity using kinematics plus the last IMU yaw rate.

◆ getImu() [1/2]

hal::imu::IIMU & libstp::drive::Drive::getImu ( )
inlinenodiscard

Access the IMU passed in at construction. Used by tuners that need raw IMU telemetry (gyro, accel) for offline analysis.

Definition at line 84 of file drive.hpp.

◆ getImu() [2/2]

const hal::imu::IIMU & libstp::drive::Drive::getImu ( ) const
inlinenodiscard

Definition at line 85 of file drive.hpp.

◆ getKinematics() [1/2]

kinematics::IKinematics & libstp::drive::Drive::getKinematics ( )
inlinenodiscard

Access the owned kinematics implementation for advanced integration.

Definition at line 73 of file drive.hpp.

◆ getKinematics() [2/2]

const kinematics::IKinematics & libstp::drive::Drive::getKinematics ( ) const
inlinenodiscard

Definition at line 74 of file drive.hpp.

◆ getMotors()

std::vector< hal::motor::IMotor * > libstp::drive::Drive::getMotors ( )
inlinenodiscard

Convenience wrapper around IKinematics::getMotors().

Definition at line 80 of file drive.hpp.

◆ getVelocityControlConfig()

const ChassisVelocityControlConfig & libstp::drive::Drive::getVelocityControlConfig ( ) const
inlinenodiscard

Definition at line 67 of file drive.hpp.

◆ getWheelRadius()

double libstp::drive::Drive::getWheelRadius ( ) const
inlinenodiscard

Convenience wrapper around IKinematics::getWheelRadius().

Definition at line 77 of file drive.hpp.

◆ hardStop()

void libstp::drive::Drive::hardStop ( )

Immediately clear controller state and brake the drivetrain.

◆ resetVelocityControllers()

void libstp::drive::Drive::resetVelocityControllers ( )

Clear integrator and derivative history in all three velocity controllers.

◆ setVelocity()

void libstp::drive::Drive::setVelocity ( const foundation::ChassisVelocity & v_body)

Set the desired body-frame velocity for the next control update.

◆ setVelocityControlConfig()

void libstp::drive::Drive::setVelocityControlConfig ( const ChassisVelocityControlConfig & config)

Replace the per-axis velocity-control settings and rebuild the controllers.

◆ softStop()

void libstp::drive::Drive::softStop ( )

Request a controlled stop by zeroing the desired velocity.

◆ update()

kinematics::MotorCommands libstp::drive::Drive::update ( double dt)

Run one chassis velocity control step and send the corrected command to kinematics.

◆ wheelCount()

std::size_t libstp::drive::Drive::wheelCount ( ) const
nodiscard

Forward the modeled wheel count from the underlying kinematics.


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