Class ElevatorSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.alotobots.reefscape.subsystems.elevator.ElevatorSubsystem
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 Summary
ConstructorsConstructorDescriptionConstructs a new ElevatorSubsystem with the specified hardware interface. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the current height of the elevator.boolean
Checks if the elevator is at or below the minimum climbing height.boolean
Checks if the elevator is stably at its target height for a minimum duration.void
periodic()
Updates and logs elevator sensor inputs.void
runAtPercentOutput
(double percentOutput) Controls the elevator using direct percent output (open-loop control).void
runToClimbingVelocity
(LinearVelocity velocity) Controls the elevator to move to a specified velocity using closed-loop climbing velocity control.void
runToTargetPosition
(Distance height) Controls the elevator to move to a specified height using closed-loop position control.void
runToTargetVelocity
(LinearVelocity velocity) Controls the elevator to move to a specified velocity using closed-loop velocity control.void
stop()
Stops elevator movement and enables brake mode to maintain position.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, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
ElevatorSubsystem
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
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
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
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
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
-