Swerve Drive
Swerve drive subsystem managing four swerve modules and odometry.
This subsystem handles:
Swerve drive kinematics and control
Pose estimation with vision integration
Field-oriented and robot-oriented driving
Gyroscope integration
Usage Example:
val drive = SwerveDrive(
gyroId = 0,
frontLeftModule = SwerveModule(1, 2, 3, Rotation2d.fromDegrees(0.0)),
frontRightModule = SwerveModule(4, 5, 6, Rotation2d.fromDegrees(90.0)),
backLeftModule = SwerveModule(7, 8, 9, Rotation2d.fromDegrees(180.0)),
backRightModule = SwerveModule(10, 11, 12, Rotation2d.fromDegrees(270.0))
)
drive.configure {
trackWidthMeters = 0.6
wheelBaseMeters = 0.6
maxLinearVelocityMPS = 4.5
maxAngularVelocityRadPS = 2.0 * PI
}
// Drive field-oriented
drive.drive(
xSpeed = 1.0,
ySpeed = 0.5,
rotSpeed = 0.2,
fieldOriented = true
)Constructors
Types
Configuration for the swerve drive.
Functions
Adds a vision measurement to the pose estimator.
Creates an AlignToTarget command for this swerve drive.
Configures the swerve drive using a DSL-style configuration block.
Creates a command to drive with joystick inputs.
Creates a drive to angle command with DSL configuration.
Creates a command to drive to a specific pose using PathPlanner.
Gets the current chassis speeds.
Gets the current rotation from the gyroscope.
Gets the maximum angular velocity.
Gets the maximum angular velocity in radians per second.
Gets the maximum linear velocity.
Gets the maximum linear velocity in meters per second.
Gets the current positions of all modules.
Gets the current states of all modules.
Extension to easily integrate a vision system with a swerve drive.
Creates a lock swerve command.
Creates a reset gyro command.
Creates a ResetPoseFromVision command for this swerve drive.
Sets the desired states for all modules.
Creates a teleop swerve command with DSL configuration.
Creates a TrackTarget command for this swerve drive.
Creates a turn to angle command with DSL configuration.