Controller to handle the wheel rotations for driving with swerve modes.
More...
#include <SwerveController.h>
|
| SwerveController (double baseWidth, double baseLength, int epsilon) |
| Construct a new controller object.
|
|
drive_commands_t | setTurnInPlaceCmdVel (double dtheta, const swerve_rots_t &wheel_rots) const |
| Request the robot to turn in place using swerve.
|
|
drive_commands_t | setTurnInPlaceCmdVel (double dtheta, const swerve_rots_t &wheel_rots, double &scaleFactor) const |
| Request the robot to turn in place using swerve.
|
|
drive_commands_t | setCrabCmdVel (double dtheta, double dy, const swerve_rots_t &wheel_rots) const |
| Request the robot to drive side to side and turn with given velocities using swerve.
|
|
drive_commands_t | setCrabCmdVel (double dtheta, double dy, const swerve_rots_t &wheel_rots, double &scaleFactor) const |
| Request the robot to drive side to side and turn with given velocities using swerve.
|
|
const kinematics::SwerveDriveKinematics & | swerveKinematics () const |
| Get the SwerveDriveKinematics object used by the controller.
|
|
void | setOverride (bool override) |
| Set the override flag for wheel rotation checking.
|
|
bool | isOverridden () const |
| Check the override flag for wheel rotation checking.
|
|
DriveMode | getDriveMode () const |
| Get the current drive mode of the controller.
|
|
swerve_rots_t | setDriveMode (DriveMode mode) |
| Set the drive mode of the controller.
|
|
bool | checkWheelRotation (DriveMode mode, const swerve_rots_t &wheel_rots) const |
| Check to see if all wheels are at their target position.
|
|
swerve_rots_t | getSteerRots (DriveMode mode) const |
| Get the wheel steer rotations for a given drive mode in millidegrees.
|
|
Controller to handle the wheel rotations for driving with swerve modes.
◆ SwerveController()
control::SwerveController::SwerveController |
( |
double | baseWidth, |
|
|
double | baseLength, |
|
|
int | epsilon ) |
Construct a new controller object.
- Parameters
-
baseWidth | The width of the wheelbase. The units themselves don't matter, as long as you're consistent. |
baseLength | The length of the wheelbase. The units themselves don't matter, as long as you're consistent. |
epsilon | The allowable error from the actual wheel rotation to the wheel rotations defined by DRIVE_MODE to process a drive request |
◆ checkWheelRotation()
bool SwerveController::checkWheelRotation |
( |
DriveMode | mode, |
|
|
const swerve_rots_t & | wheel_rots ) const |
Check to see if all wheels are at their target position.
- Parameters
-
mode | The drive mode to compare wheel rotations against. |
wheel_rots | The rotation of all four wheels in millidegrees |
- Returns
- bool if the wheels are within
STEER_EPSILON
of their target position OR if overide_steer_check
is true.
◆ getDriveMode()
DriveMode SwerveController::getDriveMode |
( |
| ) |
const |
Get the current drive mode of the controller.
- Returns
- DriveMode The current drive mode.
◆ isOverridden()
bool SwerveController::isOverridden |
( |
| ) |
const |
Check the override flag for wheel rotation checking.
- Returns
- True iff the rotation checking is overridden.
◆ setCrabCmdVel() [1/2]
Request the robot to drive side to side and turn with given velocities using swerve.
Essentially rotate the reference frame of the robot by 90 degrees CCW.
- Parameters
-
dtheta | The heading velocity. |
dy | The side-to-side velocity. |
wheel_rots | The rotation of all four wheels in millidegrees |
- Returns
- drive_commands_t The power commands for all four wheels.
◆ setCrabCmdVel() [2/2]
Request the robot to drive side to side and turn with given velocities using swerve.
Essentially rotate the reference frame of the robot by 90 degrees CCW.
- Parameters
-
dtheta | The heading velocity. |
dy | The side-to-side velocity. |
wheel_rots | The rotation of all four wheels in millidegrees |
scaleFactor | This is an output parameter. If the requested velocities are too high, they will be scaled down. The returned value is the scale divisor. If no scaling was performed, 1 is returned. |
- Returns
- drive_commands_t The power commands for all four wheels.
◆ setDriveMode()
Set the drive mode of the controller.
- Parameters
-
mode | The new drive mode to set. |
- Returns
- swerve_rots_t The wheel steer rotations associated with this drive mode.
◆ setOverride()
void SwerveController::setOverride |
( |
bool | override | ) |
|
Set the override flag for wheel rotation checking.
When set to true, the checkWheelRotation function will always return true, bypassing the wheel rotation check.
- Parameters
-
override | Override the wheel rotation check. |
◆ setTurnInPlaceCmdVel() [1/2]
Request the robot to turn in place using swerve.
- Parameters
-
dtheta | The heading velocity. |
wheel_rots | The rotation of all four wheels in millidegrees |
- Returns
- drive_commands_t The power commands for all four wheels.
◆ setTurnInPlaceCmdVel() [2/2]
Request the robot to turn in place using swerve.
- Parameters
-
dtheta | The heading velocity. |
wheel_rots | The rotation of all four wheels in millidegrees |
scaleFactor | This is an output parameter. If the requested velocities are too high, they will be scaled down. The returned value is the scale divisor. If no scaling was performed, 1 is returned. |
- Returns
- drive_commands_t The power commands for all four wheels.
◆ swerveKinematics()
The documentation for this class was generated from the following files: