sparkcan Documentation  1.0
PIDController.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 #include "SparkBase.hpp"
9 
18 {
19 private:
20  SparkBase &sparkBase;
21 
22 public:
28  explicit PIDController(SparkBase &base);
29 
35  void SetReference(float setpoint, CtrlType controlType);
36 
42  void SetFeedbackDevice(uint16_t sensor);
43 
50  void SetP(uint8_t slot, float p);
51 
58  void SetI(uint8_t slot, float i);
59 
66  void SetD(uint8_t slot, float d);
67 
74  void SetF(uint8_t slot, float f);
75 
82  void SetIZone(uint8_t slot, float iZone);
83 
90  void SetDFilter(uint8_t slot, float dFilter);
91 
98  void SetOutputMin(uint8_t slot, float min);
99 
106  void SetOutputMax(uint8_t slot, float max);
107 
114  void SetSmartMotionMaxVelocity(uint8_t slot, float maxVel);
115 
122  void SetSmartMotionMaxAccel(uint8_t slot, float maxAccel);
123 
130  void SetSmartMotionMinVelOutput(uint8_t slot, float minVel);
131 
138  void SetSmartMotionAllowedClosedLoopError(uint8_t slot, float error);
139 
146  void SetSmartMotionAccelStrategy(uint8_t slot, float strategy);
147 
154  void SetIMaxAccum(uint8_t slot, float maxAccum);
155 
162  void SetSlot3Placeholder1(uint8_t slot, float value);
163 
170  void SetSlot3Placeholder2(uint8_t slot, float value);
171 
178  void SetSlot3Placeholder3(uint8_t slot, float value);
179 
185  void SetPositionPIDWrapEnable(bool enable);
186 
192  void SetPositionPIDMinInput(float minInput);
193 
199  void SetPositionPIDMaxInput(float maxInput);
200 
201  // Get PID Parameters
202 
208  uint16_t GetFeedbackDevice();
209 
216  float GetP(uint8_t slot);
217 
224  float GetI(uint8_t slot);
225 
232  float GetD(uint8_t slot);
233 
240  float GetF(uint8_t slot);
241 
248  float GetIZone(uint8_t slot);
249 
256  float GetDFilter(uint8_t slot);
257 
264  float GetOutputMin(uint8_t slot);
265 
272  float GetOutputMax(uint8_t slot);
273 
280  float GetSmartMotionMaxVelocity(uint8_t slot);
281 
288  float GetSmartMotionMaxAccel(uint8_t slot);
289 
296  float GetSmartMotionMinVelOutput(uint8_t slot);
297 
304  float GetSmartMotionAllowedClosedLoopError(uint8_t slot);
305 
312  float GetSmartMotionAccelStrategy(uint8_t slot);
313 
320  float GetIMaxAccum(uint8_t slot);
321 
328  float GetSlot3Placeholder1(uint8_t slot);
329 
336  float GetSlot3Placeholder2(uint8_t slot);
337 
344  float GetSlot3Placeholder3(uint8_t slot);
345 
352 
358  float GetPositionPIDMinInput();
359 
365  float GetPositionPIDMaxInput();
366 };
Header file for the base class for controlling REV Robotics SPARK motor controllers.
CtrlType
Control type parameter.
Definition: SparkBase.hpp:242
A class for configuring and controlling PID for SPARK motor controllers.
Definition: PIDController.hpp:18
float GetIMaxAccum(uint8_t slot)
Get the maximum accumulated integral for the PID controller.
Definition: PIDController.cpp:215
void SetPositionPIDMinInput(float minInput)
Set the minimum input for position PID control.
Definition: PIDController.cpp:134
float GetSlot3Placeholder1(uint8_t slot)
Get the value of slot 3 placeholder 1.
Definition: PIDController.cpp:220
float GetSmartMotionMaxVelocity(uint8_t slot)
Get the Smart Motion maximum velocity.
Definition: PIDController.cpp:190
void SetFeedbackDevice(uint16_t sensor)
Set the feedback device for the PID controller.
Definition: PIDController.cpp:39
void SetOutputMax(uint8_t slot, float max)
Set the output maximum for the PID controller.
Definition: PIDController.cpp:79
void SetSmartMotionAllowedClosedLoopError(uint8_t slot, float error)
Set the allowed closed-loop error for Smart Motion.
Definition: PIDController.cpp:99
float GetOutputMax(uint8_t slot)
Get the maximum output range.
Definition: PIDController.cpp:185
void SetP(uint8_t slot, float p)
Set the Proportional (P) gain.
Definition: PIDController.cpp:44
void SetSmartMotionMaxAccel(uint8_t slot, float maxAccel)
Set the Smart Motion maximum acceleration.
Definition: PIDController.cpp:89
float GetIZone(uint8_t slot)
Get the Integral Zone (I-Zone).
Definition: PIDController.cpp:170
float GetF(uint8_t slot)
Get the Feedforward (F) gain.
Definition: PIDController.cpp:165
float GetSlot3Placeholder2(uint8_t slot)
Get the value of slot 3 placeholder 2.
Definition: PIDController.cpp:225
float GetSmartMotionMinVelOutput(uint8_t slot)
Get the Smart Motion minimum velocity output.
Definition: PIDController.cpp:200
float GetSmartMotionAccelStrategy(uint8_t slot)
Get the Smart Motion acceleration strategy.
Definition: PIDController.cpp:210
void SetI(uint8_t slot, float i)
Set the Integral (I) gain.
Definition: PIDController.cpp:49
void SetReference(float setpoint, CtrlType controlType)
Set the controller reference value based on the selected control mode.
Definition: PIDController.cpp:17
float GetSmartMotionMaxAccel(uint8_t slot)
Get the Smart Motion maximum acceleration.
Definition: PIDController.cpp:195
float GetOutputMin(uint8_t slot)
Get the minimum output range.
Definition: PIDController.cpp:180
float GetSmartMotionAllowedClosedLoopError(uint8_t slot)
Get the allowed closed-loop error for Smart Motion.
Definition: PIDController.cpp:205
void SetPositionPIDWrapEnable(bool enable)
Enable or disable position PID wrap.
Definition: PIDController.cpp:129
void SetD(uint8_t slot, float d)
Set the Derivative (D) gain.
Definition: PIDController.cpp:54
float GetPositionPIDMinInput()
Get the minimum input for position PID control.
Definition: PIDController.cpp:240
void SetIZone(uint8_t slot, float iZone)
Set the Integral Zone (I-Zone) for the PID controller.
Definition: PIDController.cpp:64
float GetDFilter(uint8_t slot)
Get the Derivative Filter value.
Definition: PIDController.cpp:175
float GetPositionPIDMaxInput()
Get the maximum input for position PID control.
Definition: PIDController.cpp:245
void SetPositionPIDMaxInput(float maxInput)
Set the maximum input for position PID control.
Definition: PIDController.cpp:139
void SetSmartMotionAccelStrategy(uint8_t slot, float strategy)
Set the acceleration strategy for Smart Motion.
Definition: PIDController.cpp:104
float GetI(uint8_t slot)
Get the Integral (I) gain.
Definition: PIDController.cpp:155
void SetDFilter(uint8_t slot, float dFilter)
Set the Derivative Filter for the PID controller.
Definition: PIDController.cpp:69
void SetIMaxAccum(uint8_t slot, float maxAccum)
Set the maximum accumulated integral for the PID controller.
Definition: PIDController.cpp:109
void SetSlot3Placeholder2(uint8_t slot, float value)
Set the placeholder parameter in slot 3, position 2.
Definition: PIDController.cpp:119
void SetSmartMotionMaxVelocity(uint8_t slot, float maxVel)
Set the Smart Motion maximum velocity.
Definition: PIDController.cpp:84
uint16_t GetFeedbackDevice()
Get the feedback device ID.
Definition: PIDController.cpp:145
float GetSlot3Placeholder3(uint8_t slot)
Get the value of slot 3 placeholder 3.
Definition: PIDController.cpp:230
void SetF(uint8_t slot, float f)
Set the Feedforward (F) gain.
Definition: PIDController.cpp:59
float GetP(uint8_t slot)
Get the Proportional (P) gain.
Definition: PIDController.cpp:150
bool GetPositionPIDWrapEnable()
Get whether position PID wrap is enabled.
Definition: PIDController.cpp:235
void SetSmartMotionMinVelOutput(uint8_t slot, float minVel)
Set the Smart Motion minimum velocity output.
Definition: PIDController.cpp:94
void SetSlot3Placeholder1(uint8_t slot, float value)
Set the placeholder parameter in slot 3, position 1.
Definition: PIDController.cpp:114
void SetSlot3Placeholder3(uint8_t slot, float value)
Set the placeholder parameter in slot 3, position 3.
Definition: PIDController.cpp:124
float GetD(uint8_t slot)
Get the Derivative (D) gain.
Definition: PIDController.cpp:160
PIDController(SparkBase &base)
Construct a PIDController from a SparkBase object.
Definition: PIDController.cpp:14
void SetOutputMin(uint8_t slot, float min)
Set the output minimum for the PID controller.
Definition: PIDController.cpp:74
A base class for controlling REV Robotics SPARK motor controllers via CAN bus.
Definition: SparkBase.hpp:266