|
bitsim
Model, simulate, estimate and control robots in C++
|
A PID controller, \(u = K_p e + K_i \int e\, dt + K_d \dot e\) with \(e\) = target - current, and optional limits on its output. More...
#include <pid_controller.h>
Public Types | |
| using | ctrl_signal_type = real_t |
Public Member Functions | |
| PIDController (real_t Kp, real_t Ki, real_t Kd) | |
| real_t | get_kp () const noexcept |
| real_t | get_ki () const noexcept |
| real_t | get_kd () const noexcept |
| bool | is_limited () const noexcept |
| void | set_control_limits (std::pair< real_t, real_t > limits) |
| Limit the output to [limits.first, limits.second]. | |
| ctrl_signal_type | compute_ctrl_signal (real_t current, real_t target, real_t dt) |
| void | reset () noexcept |
| Forget the integral and the last error. | |
| real_t | integral () const noexcept |
A PID controller, \(u = K_p e + K_i \int e\, dt + K_d \dot e\) with \(e\) = target - current, and optional limits on its output.
The first call after construction or reset() has no derivative term: there is no earlier error to take it from, and taking it from 0 would kick the output. With limits, the integral stops growing while the output is at a limit, so that it does not wind up; see PIController.
| Kp | The proportional gain |
| Ki | The integral gain |
| Kd | The derivative gain |
| real_t bitsim::control::PIDController::compute_ctrl_signal | ( | real_t | current, |
| real_t | target, | ||
| real_t | dt ) |
| current | The value the controlled system has now |
| target | The value it should have |
| dt | The time since the last call [s], positive |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Test the is_limited_ flag
|
inlinenoexcept |
Forget the integral and the last error.
|
inline |
Limit the output to [limits.first, limits.second].