Package frc.robot.subsystems.swerve
Class Swerve
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.swerve.Swerve
Swerve Subsystem
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the distance between the speaker and Swervevoid
drive
(Translation2d translation, double rotation, boolean fieldRelative, boolean isOpenLoop) Tele-Op Drive methodGet current Chassis SpeedsGet Field Relative HeadingGet Rotation from the gyroGet Rotation of robot from odometryGet Swerve Module PositionsGet Swerve Module StatesgetPose()
Get Position on field from OdometryGets a list containing all 4 swerve module positionsvoid
periodic()
void
Resets the gyro field relative driving offsetvoid
resetOdometry
(Pose2d pose) Set the position on the field with given Pose2dvoid
setModuleStates
(ChassisSpeeds chassisSpeeds) Sets swerve module states using Chassis Speeds.void
setModuleStates
(SwerveModuleState[] desiredStates) Set Swerve Module Statesvoid
Sets motors to 0 or inactive.static boolean
Determine whether or not to flight the auto pathvoid
wheelsIn()
Make an X pattern with the wheelsMethods 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
-
swerveOdometry
-
swerveMods
-
-
Constructor Details
-
Swerve
Swerve Subsystem
-
-
Method Details
-
drive
public void drive(Translation2d translation, double rotation, boolean fieldRelative, boolean isOpenLoop) Tele-Op Drive method- Parameters:
translation
- The magnitude in XYrotation
- The magnitude in rotationfieldRelative
- Whether or not field relativeisOpenLoop
- Whether or not Open or Closed Loop
-
setModuleStates
Set Swerve Module States- Parameters:
desiredStates
- Array of desired states
-
setModuleStates
Sets swerve module states using Chassis Speeds.- Parameters:
chassisSpeeds
- The desired Chassis Speeds
-
getChassisSpeeds
Get current Chassis Speeds- Returns:
- The current
ChassisSpeeds
-
getModuleStates
Get Swerve Module States- Returns:
- Array of Swerve Module States
-
getModulePositions
Get Swerve Module Positions- Returns:
- Array of Swerve Module Positions
-
getPose
Get Position on field from Odometry- Returns:
- Pose2d on the field
-
resetOdometry
Set the position on the field with given Pose2d- Parameters:
pose
- Pose2d to set
-
getHeading
Get Rotation of robot from odometry- Returns:
- Heading of robot relative to the field as
Rotation2d
-
getGyroYaw
Get Rotation from the gyro- Returns:
- Current rotation/yaw of gyro as
Rotation2d
-
getFieldRelativeHeading
Get Field Relative Heading- Returns:
- The current field relative heading in
Rotation2d
-
resetFieldRelativeOffset
public void resetFieldRelativeOffset()Resets the gyro field relative driving offset -
periodic
public void periodic() -
setMotorsZero
public void setMotorsZero()Sets motors to 0 or inactive. -
wheelsIn
public void wheelsIn()Make an X pattern with the wheels -
getSwerveModulePositions
Gets a list containing all 4 swerve module positions -
shouldFlipPath
public static boolean shouldFlipPath()Determine whether or not to flight the auto path- Returns:
- True if flip path to Red Alliance, False if Blue
-
distanceFromSpeaker
public double distanceFromSpeaker()Returns the distance between the speaker and Swerve- Returns:
- the difference between the pose of speaker and swerve
-