Class Elevator
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.mechanisms.arm.Elevator
Subsystem to control the elevator.
Elevator safety features are in the periodic()
method.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionA command that does nothing.Enables brake mode on the elevator motors.double
Gets the current position of the elevator.double
Gets the currenttarget
.void
init()
Sets up the elevator.boolean
Check if the elevator is within the tolerance to it's target position.void
periodic()
This method is responsible for they safety of the elevator.setSpeedCommand
(DoubleSupplier elevatorSpeed) A command to set the speed of the elevator.void
setTarget
(double position) A method to move the elevator to a position in meters.void
A method to move the elevator to a position.Toggles brake mode on the elevator motors.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
-
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
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 currenttarget
.- 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 theArm.setPositionCommand(ArmPosition)
command is finished. -
setSpeedCommand
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
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
Toggles brake mode on the elevator motors.- Returns:
- Command to run.
-
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.
-