Package frc.robot.subsystems.shooter
Class Turret
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.subsystems.shooter.Turret
The turret that the shooter is attached to.
- API Note:
- All set position methods in this class are robot-relative, since we don't want to interact with Drivetrain if we don't have to.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the current position of the turret, wrapped to stay within [0-1].Gets the current position of the turret with no wrapping.booleanChecks if the turret is at its setpoint.static booleanisInArrayBinarySearch(double[] values, double target, double tolerance) generic binary search, needed for findRotationsFromEncoders, replace if there is one in a library i don't know aboutvoidperiodic()voidsetPosition(Angle position) Commands the turret motor closed loop controller to a certain position, wrapping if applicable.setPositionCommand(Supplier<Angle> position) Command to set the turret to a certain position with MotionMagic.voidvoidunspool()Rotates back to an equivalent position +/- 0.5 rotations from center.Command to unspool the turret.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, startEnd, startRun
-
Constructor Details
-
Turret
public Turret()Creates a new Turret.
-
-
Method Details
-
periodic
public void periodic() -
simulationPeriodic
public void simulationPeriodic() -
setPositionCommand
Command to set the turret to a certain position with MotionMagic.- Parameters:
position- Angle to turn to.- Returns:
- Command to run.
-
isInArrayBinarySearch
public static boolean isInArrayBinarySearch(double[] values, double target, double tolerance) generic binary search, needed for findRotationsFromEncoders, replace if there is one in a library i don't know about- Parameters:
values- the list of values to searchtarget- the target valuetolerance- the tolerance of whether a value is the same- Returns:
-
unspoolCommand
Command to unspool the turret. This rotates back to an equivalent position +/- 0.5 rotations from center.This allows you to "unspool" the mechanism, untwisting the wires.
- Returns:
- Command to run.
-
setPosition
Commands the turret motor closed loop controller to a certain position, wrapping if applicable.- Parameters:
position- Angle to turn to. Wrapped to be within [0-1] rotations (and the shortest path to the target is then taken).
-
getPositionDirect
Gets the current position of the turret with no wrapping.- Returns:
- The current position of the turret, with no wrapping and scaled to match gear ratios.
-
getPosition
Gets the current position of the turret, wrapped to stay within [0-1].- Returns:
- The current position of the turret, wrapped and scaled to match gear ratios.
-
isAtTarget
public boolean isAtTarget()Checks if the turret is at its setpoint.- Returns:
- Is the turret at its setpoint?
-
unspool
public void unspool()Rotates back to an equivalent position +/- 0.5 rotations from center.This allows you to "unspool" the mechanism, untwisting the wires.
-