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 void
accept(@NotNull TankDriveData tankDriveData)
Command previously set motors according to the providedTankDriveData
.boolean
isClosedLoop()
Returns whether thisCTREOutput
commands its controllers in closed-loop mode if possible.void
setClosedLoop(boolean closedLoop)
Sets whether thisCTREOutput
commands 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)
withclosedLoop
equal 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 providedTankDriveData
has 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 providedTankDriveData
has 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:
accept
in interfaceConsumer<TankDriveData>
- Parameters:
tankDriveData
- The data to accept.
-
isClosedLoop
@Contract(pure=true) public boolean isClosedLoop()
Returns whether thisCTREOutput
commands its controllers in closed-loop mode if possible. Iftrue
, whenaccept()
is called and the providedTankDriveData
has 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 providedTankDriveData
has 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:
true
if closed-loop control will be used,false
otherwise.
-
setClosedLoop
public void setClosedLoop(boolean closedLoop)
Sets whether thisCTREOutput
commands its controllers in closed-loop mode if possible. IfclosedLoop
istrue
, whenaccept()
is called and the providedTankDriveData
has 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 providedTankDriveData
has 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.
-
-