|
libstp
Robotics library for Botball
|
#include <kinematics.hpp>
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 |
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.
|
virtualdefault |
|
pure virtual |
Apply a chassis-space velocity command.
| cmd | Desired body-frame velocity using the shared vx, vy, wz convention from foundation::ChassisVelocity. |
| dt | Control-loop time step in seconds. |
Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.
|
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.
| direction | Desired chassis-space motion direction. Only the ratios between vx, vy, and wz matter; the magnitude is normalized away. |
| power_percent | Motor 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.
|
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.
|
nodiscardpure virtual |
Get pointers to all drive motors managed by this kinematics model.
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.
|
nodiscardpure virtual |
|
inlinenodiscardvirtual |
Reimplemented in libstp::kinematics::mecanum::MecanumKinematics.
Definition at line 149 of file kinematics.hpp.
|
nodiscardpure virtual |
Get the wheel radius used by this kinematics model.
Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.
|
pure virtual |
Immediately brake or otherwise stop all managed wheels.
Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.
|
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.
|
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.
|
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.
|
nodiscardpure virtual |
Query whether this kinematics model supports direct lateral (vy) motion.
Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.
|
nodiscardpure virtual |
Return the number of drive wheels modeled by this instance.
Implemented in libstp::kinematics::differential::DifferentialKinematics, and libstp::kinematics::mecanum::MecanumKinematics.