Package com.revrobotics
Class CANPIDController
- java.lang.Object
-
- com.revrobotics.CANPIDController
-
public class CANPIDController extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CANPIDController.AccelStrategy
static class
CANPIDController.ArbFFUnits
-
Constructor Summary
Constructors Constructor Description CANPIDController(CANSparkMax device)
Constructs a CANPIDController.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getD()
Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.double
getD(int slotID)
Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.double
getDFilter(int slotID)
Get the Derivative Filter constant of the PIDF controller on the SPARK MAX.double
getFF()
Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.double
getFF(int slotID)
Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.double
getI()
Get the Integral Gain constant of the PIDF controller on the SPARK MAX.double
getI(int slotID)
Get the Integral Gain constant of the PIDF controller on the SPARK MAX.double
getIAccum()
Get the I accumulator of the PID controller.double
getIMaxAccum(int slotID)
Get the maximum I accumulator of the PID controller.double
getIZone()
Get the IZone constant of the PIDF controller on the SPARK MAX.double
getIZone(int slotID)
Get the IZone constant of the PIDF controller on the SPARK MAX.double
getOutputMax()
Get the max output of the PIDF controller on the SPARK MAX.double
getOutputMax(int slotID)
Get the max output of the PIDF controller on the SPARK MAX.double
getOutputMin()
Get the min output of the PIDF controller on the SPARK MAX.double
getOutputMin(int slotID)
Get the min output of the PIDF controller on the SPARK MAX.double
getP()
Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.double
getP(int slotID)
Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.CANPIDController.AccelStrategy
getSmartMotionAccelStrategy(int slotID)
Get the acceleration strategy used to control acceleration on the motor.The current strategy is trapezoidal motion profiling.double
getSmartMotionAllowedClosedLoopError(int slotID)
Get the allowed closed loop error of SmartMotion mode.double
getSmartMotionMaxAccel(int slotID)
Get the maximum acceleration of the SmartMotion mode.double
getSmartMotionMaxVelocity(int slotID)
Get the maximum velocity of the SmartMotion mode.double
getSmartMotionMinOutputVelocity(int slotID)
Get the mimimum velocity of the SmartMotion mode.CANError
setD(double gain)
Set the Derivative Gain constant of the PIDF controller on the SPARK MAX.CANError
setD(double gain, int slotID)
Set the Derivative Gain constant of the PIDF controller on the SPARK MAX.CANError
setDFilter(double gain)
Set the Derivative Filter constant of the PIDF controller on the SPARK MAX.CANError
setDFilter(double gain, int slotID)
Set the Derivative Filter constant of the PIDF controller on the SPARK MAX.CANError
setFeedbackDevice(CANSensor sensor)
Set the controller's feedback device.CANError
setFF(double gain)
Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX.CANError
setFF(double gain, int slotID)
Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX.CANError
setI(double gain)
Set the Integral Gain constant of the PIDF controller on the SPARK MAX.CANError
setI(double gain, int slotID)
Set the Integral Gain constant of the PIDF controller on the SPARK MAX.CANError
setIAccum(double iAccum)
Set the I accumulator of the PID controller.CANError
setIMaxAccum(double iMaxAccum, int slotID)
Configure the maximum I accumulator of the PID controller.CANError
setIZone(double IZone)
Set the IZone range of the PIDF controller on the SPARK MAX.CANError
setIZone(double IZone, int slotID)
Set the IZone range of the PIDF controller on the SPARK MAX.CANError
setOutputRange(double min, double max)
Set the min amd max output for the closed loop mode.CANError
setOutputRange(double min, double max, int slotID)
Set the min amd max output for the closed loop mode.CANError
setP(double gain)
Set the Proportional Gain constant of the PIDF controller on the SPARK MAX.CANError
setP(double gain, int slotID)
Set the Proportional Gain constant of the PIDF controller on the SPARK MAX.CANError
setReference(double value, ControlType ctrl)
Set the controller reference value based on the selected control mode.CANError
setReference(double value, ControlType ctrl, int pidSlot)
Set the controller reference value based on the selected control mode.CANError
setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward)
Set the controller reference value based on the selected control mode.CANError
setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, CANPIDController.ArbFFUnits arbFFUnits)
Set the controller reference value based on the selected control mode.CANError
setSmartMotionAccelStrategy(CANPIDController.AccelStrategy accelStrategy, int slotID)
Coming soon.CANError
setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID)
Configure the allowed closed loop error of SmartMotion mode.CANError
setSmartMotionMaxAccel(double maxAccel, int slotID)
Configure the maximum acceleration of the SmartMotion mode.CANError
setSmartMotionMaxVelocity(double maxVel, int slotID)
Configure the maximum velocity of the SmartMotion mode.CANError
setSmartMotionMinOutputVelocity(double minVel, int slotID)
Configure the mimimum velocity of the SmartMotion mode.
-
-
-
Constructor Detail
-
CANPIDController
public CANPIDController(CANSparkMax device)
Constructs a CANPIDController.- Parameters:
device
- The Spark Max this object configures.
-
-
Method Detail
-
setReference
public CANError setReference(double value, ControlType ctrl)
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). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder classctrl
- Is the control type- Returns:
- CANError Set to REV_OK if successful
-
setReference
public CANError setReference(double value, ControlType ctrl, int pidSlot)
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.- 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:
- CANError Set to REV_OK if successful
-
setReference
public CANError setReference(double value, 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.- 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:
- CANError Set to REV_OK if successful
-
setReference
public CANError setReference(double value, ControlType ctrl, int pidSlot, double arbFeedforward, CANPIDController.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.- 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:
- CANError Set to REV_OK if successful
-
setP
public CANError setP(double gain)
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- Returns:
- CANError Set to REV_OK if successful
-
setP
public CANError setP(double gain, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
setI
public CANError setI(double gain)
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- Returns:
- CANError Set to REV_OK if successful
-
setI
public CANError setI(double gain, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
setD
public CANError setD(double gain)
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- Returns:
- CANError Set to REV_OK if successful
-
setD
public CANError setD(double gain, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
setDFilter
public CANError setDFilter(double gain)
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- Returns:
- CANError Set to REV_OK if successful
-
setDFilter
public CANError setDFilter(double gain, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
setFF
public CANError setFF(double gain)
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- Returns:
- CANError Set to REV_OK if successful
-
setFF
public CANError setFF(double gain, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
setIZone
public CANError setIZone(double IZone)
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:
IZone
- The IZone value, must be positive. Set to 0 to disable- Returns:
- CANError Set to REV_OK if successful
-
setIZone
public CANError setIZone(double IZone, int slotID)
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:
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:
- CANError Set to REV_OK if successful
-
setOutputRange
public CANError setOutputRange(double min, double max)
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 outputmax
- Forward power maximum to allow the controller to output- Returns:
- CANError Set to REV_OK if successful
-
setOutputRange
public CANError setOutputRange(double min, double max, int slotID)
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 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:
- CANError Set to REV_OK if successful
-
getP
public double 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)- Returns:
- double P Gain value
-
getP
public double getP(int slotID)
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
-
getI
public double 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)- Returns:
- double I Gain value
-
getI
public double getI(int slotID)
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
-
getD
public double 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)- Returns:
- double D Gain value
-
getD
public double getD(int slotID)
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
public double getDFilter(int slotID)
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
public double 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)- Returns:
- double F Gain value
-
getFF
public double getFF(int slotID)
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
-
getIZone
public double 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)- Returns:
- double IZone value
-
getIZone
public double getIZone(int slotID)
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
-
getOutputMin
public double 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)- Returns:
- double min value
-
getOutputMin
public double getOutputMin(int slotID)
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
-
getOutputMax
public double 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)- Returns:
- double max value
-
getOutputMax
public double getOutputMax(int slotID)
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
-
setSmartMotionMaxVelocity
public CANError setSmartMotionMaxVelocity(double maxVel, int slotID)
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 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:
- CANError Set to kOK if successful
-
setSmartMotionMaxAccel
public CANError setSmartMotionMaxAccel(double maxAccel, int slotID)
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 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:
- CANError Set to kOK if successful
-
setSmartMotionMinOutputVelocity
public CANError setSmartMotionMinOutputVelocity(double minVel, int slotID)
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 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:
- CANError Set to kOK if successful
-
setSmartMotionAllowedClosedLoopError
public CANError setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID)
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 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:
- CANError Set to kOK if successful
-
setSmartMotionAccelStrategy
public CANError setSmartMotionAccelStrategy(CANPIDController.AccelStrategy accelStrategy, int slotID)
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 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:
- CANError Set to kOK if successful
-
getSmartMotionMaxVelocity
public double getSmartMotionMaxVelocity(int slotID)
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
-
getSmartMotionMaxAccel
public double getSmartMotionMaxAccel(int slotID)
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
-
getSmartMotionMinOutputVelocity
public double getSmartMotionMinOutputVelocity(int slotID)
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
-
getSmartMotionAllowedClosedLoopError
public double getSmartMotionAllowedClosedLoopError(int slotID)
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
-
getSmartMotionAccelStrategy
public CANPIDController.AccelStrategy getSmartMotionAccelStrategy(int slotID)
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.
-
setIMaxAccum
public CANError setIMaxAccum(double iMaxAccum, int slotID)
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 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:
- CANError Set to kOK if successful
-
getIMaxAccum
public double getIMaxAccum(int slotID)
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
-
setIAccum
public CANError setIAccum(double iAccum)
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
-
getIAccum
public double 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- Returns:
- The value of the I accumulator
-
setFeedbackDevice
public CANError setFeedbackDevice(CANSensor sensor)
Set the controller's feedback device. The 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.- Parameters:
sensor
- The sensor to use as a feedback device- Returns:
- CANError set to kOK if successful
-
-