Package edu.wpi.first.math.kinematics
Class DifferentialDriveKinematics
- java.lang.Object
-
- edu.wpi.first.math.kinematics.DifferentialDriveKinematics
-
public class DifferentialDriveKinematics extends Object
Helper class that converts a chassis velocity (dx and dtheta components) to left and right wheel velocities for a differential drive.Inverse kinematics converts a desired chassis speed into left and right velocity components whereas forward kinematics converts left and right component velocities into a linear and angular chassis speed.
-
-
Field Summary
Fields Modifier and Type Field Description double
trackWidthMeters
-
Constructor Summary
Constructors Constructor Description DifferentialDriveKinematics(double trackWidthMeters)
Constructs a differential drive kinematics object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChassisSpeeds
toChassisSpeeds(DifferentialDriveWheelSpeeds wheelSpeeds)
Returns a chassis speed from left and right component velocities using forward kinematics.DifferentialDriveWheelSpeeds
toWheelSpeeds(ChassisSpeeds chassisSpeeds)
Returns left and right component velocities from a chassis speed using inverse kinematics.
-
-
-
Field Detail
-
trackWidthMeters
public final double trackWidthMeters
-
-
Constructor Detail
-
DifferentialDriveKinematics
public DifferentialDriveKinematics(double trackWidthMeters)
Constructs a differential drive kinematics object.- Parameters:
trackWidthMeters
- The track width of the drivetrain. Theoretically, this is the distance between the left wheels and right wheels. However, the empirical value may be larger than the physical measured value due to scrubbing effects.
-
-
Method Detail
-
toChassisSpeeds
public ChassisSpeeds toChassisSpeeds(DifferentialDriveWheelSpeeds wheelSpeeds)
Returns a chassis speed from left and right component velocities using forward kinematics.- Parameters:
wheelSpeeds
- The left and right velocities.- Returns:
- The chassis speed.
-
toWheelSpeeds
public DifferentialDriveWheelSpeeds toWheelSpeeds(ChassisSpeeds chassisSpeeds)
Returns left and right component velocities from a chassis speed using inverse kinematics.- Parameters:
chassisSpeeds
- The linear and angular (dx and dtheta) components that represent the chassis' speed.- Returns:
- The left and right velocities.
-
-