SparkClosedLoopController
- class rev.SparkClosedLoopController
Bases:
pybind11_object- class ArbFFUnits(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectUnits for arbitrary feed-forward
Members:
kVoltage
kPercentOut
- kPercentOut = <ArbFFUnits.kPercentOut: 1>
- kVoltage = <ArbFFUnits.kVoltage: 0>
- SparkClosedLoopController.ArbFFUnits.name -> str
- property value
- getControlType() rev._rev.SparkLowLevel.ControlType
Get the selected control type used when SetSetpoint() was called.
- Returns:
The selected control type
- getIAccum() rev._rev.Signal_double
Get the I accumulator of the closed loop controller. This is useful when wishing to see what the I accumulator value is to help with PID tuning
- Returns:
Signal containing the value of the I accumulator
- getMAXMotionSetpointPosition() rev._rev.Signal_double
Get the MAXMotion internal setpoint position.
This will be 0 if the controller is not in a MAXMotion control mode.
- Returns:
Signal containing the MAXMotion internal setpoint position in rotations or units specified by the conversion factor.
- getMAXMotionSetpointVelocity() rev._rev.Signal_double
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.
- getSelectedSlot() rev._rev.Signal_ClosedLoopSlot
Get the selected closed loop PID slot.
- Returns:
Signal containing the selected closed loop PID slot
- getSetpoint() rev._rev.Signal_double
Get the internal setpoint of the closed loop controller.
- Returns:
Signal containing the internal setpoint
- isAtSetpoint() rev._rev.Signal_bool
Determine if the setpoint has been reached.
- Returns:
Signal containing true if the setpoint is reached; false otherwise
- setIAccum(iAccum: SupportsFloat | SupportsIndex) rev._rev.REVLibError
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 characteristics
To use this function, the controller must be in a closed loop control mode by calling SetSetpoint()
- Parameters:
iAccum – The value to set the I accumulator to
- Returns:
REVLibError::kOk if successful
- setSetpoint(setpoint: SupportsFloat | SupportsIndex, ctrl: rev._rev.SparkLowLevel.ControlType, slot: rev._rev.ClosedLoopSlot = <ClosedLoopSlot.kSlot0: 0>, arbFeedforward: SupportsFloat | SupportsIndex = 0, arbFFUnits: rev._rev.SparkClosedLoopController.ArbFFUnits = <ArbFFUnits.kVoltage: 0>) rev._rev.REVLibError
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 - Voltage Control: Voltage (volts) - Velocity Control: Velocity (RPM) - Position Control: Position (Rotations) - Current Control: Current (Amps). The units can be changed for position and velocity by a scale factor using AlternateEncoderConfig::PositionConversionFactor(), or ExternalEncoderConfig::PositionConversionFactor(), or EncoderConfig::PositionConversionFactor() or AlternateEncoderConfig::VelocityConversionFactor(), or ExternalEncoderConfig::VelocityConversionFactor(), or EncoderConfig::VelocityConversionFactor().
ctrl – Is the control type
slot – The ClosedLoopSlot to use
arbFeedforward – A value from -32.0 to 32.0 which is a 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 for arbitrary feed-forward
- Returns:
REVLibError::kOk if successful