core / com.acmerobotics.roadrunner.drive / SwerveDrive

SwerveDrive

abstract class SwerveDrive : Drive

This class provides the basic functionality of a swerve drive using SwerveKinematics.

Parameters

trackWidth - lateral distance between pairs of wheels on different sides of the robot

wheelBase - distance between pairs of wheels on the same side of the robot

Types

SwerveLocalizer

class SwerveLocalizer : Localizer

Default localizer for swerve drives based on the drive encoder positions, module orientations, and (optionally) a heading sensor.

Constructors

<init>

SwerveDrive(trackWidth: Double, wheelBase: Double = trackWidth, clock: NanoClock = NanoClock.system())

This class provides the basic functionality of a swerve drive using SwerveKinematics.

Properties

localizer

open var localizer: Localizer

Localizer used to determine the evolution of poseEstimate.

trackWidth

val trackWidth: Double

lateral distance between pairs of wheels on different sides of the robot

wheelBase

val wheelBase: Double

distance between pairs of wheels on the same side of the robot

Inherited Properties

poseEstimate

var poseEstimate: Pose2d

The robot's current pose estimate.

Functions

getExternalHeading

abstract fun getExternalHeading(): Double

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.

getModuleOrientations

abstract fun getModuleOrientations(): List<Double>

Returns the current module orientations in radians. Orientations should exactly match the order in setModuleOrientations.

getWheelPositions

abstract fun getWheelPositions(): List<Double>

Returns the positions of the wheels in linear distance units. Positions should exactly match the ordering in setMotorPowers.

setModuleOrientations

abstract fun setModuleOrientations(frontLeft: Double, rearLeft: Double, rearRight: Double, frontRight: Double): Unit

Sets the module orientations. All values are in radians.

setMotorPowers

abstract fun setMotorPowers(frontLeft: Double, rearLeft: Double, rearRight: Double, frontRight: Double): Unit

Sets the following motor powers (normalized voltages). All arguments are on the interval [-1.0, 1.0].

setVelocity

open fun setVelocity(poseVelocity: Pose2d): Unit

Sets the poseVelocity of the robot.

Inherited Functions

updatePoseEstimate

fun updatePoseEstimate(): Unit

Updates poseEstimate with the most recent positional change.