Class CTREOutput
- java.lang.Object
-
- org.team1540.rooster.drive.pipeline.CTREOutput
-
- All Implemented Interfaces:
Consumer<TankDriveData>,Output<TankDriveData>
public class CTREOutput extends Object implements Output<TankDriveData>
-
-
Constructor Summary
Constructors Constructor Description CTREOutput(@NotNull com.ctre.phoenix.motorcontrol.IMotorController left, @NotNull com.ctre.phoenix.motorcontrol.IMotorController right)Creates a newCTREOutput.CTREOutput(@NotNull com.ctre.phoenix.motorcontrol.IMotorController left, @NotNull com.ctre.phoenix.motorcontrol.IMotorController right, boolean closedLoop)Creates a newCTREOutput.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(@NotNull TankDriveData tankDriveData)Command previously set motors according to the providedTankDriveData.booleanisClosedLoop()Returns whether thisCTREOutputcommands its controllers in closed-loop mode if possible.voidsetClosedLoop(boolean closedLoop)Sets whether thisCTREOutputcommands its controllers in closed-loop mode if possible.
-
-
-
Constructor Detail
-
CTREOutput
public CTREOutput(@NotNull @NotNull com.ctre.phoenix.motorcontrol.IMotorController left, @NotNull @NotNull com.ctre.phoenix.motorcontrol.IMotorController right)Creates a newCTREOutput. This is equivalent to callingCTREOutput(IMotorController, IMotorController, boolean)withclosedLoopequal totrue.- Parameters:
left- The left-side motor controller.right- The right-side motor controller.
-
CTREOutput
public CTREOutput(@NotNull @NotNull com.ctre.phoenix.motorcontrol.IMotorController left, @NotNull @NotNull com.ctre.phoenix.motorcontrol.IMotorController right, boolean closedLoop)Creates a newCTREOutput.- Parameters:
left- The left-side motor controller.right- The right-side motor controller.closedLoop- Whether to command the controllers in closed-loop mode if possible. (SeeisClosedLoop()/setClosedLoop()).
-
-
Method Detail
-
accept
@Contract(pure=true) public void accept(@NotNull @NotNull TankDriveData tankDriveData)Command previously set motors according to the providedTankDriveData.If closed-loop is enabled (
isClosedLoop()returnstrue), when the providedTankDriveDatahas non-empty position or velocity fields, that setpoint will be sent to the motor controllers as a closed-loop setpoint, with any additional feed-forward sent via throttle bump. (Position has priority over velocity when deciding which setpoint to send.) If it isfalse, or if the providedTankDriveDatahas empty position and velocity fields,DriveData.additionalFeedForward(or 0 if it is not present) will be passed in as the motor throttle from -1 to 1 inclusive.- Specified by:
acceptin interfaceConsumer<TankDriveData>- Parameters:
tankDriveData- The data to accept.
-
isClosedLoop
@Contract(pure=true) public boolean isClosedLoop()
Returns whether thisCTREOutputcommands its controllers in closed-loop mode if possible. Iftrue, whenaccept()is called and the providedTankDriveDatahas non-empty position or velocity fields, that setpoint will be sent to the motor controllers as a closed-loop setpoint, with any additional feed-forward sent via throttle bump (position has priority over velocity when deciding which setpoint to send.) Iffalse, or if the providedTankDriveDatahas empty position and velocity fields,DriveData.additionalFeedForward(or 0 if it is not present) will be passed in as the motor throttle from -1 to 1 inclusive.- Returns:
trueif closed-loop control will be used,falseotherwise.
-
setClosedLoop
public void setClosedLoop(boolean closedLoop)
Sets whether thisCTREOutputcommands its controllers in closed-loop mode if possible. IfclosedLoopistrue, whenaccept()is called and the providedTankDriveDatahas non-empty position or velocity fields, that setpoint will be sent to the motor controllers as a closed-loop setpoint, with any additional feed-forward sent via throttle bump. (Position has priority over velocity when deciding which setpoint to send.) If it isfalse, or if the providedTankDriveDatahas empty position and velocity fields,DriveData.additionalFeedForward(or 0 if it is not present) will be passed in as the motor throttle from -1 to 1 inclusive.- Parameters:
closedLoop- Whether to use closed-loop, if possible.
-
-