Class SparkMaxPIDController
- All Implemented Interfaces:
CANPIDController
CANSparkMax.getPIDController().-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptiondoublegetD()Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.doublegetD(int slotID) Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.doublegetDFilter(int slotID) Get the Derivative Filter constant of the PIDF controller on the SPARK MAX.doublegetFF()Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.doublegetFF(int slotID) Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.doublegetI()Get the Integral Gain constant of the PIDF controller on the SPARK MAX.doublegetI(int slotID) Get the Integral Gain constant of the PIDF controller on the SPARK MAX.doubleGet the I accumulator of the PID controller.doublegetIMaxAccum(int slotID) Get the maximum I accumulator of the PID controller.doublegetIZone()Get the IZone constant of the PIDF controller on the SPARK MAX.doublegetIZone(int slotID) Get the IZone constant of the PIDF controller on the SPARK MAX.doubleGet the max output of the PIDF controller on the SPARK MAX.doublegetOutputMax(int slotID) Get the max output of the PIDF controller on the SPARK MAX.doubleGet the min output of the PIDF controller on the SPARK MAX.doublegetOutputMin(int slotID) Get the min output of the PIDF controller on the SPARK MAX.doublegetP()Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.doublegetP(int slotID) Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.getSmartMotionAccelStrategy(int slotID) Get the acceleration strategy used to control acceleration on the motor.doublegetSmartMotionAllowedClosedLoopError(int slotID) Get the allowed closed loop error of SmartMotion mode.doublegetSmartMotionMaxAccel(int slotID) Get the maximum acceleration of the SmartMotion mode.doublegetSmartMotionMaxVelocity(int slotID) Get the maximum velocity of the SmartMotion mode.doublegetSmartMotionMinOutputVelocity(int slotID) Get the mimimum velocity of the SmartMotion mode.setD(double gain) Set the Derivative Gain constant of the PIDF controller on the SPARK MAX.setD(double gain, int slotID) Set the Derivative Gain constant of the PIDF controller on the SPARK MAX.setDFilter(double gain) Set the Derivative Filter constant of the PIDF controller on the SPARK MAX.setDFilter(double gain, int slotID) Set the Derivative Filter constant of the PIDF controller on the SPARK MAX.setFeedbackDevice(CANSensor sensor) Deprecated, for removal: This API element is subject to removal in a future version.setFeedbackDevice(MotorFeedbackSensor sensor) Set the controller's feedback devicesetFF(double gain) Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX.setFF(double gain, int slotID) Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX.setI(double gain) Set the Integral Gain constant of the PIDF controller on the SPARK MAX.setI(double gain, int slotID) Set the Integral Gain constant of the PIDF controller on the SPARK MAX.setIAccum(double iAccum) Set the I accumulator of the PID controller.setIMaxAccum(double iMaxAccum, int slotID) Configure the maximum I accumulator of the PID controller.setIZone(double IZone) Set the IZone range of the PIDF controller on the SPARK MAX.setIZone(double IZone, int slotID) Set the IZone range of the PIDF controller on the SPARK MAX.setOutputRange(double min, double max) Set the min amd max output for the closed loop mode.setOutputRange(double min, double max, int slotID) Set the min amd max output for the closed loop mode.setP(double gain) Set the Proportional Gain constant of the PIDF controller on the SPARK MAX.setP(double gain, int slotID) Set the Proportional Gain constant of the PIDF controller on the SPARK MAX.setReference(double value, CANSparkMax.ControlType ctrl) Set the controller reference value based on the selected control mode.setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot) Set the controller reference value based on the selected control mode.setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot, double arbFeedforward) Set the controller reference value based on the selected control mode.setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot, double arbFeedforward, SparkMaxPIDController.ArbFFUnits arbFFUnits) Set the controller reference value based on the selected control mode.setReference(double value, ControlType ctrl) Deprecated, for removal: This API element is subject to removal in a future version.UsesetReference(double, CANSparkMax.ControlType)instead.setReference(double value, ControlType ctrl, int pidSlot) Deprecated, for removal: This API element is subject to removal in a future version.UsesetReference(double, CANSparkMax.ControlType, int)instead.setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward) Deprecated, for removal: This API element is subject to removal in a future version.setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, CANPIDController.ArbFFUnits arbFFUnits) Deprecated, for removal: This API element is subject to removal in a future version.setSmartMotionAccelStrategy(CANPIDController.AccelStrategy accelStrategy, int slotID) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSmartMotionAccelStrategy(AccelStrategy, int)instead.setSmartMotionAccelStrategy(SparkMaxPIDController.AccelStrategy accelStrategy, int slotID) NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling acceleration strategy.setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID) Configure the allowed closed loop error of SmartMotion mode.setSmartMotionMaxAccel(double maxAccel, int slotID) Configure the maximum acceleration of the SmartMotion mode.setSmartMotionMaxVelocity(double maxVel, int slotID) Configure the maximum velocity of the SmartMotion mode.setSmartMotionMinOutputVelocity(double minVel, int slotID) Configure the mimimum velocity of the SmartMotion mode.
-
Method Details
-
setReference
Set the controller reference value based on the selected control mode.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- the control type- Returns:
REVLibError.kOkif successful
-
setReference
Deprecated, for removal: This API element is subject to removal in a future version.UsesetReference(double, CANSparkMax.ControlType)instead.Set the controller reference value based on the selected control mode.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- the control type- Returns:
REVLibError.kOkif successful
-
setReference
Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this command- Returns:
REVLibError.kOkif successful
-
setReference
@Deprecated(forRemoval=true) public REVLibError setReference(double value, ControlType ctrl, int pidSlot) Deprecated, for removal: This API element is subject to removal in a future version.UsesetReference(double, CANSparkMax.ControlType, int)instead.Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this command- Returns:
REVLibError.kOkif successful
-
setReference
public REVLibError setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot, double arbFeedforward) Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this commandarbFeedforward- 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 value, ControlType ctrl, int pidSlot, double arbFeedforward) Deprecated, for removal: This API element is subject to removal in a future version.Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this commandarbFeedforward- 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
public REVLibError setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot, double arbFeedforward, SparkMaxPIDController.ArbFFUnits arbFFUnits) Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this commandarbFeedforward- 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 value, ControlType ctrl, int pidSlot, double arbFeedforward, CANPIDController.ArbFFUnits arbFFUnits) Deprecated, for removal: This API element is subject to removal in a future version.Set the controller reference value based on the selected control mode. This will override the pre-programmed control mode but not change what is programmed to the controller.- Specified by:
setReferencein interfaceCANPIDController- 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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl- Is the control type to override withpidSlot- for this commandarbFeedforward- 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
-
setP
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.- Specified by:
setPin interfaceCANPIDController- Parameters:
gain- The proportional gain value, must be positive- Returns:
REVLibError.kOkif successful
-
setP
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.- Specified by:
setPin interfaceCANPIDController- Parameters:
gain- The proportional gain value, must be positiveslotID- 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:
REVLibError.kOkif successful
-
setI
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.- Specified by:
setIin interfaceCANPIDController- Parameters:
gain- The integral gain value, must be positive- Returns:
REVLibError.kOkif successful
-
setI
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.- Specified by:
setIin interfaceCANPIDController- Parameters:
gain- The integral gain value, must be positiveslotID- 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:
REVLibError.kOkif successful
-
setD
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.- Specified by:
setDin interfaceCANPIDController- Parameters:
gain- The derivative gain value, must be positive- Returns:
REVLibError.kOkif successful
-
setD
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.- Specified by:
setDin interfaceCANPIDController- Parameters:
gain- The derivative gain value, must be positiveslotID- 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:
REVLibError.kOkif successful
-
setDFilter
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.- Specified by:
setDFilterin interfaceCANPIDController- Parameters:
gain- The derivative filter value, must be a positive number between 0 and 1- Returns:
REVLibError.kOkif successful
-
setDFilter
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.- Specified by:
setDFilterin interfaceCANPIDController- Parameters:
gain- The derivative filter value, must be a positive number between 0 and 1slotID- 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:
REVLibError.kOkif successful
-
setFF
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.- Specified by:
setFFin interfaceCANPIDController- Parameters:
gain- The feed-forward gain value- Returns:
REVLibError.kOkif successful
-
setFF
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.- Specified by:
setFFin interfaceCANPIDController- Parameters:
gain- The feed-forward gain valueslotID- 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:
REVLibError.kOkif successful
-
setIZone
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.
- Specified by:
setIZonein interfaceCANPIDController- Parameters:
IZone- The IZone value, must be positive. Set to 0 to disable- Returns:
REVLibError.kOkif successful
-
setIZone
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.
- Specified by:
setIZonein interfaceCANPIDController- Parameters:
IZone- The IZone value, must be positive. Set to 0 to disableslotID- 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:
REVLibError.kOkif successful
-
setOutputRange
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.
- Specified by:
setOutputRangein interfaceCANPIDController- Parameters:
min- Reverse power minimum to allow the controller to outputmax- Forward power maximum to allow the controller to output- Returns:
REVLibError.kOkif successful
-
setOutputRange
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.
- Specified by:
setOutputRangein interfaceCANPIDController- Parameters:
min- Reverse power minimum to allow the controller to outputmax- Forward power maximum to allow the controller to outputslotID- 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:
REVLibError.kOkif successful
-
getP
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)
- Specified by:
getPin interfaceCANPIDController- Returns:
- double P Gain value
-
getP
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)
- Specified by:
getPin interfaceCANPIDController- 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
-
getI
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)
- Specified by:
getIin interfaceCANPIDController- Returns:
- double I Gain value
-
getI
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)
- Specified by:
getIin interfaceCANPIDController- 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
-
getD
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)
- Specified by:
getDin interfaceCANPIDController- Returns:
- double D Gain value
-
getD
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)
- Specified by:
getDin interfaceCANPIDController- 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
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)
- Specified by:
getDFilterin interfaceCANPIDController- 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
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)
- Specified by:
getFFin interfaceCANPIDController- Returns:
- double F Gain value
-
getFF
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)
- Specified by:
getFFin interfaceCANPIDController- 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
-
getIZone
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)
- Specified by:
getIZonein interfaceCANPIDController- Returns:
- double IZone value
-
getIZone
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)
- Specified by:
getIZonein interfaceCANPIDController- 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
-
getOutputMin
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)
- Specified by:
getOutputMinin interfaceCANPIDController- Returns:
- double min value
-
getOutputMin
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)
- Specified by:
getOutputMinin interfaceCANPIDController- 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
-
getOutputMax
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)
- Specified by:
getOutputMaxin interfaceCANPIDController- Returns:
- double max value
-
getOutputMax
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)
- Specified by:
getOutputMaxin interfaceCANPIDController- 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
-
setSmartMotionMaxVelocity
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- Specified by:
setSmartMotionMaxVelocityin interfaceCANPIDController- Parameters:
maxVel- The maxmimum cruise velocity for the motion profile in RPMslotID- 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:
REVLibError.kOkif successful
-
setSmartMotionMaxAccel
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- Specified by:
setSmartMotionMaxAccelin interfaceCANPIDController- Parameters:
maxAccel- The maxmimum acceleration for the motion profile in RPM per secondslotID- 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:
REVLibError.kOkif successful
-
setSmartMotionMinOutputVelocity
Configure the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.- Specified by:
setSmartMotionMinOutputVelocityin interfaceCANPIDController- Parameters:
minVel- The minimum velocity for the motion profile in RPMslotID- 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:
REVLibError.kOkif successful
-
setSmartMotionAllowedClosedLoopError
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.- Specified by:
setSmartMotionAllowedClosedLoopErrorin interfaceCANPIDController- Parameters:
allowedErr- The allowed deviation for your setpoint vs actual position in rotationsslotID- 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:
REVLibError.kOkif successful
-
setSmartMotionAccelStrategy
public REVLibError setSmartMotionAccelStrategy(SparkMaxPIDController.AccelStrategy accelStrategy, int slotID) NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling acceleration strategy.Configure the acceleration strategy used to control acceleration on the motor.
- Parameters:
accelStrategy- The acceleration strategy to use for the automatically generated motion profileslotID- 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:
REVLibError.kOkif successful
-
setSmartMotionAccelStrategy
@Deprecated(forRemoval=true) public REVLibError setSmartMotionAccelStrategy(CANPIDController.AccelStrategy accelStrategy, int slotID) Deprecated, for removal: This API element is subject to removal in a future version.UsesetSmartMotionAccelStrategy(AccelStrategy, int)instead.NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling acceleration strategy.Configure the acceleration strategy used to control acceleration on the motor. The current strategy is trapezoidal motion profiling.
- Specified by:
setSmartMotionAccelStrategyin interfaceCANPIDController- Parameters:
accelStrategy- The acceleration strategy to use for the automatically generated motion profileslotID- 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:
REVLibError.kOkif successful
-
getSmartMotionMaxVelocity
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- Specified by:
getSmartMotionMaxVelocityin interfaceCANPIDController- 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
-
getSmartMotionMaxAccel
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- Specified by:
getSmartMotionMaxAccelin interfaceCANPIDController- 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
-
getSmartMotionMinOutputVelocity
Get the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.- Specified by:
getSmartMotionMinOutputVelocityin interfaceCANPIDController- 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
-
getSmartMotionAllowedClosedLoopError
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.- Specified by:
getSmartMotionAllowedClosedLoopErrorin interfaceCANPIDController- 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
-
getSmartMotionAccelStrategy
Get the acceleration strategy used to control acceleration on the motor. As of the 2022 FRC season, the strategy is always trapezoidal motion profiling, regardless of what the device may report.- Specified by:
getSmartMotionAccelStrategyin interfaceCANPIDController- 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.
-
setIMaxAccum
Configure the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up- Specified by:
setIMaxAccumin interfaceCANPIDController- Parameters:
iMaxAccum- The max value to contrain the I accumulator toslotID- 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:
REVLibError.kOkif successful
-
getIMaxAccum
Get the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up- Specified by:
getIMaxAccumin interfaceCANPIDController- 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
-
setIAccum
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 characteristicsTo use this function, the controller must be in a closed loop control mode by calling setReference()
- Specified by:
setIAccumin interfaceCANPIDController- Parameters:
iAccum- The value to set the I accumulator to- Returns:
REVLibError.kOkif successful
-
getIAccum
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- Specified by:
getIAccumin interfaceCANPIDController- Returns:
- The value of the I accumulator
-
setFeedbackDevice
Set the controller's feedback deviceThe default feedback device in brushless mode is assumed to be the integrated encoder and the default feedback device in brushed mode is assumed to be a quadrature 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.
- Specified by:
setFeedbackDevicein interfaceCANPIDController- Parameters:
sensor- The sensor to use as a feedback device- Returns:
REVLibError.kOkif successful
-
setFeedbackDevice
Deprecated, for removal: This API element is subject to removal in a future version.UsesetFeedbackDevice(MotorFeedbackSensor)instead- Specified by:
setFeedbackDevicein interfaceCANPIDController
-
setFeedbackDevice(MotorFeedbackSensor)instead