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
  • Constructor Details

    • DriveFSMSystem

      public DriveFSMSystem(ElevatorFSMSystem elevatorFSMSystem)
      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

      public DriveFSMSystem.DriveFSMState 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

      public void update(TeleopInput input)
      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

      public void handleOverrideState(TeleopInput input)
      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

      public void setState(DriveFSMSystem.DriveFSMState state)
      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

      public void handleReefTagAlignment(TeleopInput input)
      Handles reef tag alignment by seeing the nearest reef tag.
      Parameters:
      input -
    • handleStationTagAlignment

      public void handleStationTagAlignment(TeleopInput input)
      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 to
      x -
      y -
      Returns:
      align to tag command.
    • getMapleSimDrivetrain

      public MapleSimSwerveDrivetrain getMapleSimDrivetrain()
      Get the maple-Sim Swerve simulation.
      Returns:
      the simulation
    • updateRaspberryPi

      public void updateRaspberryPi()
      Update the raspberry pi simulation state.