libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::kinematics::IKinematics Struct Referenceabstract

#include <kinematics.hpp>

Inheritance diagram for libstp::kinematics::IKinematics:
[legend]

Classes

struct  StmOdometryConfig

Public Member Functions

virtual ~IKinematics ()=default
virtual std::size_t wheelCount () const =0
virtual double maxYawRateForArcRadius (double, bool) const
virtual MotorCommands applyCommand (const foundation::ChassisVelocity &cmd, double dt)=0
virtual foundation::ChassisVelocity estimateState () const =0
virtual void hardStop ()=0
virtual bool supportsLateralMotion () const =0
 Query whether this kinematics model supports direct lateral (vy) motion.
virtual void resetEncoders ()=0
 Reset encoder/BEMF counters to prepare for new odometry origin.
virtual double getWheelRadius () const =0
 Get the wheel radius used by this kinematics model.
virtual std::vector< hal::motor::IMotor * > getMotors ()=0
 Get pointers to all drive motors managed by this kinematics model.
virtual StmOdometryConfig getStmOdometryConfig ()=0
virtual void setVelocityCommandGains (double, double, double)
virtual std::array< double, 3 > getVelocityCommandGains () const
virtual void applyPowerCommand (const foundation::ChassisVelocity &direction, int power_percent)=0

Detailed Description

Abstract drivetrain kinematics contract.

Implementations own the mapping between chassis-space velocity commands and the wheel-space commands understood by a specific drivetrain layout. They also provide encoder-based chassis velocity estimation for drive control and odometry.

Definition at line 34 of file kinematics.hpp.

Constructor & Destructor Documentation

◆ ~IKinematics()

virtual libstp::kinematics::IKinematics::~IKinematics ( )
virtualdefault

Member Function Documentation

◆ applyCommand()

virtual MotorCommands libstp::kinematics::IKinematics::applyCommand ( const foundation::ChassisVelocity & cmd,
double dt )
pure virtual

Apply a chassis-space velocity command.

Parameters
cmdDesired body-frame velocity using the shared vx, vy, wz convention from foundation::ChassisVelocity.
dtControl-loop time step in seconds.
Returns
Per-wheel command data produced by the model.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ applyPowerCommand()

virtual void libstp::kinematics::IKinematics::applyPowerCommand ( const foundation::ChassisVelocity & direction,
int power_percent )
pure virtual

Command motors at raw open-loop power using the inverse kinematics to determine per-wheel direction signs.

The direction vector is passed through the same inverse kinematics as applyCommand, but instead of converting to velocity targets, the resulting wheel speed ratios are normalized so the largest wheel receives exactly power_percent and every other wheel is scaled proportionally. Each motor is then driven via setSpeed() (raw PWM).

This bypasses all firmware velocity PID and library velocity control, giving direct open-loop access to the motors while still respecting the drivetrain geometry.

Parameters
directionDesired chassis-space motion direction. Only the ratios between vx, vy, and wz matter; the magnitude is normalized away.
power_percentMotor power from -100 to 100. Sign is combined with the direction to determine final per-wheel sign.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ estimateState()

virtual foundation::ChassisVelocity libstp::kinematics::IKinematics::estimateState ( ) const
nodiscardpure virtual

Estimate the current chassis-space velocity from motor feedback.

The returned value stays in the body frame. World-frame integration is handled by odometry modules.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ getMotors()

virtual std::vector< hal::motor::IMotor * > libstp::kinematics::IKinematics::getMotors ( )
nodiscardpure virtual

Get pointers to all drive motors managed by this kinematics model.

Returns
Vector of motor pointers (non-owning)

Non-const because the returned pointers are used to command motors, which is a write through the kinematics. A const Kinematics& cannot hand out mutating handles.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ getStmOdometryConfig()

virtual StmOdometryConfig libstp::kinematics::IKinematics::getStmOdometryConfig ( )
nodiscardpure virtual

◆ getVelocityCommandGains()

virtual std::array< double, 3 > libstp::kinematics::IKinematics::getVelocityCommandGains ( ) const
inlinenodiscardvirtual

Reimplemented in libstp::kinematics::mecanum::MecanumKinematics.

Definition at line 149 of file kinematics.hpp.

◆ getWheelRadius()

virtual double libstp::kinematics::IKinematics::getWheelRadius ( ) const
nodiscardpure virtual

Get the wheel radius used by this kinematics model.

Returns
Wheel radius in meters

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ hardStop()

virtual void libstp::kinematics::IKinematics::hardStop ( )
pure virtual

Immediately brake or otherwise stop all managed wheels.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ maxYawRateForArcRadius()

virtual double libstp::kinematics::IKinematics::maxYawRateForArcRadius ( double ,
bool  ) const
inlinenodiscardvirtual

Max sustainable |yaw rate| (rad/s) while tracing an arc of radius_m, such that EVERY wheel stays inside the configured max wheel speed. On an arc the outer wheel travels faster than the chassis centre (omega * (radius + lever)), so capping only the centre speed over-commands the outer wheel — the drivetrain saturates, the commanded differential collapses and the arc turns far slower than commanded.

lateral selects the strafe-arc geometry on holonomic bases. Default: no coupling (infinity) — models without a wheel-speed limit keep the caller's own caps.

Reimplemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

Definition at line 54 of file kinematics.hpp.

◆ resetEncoders()

virtual void libstp::kinematics::IKinematics::resetEncoders ( )
pure virtual

Reset encoder/BEMF counters to prepare for new odometry origin.

This should be called when odometry is reset to prevent stale counter values from causing incorrect velocity/position estimates in the next update cycle.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ setVelocityCommandGains()

virtual void libstp::kinematics::IKinematics::setVelocityCommandGains ( double ,
double ,
double  )
inlinevirtual

Per-axis velocity-command gain [vx, vy, wz].

Multiplies the forward-kinematics (chassis→wheel) coefficients so a commanded body velocity produces a proportionally larger wheel setpoint. This compensates for drivetrain efficiency that the ideal geometry does not model — most notably mecanum roller slip, where the wheels track their BEMF setpoint correctly yet the chassis travels less than the kinematics predict. Calibrated by the autotune velocity phase against an external ground-truth (calib board) so commanded == achieved. Default 1.0 (no correction). Applied in getStmOdometryConfig() so it is pushed to the coprocessor.

Reimplemented in libstp::kinematics::mecanum::MecanumKinematics.

Definition at line 148 of file kinematics.hpp.

◆ supportsLateralMotion()

virtual bool libstp::kinematics::IKinematics::supportsLateralMotion ( ) const
nodiscardpure virtual

Query whether this kinematics model supports direct lateral (vy) motion.

Returns
true if the robot can strafe sideways (e.g., mecanum, omni wheels) false if lateral motion requires rotation (e.g., differential drive)

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.

◆ wheelCount()

virtual std::size_t libstp::kinematics::IKinematics::wheelCount ( ) const
nodiscardpure virtual

Return the number of drive wheels modeled by this instance.

Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.


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