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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrive(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 OdometryfloatgetRoll()Gets the roll (pitch) degree from swerve modules.voidperiodic()voidResets the gyro field relative driving offsetvoidReset April Tag position initializationvoidReset all modules to their front facing positionvoidresetOdometry(Pose2d pose) Set the position on the field with given Pose2dvoidsetModuleStates(ChassisSpeeds chassisSpeeds) Sets swerve module states using Chassis Speeds.voidsetModuleStates(SwerveModuleState[] desiredStates) Set Swerve Module StatesvoidSets motors to 0 or inactive.booleanDetermine whether or not to flight the auto pathvoidwheelsIn()Make an X pattern with the wheelsvoidzeroGyro()Zero the GyroMethods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd
-
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
-
getRoll
public float getRoll()Gets the roll (pitch) degree from swerve modules. -
getFieldRelativeHeading
Get Field Relative Heading- Returns:
- The current field relative heading in
Rotation2d
-
resetFieldRelativeOffset
public void resetFieldRelativeOffset()Resets the gyro field relative driving offset -
resetModulesToAbsolute
public void resetModulesToAbsolute()Reset all modules to their front facing position -
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 -
shouldFlipPath
public boolean shouldFlipPath()Determine whether or not to flight the auto path- Returns:
- True if flip path to Red Alliance, False if Blue
-
resetInitialized
public void resetInitialized()Reset April Tag position initialization -
zeroGyro
public void zeroGyro()Zero the Gyro
-