Class SparkClosedLoopController
java.lang.Object
com.revrobotics.spark.SparkClosedLoopController
Get an instance of this class by using
SparkBase.getClosedLoopController().-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionGet the selected control type used whensetReference(double, SparkBase.ControlType)was last called.Get the I accumulator of the closed loop controller.Get the MAXMotion internal setpoint position.Get the MAXMotion internal setpoint velocity.Get the selected closed loop PID slot.Get the internal setpoint of the closed loop controller.Determine if the setpoint has been reached.setIAccum(double iAccum) Set the I accumulator of the closed loop controller.setReference(double setpoint, SparkBase.ControlType ctrl) Deprecated, for removal: This API element is subject to removal in a future version.setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot) Deprecated, for removal: This API element is subject to removal in a future version.setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward) Deprecated, for removal: This API element is subject to removal in a future version.setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward, SparkClosedLoopController.ArbFFUnits arbFFUnits) Deprecated, for removal: This API element is subject to removal in a future version.setSetpoint(double setpoint, SparkBase.ControlType ctrl) Set the controller setpoint based on the selected control mode.setSetpoint(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot) Set the controller setpoint based on the selected control mode.setSetpoint(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward) Set the controller setpoint based on the selected control mode.setSetpoint(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward, SparkClosedLoopController.ArbFFUnits arbFFUnits) Set the controller setpoint based on the selected control mode.
-
Method Details
-
setSetpoint
Set the controller setpoint based on the selected control mode.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- the control type- Returns:
REVLibError.kOkif successful
-
setSetpoint
Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto use- Returns:
REVLibError.kOkif successful
-
setSetpoint
public REVLibError setSetpoint(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward) Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto usearbFeedforward- A value from which is represented in voltage applied to the motor after the result of the specified control mode. The units for the parameter is Volts. This value is set after the control mode, but before any current limits or ramp rates.- Returns:
REVLibError.kOkif successful
-
setSetpoint
public REVLibError setSetpoint(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward, SparkClosedLoopController.ArbFFUnits arbFFUnits) Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto usearbFeedforward- A value from which is represented in voltage applied to the motor after the result of the specified control mode. The units for the parameter is Volts. This value is set after the control mode, but before any current limits or ramp rates.arbFFUnits- The units the arbitrary feed forward term is in- Returns:
REVLibError.kOkif successful
-
setReference
@Deprecated(forRemoval=true) public REVLibError setReference(double setpoint, SparkBase.ControlType ctrl) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSetpoint(double, SparkBase.ControlType)insteadSet the controller setpoint based on the selected control mode.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- the control type- Returns:
REVLibError.kOkif successful
-
setReference
@Deprecated(forRemoval=true) public REVLibError setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot) Deprecated, for removal: This API element is subject to removal in a future version.Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto use- Returns:
REVLibError.kOkif successful
-
setReference
@Deprecated(forRemoval=true) public REVLibError setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward) Deprecated, for removal: This API element is subject to removal in a future version.Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto usearbFeedforward- A value from which is represented in voltage applied to the motor after the result of the specified control mode. The units for the parameter is Volts. This value is set after the control mode, but before any current limits or ramp rates.- Returns:
REVLibError.kOkif successful
-
setReference
@Deprecated(forRemoval=true) public REVLibError setReference(double setpoint, SparkBase.ControlType ctrl, ClosedLoopSlot slot, double arbFeedforward, SparkClosedLoopController.ArbFFUnits arbFFUnits) Deprecated, for removal: This API element is subject to removal in a future version.Set the controller setpoint based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Parameters:
setpoint- The setpoint to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double)orAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double)ctrl- Is the control type to override withslot- TheClosedLoopSlotto usearbFeedforward- A value from which is represented in voltage applied to the motor after the result of the specified control mode. The units for the parameter is Volts. This value is set after the control mode, but before any current limits or ramp rates.arbFFUnits- The units the arbitrary feed forward term is in- Returns:
REVLibError.kOkif successful
-
getControlType
Get the selected control type used whensetReference(double, SparkBase.ControlType)was last called.- Returns:
- The selected control type
-
setIAccum
Set the I accumulator of the closed loop controller. This is useful when wishing to force a reset on the I accumulator of the closed loop controller. You can also preset values to see how it will respond to certain I characteristicsTo use this function, the controller must be in a closed loop control mode by calling setReference()
- Parameters:
iAccum- The value to set the I accumulator to- Returns:
REVLibError.kOkif successful
-
getIAccum
-
getSetpoint
-
isAtSetpoint
-
getSelectedSlot
Get the selected closed loop PID slot.- Returns:
- Signal containing the selected closed loop PID slot
-
getMAXMotionSetpointPosition
-
getMAXMotionSetpointVelocity
Get the MAXMotion internal setpoint velocity.This will be 0 if the controller is not in a MAXMotion control mode.
- Returns:
- Signal containing the MAXMotion internal setpoint velocity in rotations per minute or units specified by the conversion factor.
-
setSetpoint(double, SparkBase.ControlType)instead