public class SwerveDrive
extends Drive
This class provides the basic functionality of a swerve drive using class SwerveKinematics.
class SwerveKinematics| Modifier and Type | Class and Description |
|---|---|
static class |
SwerveDrive.SwerveLocalizer
Default localizer for swerve drives based on the drive encoder positions, module orientations, and (optionally) a
heading sensor.
|
| Constructor and Description |
|---|
SwerveDrive(double trackWidth,
double wheelBase)
This class provides the basic functionality of a swerve drive using
class SwerveKinematics. |
SwerveDrive(double trackWidth)
This class provides the basic functionality of a swerve drive using
class SwerveKinematics. |
| Modifier and Type | Method and Description |
|---|---|
double |
getExternalHeading()
Returns the robot's heading in radians as measured by an external sensor (e.g., IMU, gyroscope). Heading is
measured counter-clockwise from the x-axis.
|
Localizer |
getLocalizer()
Localizer used to determine the evolution of
Drive.getPoseEstimate. |
java.util.List<java.lang.Double> |
getModuleOrientations()
Returns the current module orientations in radians. Orientations should exactly match the order in
SwerveDrive.setModuleOrientations. |
double |
getTrackWidth()
lateral distance between pairs of wheels on different sides of the robot
|
double |
getWheelBase()
distance between pairs of wheels on the same side of the robot
|
java.util.List<java.lang.Double> |
getWheelPositions()
Returns the positions of the wheels in linear distance units. Positions should exactly match the ordering in
SwerveDrive.setMotorPowers. |
void |
setLocalizer(Localizer p)
Localizer used to determine the evolution of
Drive.getPoseEstimate. |
void |
setModuleOrientations(double frontLeft,
double rearLeft,
double rearRight,
double frontRight)
Sets the module orientations. All values are in radians.
|
void |
setMotorPowers(double frontLeft,
double rearLeft,
double rearRight,
double frontRight)
Sets the following motor powers (normalized voltages). All arguments are on the interval
[-1.0, 1.0]. |
void |
setVelocity(Pose2d poseVelocity)
Sets the poseVelocity of the robot.
|
getLocalizer, getPoseEstimate, setLocalizer, setPoseEstimate, setVelocity, updatePoseEstimatepublic SwerveDrive(double trackWidth,
double wheelBase)
This class provides the basic functionality of a swerve drive using class SwerveKinematics.
trackWidth - lateral distance between pairs of wheels on different sides of the robotwheelBase - distance between pairs of wheels on the same side of the robottrackWidth - lateral distance between pairs of wheels on different sides of the robotwheelBase - distance between pairs of wheels on the same side of the robotclass SwerveKinematicspublic SwerveDrive(double trackWidth)
This class provides the basic functionality of a swerve drive using class SwerveKinematics.
trackWidth - lateral distance between pairs of wheels on different sides of the robottrackWidth - lateral distance between pairs of wheels on different sides of the robotclass SwerveKinematicspublic Localizer getLocalizer()
Localizer used to determine the evolution of Drive.getPoseEstimate.
Drive.getPoseEstimatepublic void setLocalizer(Localizer p)
Localizer used to determine the evolution of Drive.getPoseEstimate.
Drive.getPoseEstimatepublic void setVelocity(Pose2d poseVelocity)
Sets the poseVelocity of the robot.
public void setMotorPowers(double frontLeft,
double rearLeft,
double rearRight,
double frontRight)
Sets the following motor powers (normalized voltages). All arguments are on the interval [-1.0, 1.0].
public void setModuleOrientations(double frontLeft,
double rearLeft,
double rearRight,
double frontRight)
Sets the module orientations. All values are in radians.
public java.util.List<java.lang.Double> getWheelPositions()
Returns the positions of the wheels in linear distance units. Positions should exactly match the ordering in
SwerveDrive.setMotorPowers.
SwerveDrive.setMotorPowerspublic java.util.List<java.lang.Double> getModuleOrientations()
Returns the current module orientations in radians. Orientations should exactly match the order in
SwerveDrive.setModuleOrientations.
SwerveDrive.setModuleOrientationspublic double getExternalHeading()
Returns the robot's heading in radians as measured by an external sensor (e.g., IMU, gyroscope). Heading is measured counter-clockwise from the x-axis.
public double getTrackWidth()
lateral distance between pairs of wheels on different sides of the robot
public double getWheelBase()
distance between pairs of wheels on the same side of the robot