Class Elevator

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.mechanisms.arm.Elevator
All Implemented Interfaces:
Sendable, Subsystem

public class Elevator extends SubsystemBase
Subsystem to control the elevator.

Elevator safety features are in the periodic() method.

  • Constructor Details

    • Elevator

      public Elevator()
      Creates a new Elevator.
  • Method Details

    • periodic

      public void periodic()
      This method is responsible for they safety of the elevator.

      This uses the target to determine the target position of the elevator, and constrain said target to the safe bounds.

    • init

      public void init()
      Sets up the elevator. Should be called pre-enable.
    • setTarget

      public void setTarget(Distance position)
      A method to move the elevator to a position.
      Parameters:
      position - The position as a distance.
    • setTarget

      public void setTarget(double position)
      A method to move the elevator to a position in meters.
      Parameters:
      position - The position in meters.
    • getTarget

      public double getTarget()
      Gets the current target.
      Returns:
      The elevator target in meters.
    • getPosition

      public double getPosition()
      Gets the current position of the elevator.
      Returns:
      The elevator position in meters.
    • isAtTarget

      public boolean isAtTarget()
      Check if the elevator is within the tolerance to it's target position. This is used to determine if the Arm.setPositionCommand(ArmPosition) command is finished.
    • setSpeedCommand

      public Command setSpeedCommand(DoubleSupplier elevatorSpeed)
      A command to set the speed of the elevator. Used for relative control.
      Parameters:
      elevatorSpeed - The speed of the elevator as a percentage of max speed. [-1, 1]
      Returns:
      Command to run.
    • doNothing

      public Command doNothing()
      A command that does nothing. This command requires the elevator subsystem so it will kill any other command. This is used to let the drivers regain controll of the elevator if it is unable to reach its target.
      Returns:
      Command to run.
    • toggleBrakeModeCommand

      public Command toggleBrakeModeCommand()
      Toggles brake mode on the elevator motors.
      Returns:
      Command to run.
    • enableBrakeModeCommand

      public Command enableBrakeModeCommand()
      Enables brake mode on the elevator motors. Called on enable to ensure the elevator is in brake mode for the match.
      Returns:
      Command to run.