|
sparkcan Documentation
1.0
|
A class for configuring and controlling PID for SPARK motor controllers. More...
#include <PIDController.hpp>
Public Member Functions | |
| PIDController (SparkBase &base) | |
| Construct a PIDController from a SparkBase object. More... | |
| void | SetReference (float setpoint, CtrlType controlType) |
| Set the controller reference value based on the selected control mode. More... | |
| void | SetFeedbackDevice (uint16_t sensor) |
| Set the feedback device for the PID controller. More... | |
| void | SetP (uint8_t slot, float p) |
| Set the Proportional (P) gain. More... | |
| void | SetI (uint8_t slot, float i) |
| Set the Integral (I) gain. More... | |
| void | SetD (uint8_t slot, float d) |
| Set the Derivative (D) gain. More... | |
| void | SetF (uint8_t slot, float f) |
| Set the Feedforward (F) gain. More... | |
| void | SetIZone (uint8_t slot, float iZone) |
| Set the Integral Zone (I-Zone) for the PID controller. More... | |
| void | SetDFilter (uint8_t slot, float dFilter) |
| Set the Derivative Filter for the PID controller. More... | |
| void | SetOutputMin (uint8_t slot, float min) |
| Set the output minimum for the PID controller. More... | |
| void | SetOutputMax (uint8_t slot, float max) |
| Set the output maximum for the PID controller. More... | |
| void | SetSmartMotionMaxVelocity (uint8_t slot, float maxVel) |
| Set the Smart Motion maximum velocity. More... | |
| void | SetSmartMotionMaxAccel (uint8_t slot, float maxAccel) |
| Set the Smart Motion maximum acceleration. More... | |
| void | SetSmartMotionMinVelOutput (uint8_t slot, float minVel) |
| Set the Smart Motion minimum velocity output. More... | |
| void | SetSmartMotionAllowedClosedLoopError (uint8_t slot, float error) |
| Set the allowed closed-loop error for Smart Motion. More... | |
| void | SetSmartMotionAccelStrategy (uint8_t slot, float strategy) |
| Set the acceleration strategy for Smart Motion. More... | |
| void | SetIMaxAccum (uint8_t slot, float maxAccum) |
| Set the maximum accumulated integral for the PID controller. More... | |
| void | SetSlot3Placeholder1 (uint8_t slot, float value) |
| Set the placeholder parameter in slot 3, position 1. More... | |
| void | SetSlot3Placeholder2 (uint8_t slot, float value) |
| Set the placeholder parameter in slot 3, position 2. More... | |
| void | SetSlot3Placeholder3 (uint8_t slot, float value) |
| Set the placeholder parameter in slot 3, position 3. More... | |
| void | SetPositionPIDWrapEnable (bool enable) |
| Enable or disable position PID wrap. More... | |
| void | SetPositionPIDMinInput (float minInput) |
| Set the minimum input for position PID control. More... | |
| void | SetPositionPIDMaxInput (float maxInput) |
| Set the maximum input for position PID control. More... | |
| uint16_t | GetFeedbackDevice () |
| Get the feedback device ID. More... | |
| float | GetP (uint8_t slot) |
| Get the Proportional (P) gain. More... | |
| float | GetI (uint8_t slot) |
| Get the Integral (I) gain. More... | |
| float | GetD (uint8_t slot) |
| Get the Derivative (D) gain. More... | |
| float | GetF (uint8_t slot) |
| Get the Feedforward (F) gain. More... | |
| float | GetIZone (uint8_t slot) |
| Get the Integral Zone (I-Zone). More... | |
| float | GetDFilter (uint8_t slot) |
| Get the Derivative Filter value. More... | |
| float | GetOutputMin (uint8_t slot) |
| Get the minimum output range. More... | |
| float | GetOutputMax (uint8_t slot) |
| Get the maximum output range. More... | |
| float | GetSmartMotionMaxVelocity (uint8_t slot) |
| Get the Smart Motion maximum velocity. More... | |
| float | GetSmartMotionMaxAccel (uint8_t slot) |
| Get the Smart Motion maximum acceleration. More... | |
| float | GetSmartMotionMinVelOutput (uint8_t slot) |
| Get the Smart Motion minimum velocity output. More... | |
| float | GetSmartMotionAllowedClosedLoopError (uint8_t slot) |
| Get the allowed closed-loop error for Smart Motion. More... | |
| float | GetSmartMotionAccelStrategy (uint8_t slot) |
| Get the Smart Motion acceleration strategy. More... | |
| float | GetIMaxAccum (uint8_t slot) |
| Get the maximum accumulated integral for the PID controller. More... | |
| float | GetSlot3Placeholder1 (uint8_t slot) |
| Get the value of slot 3 placeholder 1. More... | |
| float | GetSlot3Placeholder2 (uint8_t slot) |
| Get the value of slot 3 placeholder 2. More... | |
| float | GetSlot3Placeholder3 (uint8_t slot) |
| Get the value of slot 3 placeholder 3. More... | |
| bool | GetPositionPIDWrapEnable () |
| Get whether position PID wrap is enabled. More... | |
| float | GetPositionPIDMinInput () |
| Get the minimum input for position PID control. More... | |
| float | GetPositionPIDMaxInput () |
| Get the maximum input for position PID control. More... | |
A class for configuring and controlling PID for SPARK motor controllers.
This class provides methods for setting and getting various PID parameters such as P, I, D, F gains, and other control parameters specific to Smart Motion and position control.
|
explicit |
Construct a PIDController from a SparkBase object.
Constructor that initializes a PIDController with a reference to a SparkBase object.
| base | The SparkBase object associated with this PIDController. |
| float PIDController::GetD | ( | uint8_t | slot | ) |
Get the Derivative (D) gain.
| slot | The PID slot (0-3). |
| float PIDController::GetDFilter | ( | uint8_t | slot | ) |
Get the Derivative Filter value.
| slot | The PID slot (0-3). |
| float PIDController::GetF | ( | uint8_t | slot | ) |
Get the Feedforward (F) gain.
| slot | The PID slot (0-3). |
| uint16_t PIDController::GetFeedbackDevice | ( | ) |
Get the feedback device ID.
| float PIDController::GetI | ( | uint8_t | slot | ) |
Get the Integral (I) gain.
| slot | The PID slot (0-3). |
| float PIDController::GetIMaxAccum | ( | uint8_t | slot | ) |
Get the maximum accumulated integral for the PID controller.
| slot | The PID slot (0-3). |
| float PIDController::GetIZone | ( | uint8_t | slot | ) |
Get the Integral Zone (I-Zone).
| slot | The PID slot (0-3). |
| float PIDController::GetOutputMax | ( | uint8_t | slot | ) |
Get the maximum output range.
| slot | The PID slot (0-3). |
| float PIDController::GetOutputMin | ( | uint8_t | slot | ) |
Get the minimum output range.
| slot | The PID slot (0-3). |
| float PIDController::GetP | ( | uint8_t | slot | ) |
Get the Proportional (P) gain.
| slot | The PID slot (0-3). |
| float PIDController::GetPositionPIDMaxInput | ( | ) |
Get the maximum input for position PID control.
| float PIDController::GetPositionPIDMinInput | ( | ) |
Get the minimum input for position PID control.
| bool PIDController::GetPositionPIDWrapEnable | ( | ) |
Get whether position PID wrap is enabled.
| float PIDController::GetSlot3Placeholder1 | ( | uint8_t | slot | ) |
Get the value of slot 3 placeholder 1.
| slot | The PID slot (0-3). |
| float PIDController::GetSlot3Placeholder2 | ( | uint8_t | slot | ) |
Get the value of slot 3 placeholder 2.
| slot | The PID slot (0-3). |
| float PIDController::GetSlot3Placeholder3 | ( | uint8_t | slot | ) |
Get the value of slot 3 placeholder 3.
| slot | The PID slot (0-3). |
| float PIDController::GetSmartMotionAccelStrategy | ( | uint8_t | slot | ) |
Get the Smart Motion acceleration strategy.
| slot | The Smart Motion slot (0-3). |
| float PIDController::GetSmartMotionAllowedClosedLoopError | ( | uint8_t | slot | ) |
Get the allowed closed-loop error for Smart Motion.
| slot | The Smart Motion slot (0-3). |
| float PIDController::GetSmartMotionMaxAccel | ( | uint8_t | slot | ) |
Get the Smart Motion maximum acceleration.
| slot | The Smart Motion slot (0-3). |
| float PIDController::GetSmartMotionMaxVelocity | ( | uint8_t | slot | ) |
Get the Smart Motion maximum velocity.
| slot | The Smart Motion slot (0-3). |
| float PIDController::GetSmartMotionMinVelOutput | ( | uint8_t | slot | ) |
Get the Smart Motion minimum velocity output.
| slot | The Smart Motion slot (0-3). |
| void PIDController::SetD | ( | uint8_t | slot, |
| float | d | ||
| ) |
Set the Derivative (D) gain.
| slot | The PID slot (0-3). |
| d | The D gain value. |
| void PIDController::SetDFilter | ( | uint8_t | slot, |
| float | dFilter | ||
| ) |
Set the Derivative Filter for the PID controller.
| slot | The PID slot (0-3). |
| dFilter | The D-Filter value. |
| void PIDController::SetF | ( | uint8_t | slot, |
| float | f | ||
| ) |
Set the Feedforward (F) gain.
| slot | The PID slot (0-3). |
| f | The F gain value. |
| void PIDController::SetFeedbackDevice | ( | uint16_t | sensor | ) |
Set the feedback device for the PID controller.
| sensor | The feedback sensor device. |
| void PIDController::SetI | ( | uint8_t | slot, |
| float | i | ||
| ) |
Set the Integral (I) gain.
| slot | The PID slot (0-3). |
| i | The I gain value. |
| void PIDController::SetIMaxAccum | ( | uint8_t | slot, |
| float | maxAccum | ||
| ) |
Set the maximum accumulated integral for the PID controller.
| slot | The PID slot (0-3). |
| maxAccum | The maximum accumulated integral value. |
| void PIDController::SetIZone | ( | uint8_t | slot, |
| float | iZone | ||
| ) |
Set the Integral Zone (I-Zone) for the PID controller.
| slot | The PID slot (0-3). |
| iZone | The I-Zone value. |
| void PIDController::SetOutputMax | ( | uint8_t | slot, |
| float | max | ||
| ) |
Set the output maximum for the PID controller.
| slot | The PID slot (0-3). |
| max | The maximum output value. |
| void PIDController::SetOutputMin | ( | uint8_t | slot, |
| float | min | ||
| ) |
Set the output minimum for the PID controller.
| slot | The PID slot (0-3). |
| min | The minimum output value. |
| void PIDController::SetP | ( | uint8_t | slot, |
| float | p | ||
| ) |
Set the Proportional (P) gain.
| slot | The PID slot (0-3). |
| p | The P gain value. |
| void PIDController::SetPositionPIDMaxInput | ( | float | maxInput | ) |
Set the maximum input for position PID control.
| maxInput | The maximum input value. |
| void PIDController::SetPositionPIDMinInput | ( | float | minInput | ) |
Set the minimum input for position PID control.
| minInput | The minimum input value. |
| void PIDController::SetPositionPIDWrapEnable | ( | bool | enable | ) |
Enable or disable position PID wrap.
| enable | True to enable, false to disable. |
| void PIDController::SetReference | ( | float | setpoint, |
| CtrlType | controlType | ||
| ) |
Set the controller reference value based on the selected control mode.
| controlType | CtrlType::kDutyCycle for Duty Cycle, CtrlType::kVelocity for Velocity, CtrlType::kVoltage for Voltage, CtrlType::kPosition for Position |
| void PIDController::SetSlot3Placeholder1 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Set the placeholder parameter in slot 3, position 1.
| slot | The PID slot (0-3). |
| value | The value for the placeholder. |
| void PIDController::SetSlot3Placeholder2 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Set the placeholder parameter in slot 3, position 2.
| slot | The PID slot (0-3). |
| value | The value for the placeholder. |
| void PIDController::SetSlot3Placeholder3 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Set the placeholder parameter in slot 3, position 3.
| slot | The PID slot (0-3). |
| value | The value for the placeholder. |
| void PIDController::SetSmartMotionAccelStrategy | ( | uint8_t | slot, |
| float | strategy | ||
| ) |
Set the acceleration strategy for Smart Motion.
| slot | The Smart Motion slot (0-3). |
| strategy | The acceleration strategy. |
| void PIDController::SetSmartMotionAllowedClosedLoopError | ( | uint8_t | slot, |
| float | error | ||
| ) |
Set the allowed closed-loop error for Smart Motion.
| slot | The Smart Motion slot (0-3). |
| error | The allowed closed-loop error. |
| void PIDController::SetSmartMotionMaxAccel | ( | uint8_t | slot, |
| float | maxAccel | ||
| ) |
Set the Smart Motion maximum acceleration.
| slot | The Smart Motion slot (0-3). |
| maxAccel | The maximum acceleration. |
| void PIDController::SetSmartMotionMaxVelocity | ( | uint8_t | slot, |
| float | maxVel | ||
| ) |
Set the Smart Motion maximum velocity.
| slot | The Smart Motion slot (0-3). |
| maxVel | The maximum velocity. |
| void PIDController::SetSmartMotionMinVelOutput | ( | uint8_t | slot, |
| float | minVel | ||
| ) |
Set the Smart Motion minimum velocity output.
| slot | The Smart Motion slot (0-3). |
| minVel | The minimum velocity output. |