libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::kinematics::mecanum::MecanumKinematics Class Reference

#include <mecanum.hpp>

Inheritance diagram for libstp::kinematics::mecanum::MecanumKinematics:
[legend]
Collaboration diagram for libstp::kinematics::mecanum::MecanumKinematics:
[legend]

Public Member Functions

 MecanumKinematics (hal::motor::IMotor *front_left_motor, hal::motor::IMotor *front_right_motor, hal::motor::IMotor *back_left_motor, hal::motor::IMotor *back_right_motor, double wheelbase, double trackWidth, double wheelRadius, foundation::VelocityCommandGain velocityCommandGain={})
 ~MecanumKinematics () override=default
std::size_t wheelCount () const override
MotorCommands applyCommand (const foundation::ChassisVelocity &cmd, double dt) override
foundation::ChassisVelocity estimateState () const override
void hardStop () override
bool supportsLateralMotion () const override
void resetEncoders () override
double getWheelRadius () const override
 Get the wheel radius used by this kinematics model.
void setMaxWheelSpeed (double max_wheel_speed)
double getMaxWheelSpeed () const
double maxYawRateForArcRadius (double radius_m, bool) const override
std::vector< hal::motor::IMotor * > getMotors () override
StmOdometryConfig getStmOdometryConfig () override
void setVelocityCommandGains (double gx, double gy, double gw) override
std::array< double, 3 > getVelocityCommandGains () const override
void applyPowerCommand (const foundation::ChassisVelocity &direction, int power_percent) override
Public Member Functions inherited from libstp::kinematics::IKinematics
virtual ~IKinematics ()=default

Detailed Description

Four-wheel mecanum implementation of IKinematics.

The model uses the shared LibSTP body-frame convention: +x forward, +y right, +wz counter-clockwise.

Definition at line 17 of file mecanum.hpp.

Constructor & Destructor Documentation

◆ MecanumKinematics()

libstp::kinematics::mecanum::MecanumKinematics::MecanumKinematics ( hal::motor::IMotor * front_left_motor,
hal::motor::IMotor * front_right_motor,
hal::motor::IMotor * back_left_motor,
hal::motor::IMotor * back_right_motor,
double wheelbase,
double trackWidth,
double wheelRadius,
foundation::VelocityCommandGain velocityCommandGain = {} )
Parameters
front_left_motorNon-owning pointer to the front-left motor.
front_right_motorNon-owning pointer to the front-right motor.
back_left_motorNon-owning pointer to the back-left motor.
back_right_motorNon-owning pointer to the back-right motor.
wheelbaseFront-to-back axle spacing in meters.
trackWidthLeft-to-right wheel spacing in meters.
wheelRadiusRadius of each drive wheel in meters.
velocityCommandGainPer-axis velocity-command gain (identity by default); folded into the STM32 forward kinematics to compensate drivetrain efficiency. Calibrated by the autotune velocity phase.

◆ ~MecanumKinematics()

libstp::kinematics::mecanum::MecanumKinematics::~MecanumKinematics ( )
overridedefault

Member Function Documentation

◆ applyCommand()

MotorCommands libstp::kinematics::mecanum::MecanumKinematics::applyCommand ( const foundation::ChassisVelocity & cmd,
double dt )
overridevirtual

Convert chassis velocity into front-left, front-right, back-left, back-right wheel speeds.

Implements libstp::kinematics::IKinematics.

◆ applyPowerCommand()

void libstp::kinematics::mecanum::MecanumKinematics::applyPowerCommand ( const foundation::ChassisVelocity & direction,
int power_percent )
overridevirtual

Command motors at raw open-loop power using mecanum inverse kinematics for direction.

Implements libstp::kinematics::IKinematics.

◆ estimateState()

foundation::ChassisVelocity libstp::kinematics::mecanum::MecanumKinematics::estimateState ( ) const
nodiscardoverridevirtual

Recover chassis velocity from the four measured wheel speeds.

Implements libstp::kinematics::IKinematics.

◆ getMaxWheelSpeed()

double libstp::kinematics::mecanum::MecanumKinematics::getMaxWheelSpeed ( ) const
inlinenodiscard

Definition at line 81 of file mecanum.hpp.

◆ getMotors()

std::vector< hal::motor::IMotor * > libstp::kinematics::mecanum::MecanumKinematics::getMotors ( )
nodiscardoverridevirtual

Return the underlying motors in front-left, front-right, back-left, back-right order.

Implements libstp::kinematics::IKinematics.

◆ getStmOdometryConfig()

StmOdometryConfig libstp::kinematics::mecanum::MecanumKinematics::getStmOdometryConfig ( )
nodiscardoverridevirtual

◆ getVelocityCommandGains()

std::array< double, 3 > libstp::kinematics::mecanum::MecanumKinematics::getVelocityCommandGains ( ) const
nodiscardoverridevirtual

Reimplemented from libstp::kinematics::IKinematics.

◆ getWheelRadius()

double libstp::kinematics::mecanum::MecanumKinematics::getWheelRadius ( ) const
inlinenodiscardoverridevirtual

Get the wheel radius used by this kinematics model.

Returns
Wheel radius in meters

Implements libstp::kinematics::IKinematics.

Definition at line 77 of file mecanum.hpp.

◆ hardStop()

void libstp::kinematics::mecanum::MecanumKinematics::hardStop ( )
overridevirtual

Brake all four drive motors immediately.

Implements libstp::kinematics::IKinematics.

◆ maxYawRateForArcRadius()

double libstp::kinematics::mecanum::MecanumKinematics::maxYawRateForArcRadius ( double radius_m,
bool  ) const
inlinenodiscardoverridevirtual

Mecanum wheel speed is (|vx| + |vy| + |wz| * (l + w)/2) / r; on an arc (v = omega * radius, one translational axis) the fastest wheel runs at omega * (radius + (l + w)/2) / r — cap omega so it stays inside the wheel-speed limit. Same lever for drive and strafe arcs.

Reimplemented from libstp::kinematics::IKinematics.

Definition at line 89 of file mecanum.hpp.

◆ resetEncoders()

void libstp::kinematics::mecanum::MecanumKinematics::resetEncoders ( )
overridevirtual

Clear encoder history in all four MotorAdapter instances.

Implements libstp::kinematics::IKinematics.

◆ setMaxWheelSpeed()

void libstp::kinematics::mecanum::MecanumKinematics::setMaxWheelSpeed ( double max_wheel_speed)
inline

Set max wheel speed (rad/s) for desaturation. 0 = disabled.

Definition at line 80 of file mecanum.hpp.

◆ setVelocityCommandGains()

void libstp::kinematics::mecanum::MecanumKinematics::setVelocityCommandGains ( double gx,
double gy,
double gw )
overridevirtual

Set/get the per-axis velocity-command gain [vx, vy, wz].

Reimplemented from libstp::kinematics::IKinematics.

◆ supportsLateralMotion()

bool libstp::kinematics::mecanum::MecanumKinematics::supportsLateralMotion ( ) const
nodiscardoverridevirtual

Mecanum drivetrains can command lateral motion directly.

Implements libstp::kinematics::IKinematics.

◆ wheelCount()

std::size_t libstp::kinematics::mecanum::MecanumKinematics::wheelCount ( ) const
nodiscardoverridevirtual

Always returns 4.

Implements libstp::kinematics::IKinematics.


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