Class Pivot
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.mechanisms.arm.Pivot
Subsystem used to control the elevator pivot.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionA command that does nothing.Enables brake mode on the pivot motor.double
Gets the current position of the pivot.double
Gets the currenttarget
.void
init()
Sets up the pivot.boolean
Check if the pivot is within the tolerance to it's target position.void
periodic()
This method is responsible for they safety of the pivot.setSpeedCommand
(DoubleSupplier pivotSpeed) A command to set the speed of the pivot.void
setTarget
(double position) A function to move the pivot to a position in degrees.void
A method to move the pivot to a position.Toggles brake mode on the pivot motor.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
-
Pivot
public Pivot()Creates a new Pivot.
-
-
Method Details
-
periodic
public void periodic()This method is responsible for they safety of the pivot.This uses the
target
to determine the target position of the pivot. -
init
public void init()Sets up the pivot. Should be called pre-enable. -
setTarget
A method to move the pivot to a position.- Parameters:
position
- The position as a angle.
-
setTarget
public void setTarget(double position) A function to move the pivot to a position in degrees.- Parameters:
position
- The position in degrees.
-
getTarget
public double getTarget()Gets the currenttarget
.- Returns:
- The pivot target in meters.
-
getPosition
public double getPosition()Gets the current position of the pivot.- Returns:
- The pivot position in degrees.
-
isAtTarget
public boolean isAtTarget()Check if the pivot 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 pivot. Used for relative control.- Parameters:
pivotSpeed
- The speed of the pivot 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 pivot motor.- Returns:
- Command to run.
-
enableBrakeModeCommand
Enables brake mode on the pivot motor. Called on enable to ensure the pivot is in brake mode for the match.- Returns:
- Command to run.
-