core / com.acmerobotics.roadrunner.drive / SwerveDrive

SwerveDrive

abstract class SwerveDrive : Drive (source)

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

Parameters

kV - velocity feedforward

kA - acceleration feedforward

kStatic - additive constant feedforward

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

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

class SwerveLocalizer : Localizer

Constructors

<init>

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

SwerveDrive(kV: Double, kA: Double, kStatic: Double, trackWidth: Double, wheelBase: Double = trackWidth)

Properties

localizer

Localizer used to determine the evolution of poseEstimate.

open var localizer: Localizer

Functions

getModuleOrientations

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

abstract fun getModuleOrientations(): List<Double>

getWheelPositions

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

abstract fun getWheelPositions(): List<Double>

getWheelVelocities

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

open fun getWheelVelocities(): List<Double>?

setDrivePower

Sets the current commanded drive state of the robot. Feedforward is not applied to drivePower.

open fun setDrivePower(drivePower: Pose2d): Unit

setDriveSignal

Sets the current commanded drive state of the robot. Feedforward is applied to driveSignal before it reaches the motors.

open fun setDriveSignal(driveSignal: DriveSignal): Unit

setModuleOrientations

Sets the module orientations. All values are in radians.

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

setMotorPowers

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

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