Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
|
Represents the kinematics of a differential drive. More...
#include <DiffDriveKinematics.h>
Public Types | |
enum class | PreferredVelPreservation { Proportional , PreferXVel , PreferThetaVel } |
Proportional: The xVel and thetaVel are scaled an equal amount. More... | |
Public Member Functions | |
DiffDriveKinematics (double wheelBaseWidth) | |
Create a new DiffDriveKinematics with the given wheel base width. | |
navtypes::pose_t | wheelVelToRobotVel (double lVel, double rVel) const |
Given the left and right wheel velocities, find the robot velocity in the robot's reference frame. | |
wheelvel_t | robotVelToWheelVel (double xVel, double thetaVel) const |
Given the robot velocity in the robot's local reference frame, find the left and right tangential wheel velocities. | |
navtypes::pose_t | getLocalPoseUpdate (const wheelvel_t &wheelVel, double dt) const |
Calculate the pose update in the local reference frame assuming the left and right wheels have constant velocity. | |
navtypes::pose_t | getPoseUpdate (const wheelvel_t &wheelVel, double heading, double dt) const |
Calculate the pose update in the global reference frame (map space) assuming the left and right wheels have constant velocity. | |
navtypes::pose_t | getNextPose (const wheelvel_t &wheelVel, const navtypes::pose_t &pose, double dt) const |
Calculate the next pose of the robot in the global reference frame. | |
navtypes::pose_t | ensureWithinWheelSpeedLimit (PreferredVelPreservation preferred, double xVel, double thetaVel, double maxWheelSpeed) const |
Ensure that the given xVel and thetaVel translate to a wheel speed less than or equal to the max wheel speed. | |
Represents the kinematics of a differential drive.
This class can be used to calculate various velocities and pose updates using the mathematical representation of the drivebase.
|
strong |
Proportional: The xVel and thetaVel are scaled an equal amount.
This keeps the linear and theta velocity at equal proportions to their original values but their output wheel speed is below the max allowed.
PreferXVel: The theta velocity is scaled and the x velocity is maintained. This preserves linear velocity over theta velocity meaning we lose turning ability.
PreferThetaVel: The x velocity is scaled and the theta velocity is maintained. This preserves the ability to rotate the rover by scaling down the linear velocity so that the calculated max wheel speed is below the set max wheel speed allowed.
|
explicit |
Create a new DiffDriveKinematics with the given wheel base width.
wheelBaseWidth | The width of the wheelbase. The units themselves don't matter, as long as you're consistent. |
pose_t kinematics::DiffDriveKinematics::ensureWithinWheelSpeedLimit | ( | PreferredVelPreservation | preferred, |
double | xVel, | ||
double | thetaVel, | ||
double | maxWheelSpeed ) const |
Ensure that the given xVel and thetaVel translate to a wheel speed less than or equal to the max wheel speed.
Scales them if they do not.
preferred | Choose proportional if x velocity and theta velocity should be scaled proportionally to each other, choose PreferXVel if linear velocity is preferred, or choose PreferThetaVel if turning is preferred. |
xVel | The xVel used to calculate the wheel speed |
thetaVel | The theta veloicty used to calculate the wheel speed. |
maxWheelSpeed | The current max possible wheel speed. This is the value that the calculated velocity will be checked against. |
pose_t kinematics::DiffDriveKinematics::getLocalPoseUpdate | ( | const wheelvel_t & | wheelVel, |
double | dt ) const |
Calculate the pose update in the local reference frame assuming the left and right wheels have constant velocity.
wheelVel | The velocities of the wheels. |
dt | The elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time. |
pose_t kinematics::DiffDriveKinematics::getNextPose | ( | const wheelvel_t & | wheelVel, |
const navtypes::pose_t & | pose, | ||
double | dt ) const |
Calculate the next pose of the robot in the global reference frame.
(map space)
wheelVel | The velocities of the wheels. |
pose | The current pose of the robot, in the global reference frame. |
dt | The elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time. |
pose_t kinematics::DiffDriveKinematics::getPoseUpdate | ( | const wheelvel_t & | wheelVel, |
double | heading, | ||
double | dt ) const |
Calculate the pose update in the global reference frame (map space) assuming the left and right wheels have constant velocity.
wheelVel | The velocities of the wheels. |
dt | The elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time. |
wheelvel_t kinematics::DiffDriveKinematics::robotVelToWheelVel | ( | double | xVel, |
double | thetaVel ) const |
Given the robot velocity in the robot's local reference frame, find the left and right tangential wheel velocities.
xVel | The x velocity in the robot's reference frame. |
thetaVel | The rotational velocity around the z-axis. In rad/sec. |
pose_t kinematics::DiffDriveKinematics::wheelVelToRobotVel | ( | double | lVel, |
double | rVel ) const |
Given the left and right wheel velocities, find the robot velocity in the robot's reference frame.
Since this is a non-holonomic drivebase, the y velocity will be 0.
lVel | The tangential velocity of the left wheel. |
rVel | The tangential velocity of the right wheel. |