bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::control::PIDController Class Reference

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

Detailed Description

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.

Member Typedef Documentation

◆ ctrl_signal_type

Constructor & Destructor Documentation

◆ PIDController()

bitsim::control::PIDController::PIDController ( real_t Kp,
real_t Ki,
real_t Kd )
inline
Parameters
KpThe proportional gain
KiThe integral gain
KdThe derivative gain

Member Function Documentation

◆ compute_ctrl_signal()

real_t bitsim::control::PIDController::compute_ctrl_signal ( real_t current,
real_t target,
real_t dt )
Parameters
currentThe value the controlled system has now
targetThe value it should have
dtThe time since the last call [s], positive
Returns
The control signal

◆ get_kd()

real_t bitsim::control::PIDController::get_kd ( ) const
inlinenoexcept

◆ get_ki()

real_t bitsim::control::PIDController::get_ki ( ) const
inlinenoexcept

◆ get_kp()

real_t bitsim::control::PIDController::get_kp ( ) const
inlinenoexcept

◆ integral()

real_t bitsim::control::PIDController::integral ( ) const
inlinenoexcept

◆ is_limited()

bool bitsim::control::PIDController::is_limited ( ) const
inlinenoexcept

Test the is_limited_ flag

Returns
True is the set_control_limits has been called

◆ reset()

void bitsim::control::PIDController::reset ( )
inlinenoexcept

Forget the integral and the last error.

◆ set_control_limits()

void bitsim::control::PIDController::set_control_limits ( std::pair< real_t, real_t > limits)
inline

Limit the output to [limits.first, limits.second].


The documentation for this class was generated from the following files: