Package frc.RebeLib.subsystems.drive
Class Drive
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.RebeLib.subsystems.drive.Drive
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
,edu.wpi.first.wpilibj2.command.Subsystem
public class Drive
extends edu.wpi.first.wpilibj2.command.SubsystemBase
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVisionMeasurement
(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3, edu.wpi.first.math.numbers.N1> visionMeasurementStdDevs) Adds a new timestamped vision measurement.double
Returns the average velocity of the modules in rotations/sec (Phoenix native units).double
Returns the maximum angular speed in radians per sec.double
Returns the maximum linear speed in meters per sec.static edu.wpi.first.math.geometry.Translation2d[]
Returns an array of module translations.edu.wpi.first.math.geometry.Pose2d
getPose()
Returns the current odometry pose.edu.wpi.first.math.geometry.Rotation2d
Returns the current odometry rotation.double[]
Returns the position of each module in radians.void
periodic()
void
runCharacterization
(double output) Runs the drive in a straight line with the specified drive output.void
runVelocity
(edu.wpi.first.math.kinematics.ChassisSpeeds speeds) Runs the drive at the desired velocity.void
setPose
(edu.wpi.first.math.geometry.Pose2d pose) Resets the current odometry pose.void
stop()
Stops the drive.void
Stops the drive and turns the modules to an X arrangement to resist movement.edu.wpi.first.wpilibj2.command.Command
sysIdDynamic
(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Returns a command to run a dynamic test in the specified direction.edu.wpi.first.wpilibj2.command.Command
sysIdQuasistatic
(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Returns a command to run a quasistatic test in the specified direction.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Field Details
-
DRIVE_BASE_RADIUS
public static final double DRIVE_BASE_RADIUS
-
-
Constructor Details
-
Drive
-
-
Method Details
-
periodic
public void periodic() -
runVelocity
public void runVelocity(edu.wpi.first.math.kinematics.ChassisSpeeds speeds) Runs the drive at the desired velocity.- Parameters:
speeds
- Speeds in meters/sec
-
runCharacterization
public void runCharacterization(double output) Runs the drive in a straight line with the specified drive output. -
stop
public void stop()Stops the drive. -
stopWithX
public void stopWithX()Stops the drive and turns the modules to an X arrangement to resist movement. The modules will return to their normal orientations the next time a nonzero velocity is requested. -
sysIdQuasistatic
public edu.wpi.first.wpilibj2.command.Command sysIdQuasistatic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Returns a command to run a quasistatic test in the specified direction. -
sysIdDynamic
public edu.wpi.first.wpilibj2.command.Command sysIdDynamic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction) Returns a command to run a dynamic test in the specified direction. -
getWheelRadiusCharacterizationPositions
public double[] getWheelRadiusCharacterizationPositions()Returns the position of each module in radians. -
getFFCharacterizationVelocity
public double getFFCharacterizationVelocity()Returns the average velocity of the modules in rotations/sec (Phoenix native units). -
getPose
public edu.wpi.first.math.geometry.Pose2d getPose()Returns the current odometry pose. -
getRotation
public edu.wpi.first.math.geometry.Rotation2d getRotation()Returns the current odometry rotation. -
setPose
public void setPose(edu.wpi.first.math.geometry.Pose2d pose) Resets the current odometry pose. -
addVisionMeasurement
public void addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3, edu.wpi.first.math.numbers.N1> visionMeasurementStdDevs) Adds a new timestamped vision measurement. -
getMaxLinearSpeedMetersPerSec
public double getMaxLinearSpeedMetersPerSec()Returns the maximum linear speed in meters per sec. -
getMaxAngularSpeedRadPerSec
public double getMaxAngularSpeedRadPerSec()Returns the maximum angular speed in radians per sec. -
getModuleTranslations
public static edu.wpi.first.math.geometry.Translation2d[] getModuleTranslations()Returns an array of module translations.
-