CANPIDController

class rev.CANPIDController

Bases: pybind11_builtins.pybind11_object

class AccelStrategy(self: rev._rev.CANPIDController.AccelStrategy, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kTrapezoidal

kSCurve

kSCurve = <AccelStrategy.kSCurve: 1>
kTrapezoidal = <AccelStrategy.kTrapezoidal: 0>
property name
class ArbFFUnits(self: rev._rev.CANPIDController.ArbFFUnits, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kVoltage

kPercentOut

kPercentOut = <ArbFFUnits.kPercentOut: 1>
kVoltage = <ArbFFUnits.kVoltage: 0>
property name
getD(self: rev.CANPIDController, slotID: int = 0) → float

Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double D Gain value

getDFilter(self: rev.CANPIDController, slotID: int = 0) → float

Get the Derivative Filter constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double D Filter value

getFF(self: rev.CANPIDController, slotID: int = 0) → float

Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double F Gain value

getI(self: rev.CANPIDController, slotID: int = 0) → float

Get the Integral Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double I Gain value

getIAccum(self: rev.CANPIDController) → float

Get the I accumulator of the PID controller. This is useful when wishing to see what the I accumulator value is to help with PID tuning

Returns

The value of the I accumulator

getIMaxAccum(self: rev.CANPIDController, slotID: int = 0) → float

Get the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The max value to contrain the I accumulator to

getIZone(self: rev.CANPIDController, slotID: int = 0) → float

Get the IZone constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double IZone value

getOutputMax(self: rev.CANPIDController, slotID: int = 0) → float

Get the max output of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double max value

getOutputMin(self: rev.CANPIDController, slotID: int = 0) → float

Get the min output of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double min value

getP(self: rev.CANPIDController, slotID: int = 0) → float

Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

double P Gain value

getSmartMotionAccelStrategy(self: rev.CANPIDController, slotID: int = 0) → rev._rev.CANPIDController.AccelStrategy

Get the acceleration strategy used to control acceleration on the motor. The current strategy is trapezoidal motion profiling.

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The acceleration strategy to use for the automatically generated motion profile

getSmartMotionAllowedClosedLoopError(self: rev.CANPIDController, slotID: int = 0) → float

Get the allowed closed loop error of SmartMotion mode. This value is how much deviation from your setpoint is tolerated and is useful in preventing oscillation around your setpoint.

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The allowed deviation for your setpoint vs actual position in rotations

getSmartMotionMaxAccel(self: rev.CANPIDController, slotID: int = 0) → float

Get the maximum acceleration of the SmartMotion mode. This is the accleration that the motor velocity will increase at until the max velocity is reached

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The maxmimum acceleration for the motion profile in RPM per second

getSmartMotionMaxVelocity(self: rev.CANPIDController, slotID: int = 0) → float

Get the maximum velocity of the SmartMotion mode. This is the velocity that is reached in the middle of the profile and is what the motor should spend most of its time at

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The maxmimum cruise velocity for the motion profile in RPM

getSmartMotionMinOutputVelocity(self: rev.CANPIDController, slotID: int = 0) → float

Get the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.

Parameters

slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

The minimum velocity for the motion profile in RPM

setD(self: rev.CANPIDController, gain: float, slotID: int = 0)rev.CANError

Set the Derivative Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
  • gain – The derivative gain value, must be positive

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setDFilter(self: rev.CANPIDController, gain: float, slotID: int = 0)rev.CANError

Set the Derivative Filter constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called.

Parameters
  • gain – The derivative filter value, must be a positive number between 0 and 1

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setFF(self: rev.CANPIDController, gain: float, slotID: int = 0)rev.CANError

Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
  • gain – The feed-forward gain value

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setFeedbackDevice(self: rev.CANPIDController, sensor: rev.CANSensor)rev.CANError

Set the controller’s feedback device.

The default feedback device is assumed to be the integrated encoder. This is used to changed to another feedback device for the controller, such as an analog sensor.

If there is a limited range on the feedback sensor that should be observed by the PIDController, it can be set by calling SetFeedbackSensorRange() on the sensor object.

Parameters

sensor – The sensor to be used as a feedback device

Returns

CANError set to kOK if successful

setI(self: rev.CANPIDController, gain: float, slotID: int = 0)rev.CANError

Set the Integral Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
  • gain – The integral gain value, must be positive

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setIAccum(self: rev.CANPIDController, iAccum: float)rev.CANError

Set the I accumulator of the PID controller. This is useful when wishing to force a reset on the I accumulator of the PID 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 setReference()

Parameters

iAccum – The value to set the I accumulator to

Returns

CANError Set to kOK if successful

setIMaxAccum(self: rev.CANPIDController, iMaxAccum: float, slotID: int = 0)rev.CANError

Configure the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up

Parameters
  • iMaxAccum – The max value to contrain the I accumulator to

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful

setIZone(self: rev.CANPIDController, IZone: float, slotID: int = 0)rev.CANError

Set the IZone range of the PIDF controller on the SPARK MAX. This value specifies the range the |error| must be within for the integral constant to take effect.

This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.

Parameters
  • gain – The IZone value, must be positive. Set to 0 to disable

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setOutputRange(self: rev.CANPIDController, min: float, max: float, slotID: int = 0)rev.CANError

Set the min amd max output for the closed loop mode.

This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.

Parameters
  • min – Reverse power minimum to allow the controller to output

  • max – Forward power maximum to allow the controller to output

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setP(self: rev.CANPIDController, gain: float, slotID: int = 0)rev.CANError

Set the Proportional Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
  • gain – The proportional gain value, must be positive

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to REV_OK if successful

setReference(value: float, ctrl: rev._rev.ControlType, pidSlot: int = 0, arbFeedforward: float = 0, arbFFUnits: rev._rev.CANPIDController.ArbFFUnits = <ArbFFUnits.kVoltage: 0>)rev.CANError

Set the controller reference value based on the selected control mode.

Parameters
  • value – The value 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). The units can be changed for position and velocity by a scale factor using setPositionConversionFactor().

  • ctrl – Is the control type

  • pidSlot – for this command

  • 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.

Returns

CANError Set to REV_OK if successful

setSmartMotionAccelStrategy(self: rev.CANPIDController, accelStrategy: rev._rev.CANPIDController.AccelStrategy, slotID: int = 0)rev.CANError

Coming soon. Configure the acceleration strategy used to control acceleration on the motor. The current strategy is trapezoidal motion profiling.

Parameters
  • accelStrategy – The acceleration strategy to use for the automatically generated motion profile

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful

setSmartMotionAllowedClosedLoopError(self: rev.CANPIDController, allowedErr: float, slotID: int = 0)rev.CANError

Configure the allowed closed loop error of SmartMotion mode. This value is how much deviation from your setpoint is tolerated and is useful in preventing oscillation around your setpoint.

Parameters
  • allowedErr – The allowed deviation for your setpoint vs actual position in rotations

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful

setSmartMotionMaxAccel(self: rev.CANPIDController, maxAccel: float, slotID: int = 0)rev.CANError

Configure the maximum acceleration of the SmartMotion mode. This is the accleration that the motor velocity will increase at until the max velocity is reached

Parameters
  • maxAccel – The maxmimum acceleration for the motion profile in RPM per second

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful

setSmartMotionMaxVelocity(self: rev.CANPIDController, maxVel: float, slotID: int = 0)rev.CANError

Configure the maximum velocity of the SmartMotion mode. This is the velocity that is reached in the middle of the profile and is what the motor should spend most of its time at

Parameters
  • maxVel – The maxmimum cruise velocity for the motion profile in RPM

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful

setSmartMotionMinOutputVelocity(self: rev.CANPIDController, minVel: float, slotID: int = 0)rev.CANError

Configure the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.

Parameters
  • minVel – The minimum velocity for the motion profile in RPM

  • slotID – Is the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().

Returns

CANError Set to kOK if successful