Package frc.robot.systems
Class DriveFSMSystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.systems.DriveFSMSystem
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
,edu.wpi.first.wpilibj2.command.Subsystem
public class DriveFSMSystem
extends edu.wpi.first.wpilibj2.command.SubsystemBase
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for DriveFSMSystem.DriveFSMSystem
(ElevatorFSMSystem elevatorFSMSystem) Create DriveFSMSystem and initialize to starting state. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.Command
alignToTagCommand
(int id, double x, double y) Command to align to any visible reef tags or not move if none are seen.edu.wpi.first.wpilibj2.command.Command
Returns a command that sets the drivetrain to brake mode.boolean
Checks if the robot can see the tag.choreo.auto.AutoFactory
Configures Auto Builder for pathfinding.boolean
driveToPose
(edu.wpi.first.math.geometry.Pose2d target, boolean allianceFlip) Drive to pose function.Return current FSM state.Get the maple-Sim Swerve simulation.void
handleOverrideState
(TeleopInput input) Handles the override state based on the given input.void
Handles reef tag alignment by seeing the nearest reef tag.void
Handles station tag alignment by aligning with the nearest station tag.boolean
Gets robot alignment status (for LEDs).void
reset()
Reset this system to its start state.void
Sets the current state of the FSM.void
update
(TeleopInput input) Update FSM based on new inputs.void
Performs specific action based on the autoState passed in.void
updates drivetrain logging.void
Update the raspberry pi simulation state.void
Update vision measurements according to all seen tags.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, periodic, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
DriveFSMSystem
Create DriveFSMSystem and initialize to starting state. Also perform any one-time initialization or configuration of hardware required. Note the constructor is called only once when the robot boots.- Parameters:
elevatorFSMSystem
- The ElevatorFSMSystem instance to be used by this system.
-
DriveFSMSystem
public DriveFSMSystem()Default constructor for DriveFSMSystem.
-
-
Method Details
-
getCurrentState
Return current FSM state.- Returns:
- Current FSM state
-
reset
public void reset()Reset this system to its start state. This may be called from mode init when the robot is enabled. Note this is distinct from the one-time initialization in the constructor as it may be called multiple times in a boot cycle, Ex. if the robot is enabled, disabled, then reenabled. -
update
Update FSM based on new inputs. This function only calls the FSM state specific handlers.- Parameters:
input
- Global TeleopInput if robot in teleop mode or null if the robot is in autonomous mode.
-
handleOverrideState
Handles the override state based on the given input.- Parameters:
input
- The TeleopInput instance containing the current input state.
-
canSeeTag
public boolean canSeeTag()Checks if the robot can see the tag.- Returns:
- true if the robot can see the tag, false otherwise.
-
updateAutonomous
public void updateAutonomous()Performs specific action based on the autoState passed in. -
configureAutoSettings
public choreo.auto.AutoFactory configureAutoSettings()Configures Auto Builder for pathfinding.- Returns:
- An AutoFactory instance for creating autonomous routines.
-
isAlignedToTag
public boolean isAlignedToTag()Gets robot alignment status (for LEDs).- Returns:
- Whether the robot is aligned to the target apriltag.
-
setState
Sets the current state of the FSM.- Parameters:
state
- The new state to set.
-
updateVisionEstimates
public void updateVisionEstimates()Update vision measurements according to all seen tags. -
updateLogging
public void updateLogging()updates drivetrain logging. -
driveToPose
public boolean driveToPose(edu.wpi.first.math.geometry.Pose2d target, boolean allianceFlip) Drive to pose function.- Parameters:
target
- target pose to align to.allianceFlip
- whether to incorporate an alliance multiplier in alignment directions.- Returns:
- whether or not driving is completed.
-
handleReefTagAlignment
Handles reef tag alignment by seeing the nearest reef tag.- Parameters:
input
-
-
handleStationTagAlignment
Handles station tag alignment by aligning with the nearest station tag.- Parameters:
input
-
-
brakeCommand
public edu.wpi.first.wpilibj2.command.Command brakeCommand()Returns a command that sets the drivetrain to brake mode.- Returns:
- A command that sets the drivetrain to brake mode.
-
alignToTagCommand
public edu.wpi.first.wpilibj2.command.Command alignToTagCommand(int id, double x, double y) Command to align to any visible reef tags or not move if none are seen.- Parameters:
id
- the id of the tag to align tox
-y
-- Returns:
- align to tag command.
-
getMapleSimDrivetrain
Get the maple-Sim Swerve simulation.- Returns:
- the simulation
-
updateRaspberryPi
public void updateRaspberryPi()Update the raspberry pi simulation state.
-