Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
kinematics::DiffDriveKinematics Class Reference

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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ PreferredVelPreservation

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.

Constructor & Destructor Documentation

◆ DiffDriveKinematics()

kinematics::DiffDriveKinematics::DiffDriveKinematics ( double wheelBaseWidth)
explicit

Create a new DiffDriveKinematics with the given wheel base width.

Parameters
wheelBaseWidthThe width of the wheelbase. The units themselves don't matter, as long as you're consistent.

Member Function Documentation

◆ ensureWithinWheelSpeedLimit()

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.

Parameters
preferredChoose 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.
xVelThe xVel used to calculate the wheel speed
thetaVelThe theta veloicty used to calculate the wheel speed.
maxWheelSpeedThe current max possible wheel speed. This is the value that the calculated velocity will be checked against.

◆ getLocalPoseUpdate()

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.

Parameters
wheelVelThe velocities of the wheels.
dtThe elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time.
Returns
The pose update in the robot's local reference frame.

◆ getNextPose()

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)

Parameters
wheelVelThe velocities of the wheels.
poseThe current pose of the robot, in the global reference frame.
dtThe elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time.
Returns
The next pose of the robot in the global reference frame after having moved at the specified velocity for the specified time.

◆ getPoseUpdate()

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.

Parameters
wheelVelThe velocities of the wheels.
dtThe elapsed time in seconds for which the update is calculated. The robot has been moving at the specified velocity for this much time.
Returns
The pose update in the global reference frame.

◆ robotVelToWheelVel()

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.

Parameters
xVelThe x velocity in the robot's reference frame.
thetaVelThe rotational velocity around the z-axis. In rad/sec.
Returns
Struct with fields lVel and rVel, representing the left and right velocities.

◆ wheelVelToRobotVel()

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.

Parameters
lVelThe tangential velocity of the left wheel.
rVelThe tangential velocity of the right wheel.
Returns
The robot velocity in the form [xVel, yVel, thetaVel] in the robot's local reference frame. thetaVel will be in units rad/sec.

The documentation for this class was generated from the following files: