Class ElevatorSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.alotobots.reefscape.subsystems.elevator.ElevatorSubsystem
All Implemented Interfaces:
Sendable, Subsystem

public class ElevatorSubsystem extends SubsystemBase
The Elevator subsystem controls the vertical movement of the robot's elevator mechanism. This subsystem manages closed-loop position control, closed-loop velocity control, and open loop control
  • Constructor Details

    • ElevatorSubsystem

      public ElevatorSubsystem(ElevatorIO io)
      Constructs a new ElevatorSubsystem with the specified hardware interface.
      Parameters:
      io - The hardware interface for controlling the elevator mechanism
  • Method Details

    • periodic

      public void periodic()
      Updates and logs elevator sensor inputs. Called periodically by the command scheduler. This method ensures that the latest sensor data is available for control decisions.
    • runToTargetPosition

      public void runToTargetPosition(Distance height)
      Controls the elevator to move to a specified height using closed-loop position control.
      Parameters:
      height - Target height in meters, automatically constrained between MIN_HEIGHT and MAX_HEIGHT
    • runToTargetVelocity

      public void runToTargetVelocity(LinearVelocity velocity)
      Controls the elevator to move to a specified velocity using closed-loop velocity control.
      Parameters:
      velocity - Target velocity in meters per second, automatically constrained between -MAX_OPERATOR_VELOCITY and MAX_OPERATOR_VELOCITY
    • runToClimbingVelocity

      public void runToClimbingVelocity(LinearVelocity velocity)
      Controls the elevator to move to a specified velocity using closed-loop climbing velocity control.
      Parameters:
      velocity - Target velocity in meters per second, automatically constrained between -MAX_OPERATOR_VELOCITY and MAX_OPERATOR_VELOCITY
    • isAtMinClimbHeight

      public boolean isAtMinClimbHeight()
      Checks if the elevator is at or below the minimum climbing height. This can be used both for velocity limiting and as a command end condition.
      Returns:
      true if the elevator is at or below MIN_CLIMB_HEIGHT, false otherwise
    • runAtPercentOutput

      public void runAtPercentOutput(double percentOutput)
      Controls the elevator using direct percent output (open-loop control). The output is clamped to prevent excessive speed.
      Parameters:
      percentOutput - Motor output percentage (-1.0 to 1.0)
    • stop

      public void stop()
      Stops elevator movement and enables brake mode to maintain position. This method should be called when active control of the elevator is no longer needed.
    • getCurrentHeight

      public Distance getCurrentHeight()
      Retrieves the current height of the elevator.
      Returns:
      The current height as a Distance object
    • isAtTargetHeight

      public boolean isAtTargetHeight()
      Checks if the elevator is stably at its target height for a minimum duration.
      Returns:
      true if the elevator has maintained its target height within tolerance