bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
pid_controller.h
Go to the documentation of this file.
1#ifndef PID_CONTROLLER_H
2#define PID_CONTROLLER_H
3
4#include "bitrl/bitrl_types.h"
5
6#include <utility>
7
8namespace bitrl
9{
10 namespace control
11 {
19 {
20 public:
21
23
29
30 real_t get_kp()const noexcept{return kp_;}
31 real_t get_ki()const noexcept{return ki_;}
32 real_t get_kd()const noexcept{return kd_;}
33
36 bool is_limited()const noexcept{return is_limited_;}
37
40 void set_control_limits(std::pair<real_t, real_t> limits);
41
48
49 private:
50
51 bool is_limited_{false};
52 real_t kp_;
53 real_t ki_;
54 real_t kd_;
55
56 real_t integral_{0.0};
57 real_t err_old_{0.0};
58 // min = limits.first, max = limits.second
59 std::pair<real_t, real_t> limits_;
60
61 };
62
63 inline
65 :
66 kp_(kp),
67 ki_(ki),
68 kd_(kd)
69 {}
70
71 inline
72 void
73 PIDController::set_control_limits(std::pair<real_t, real_t> limits)
74 {
75 is_limited_ = true;
76 limits_ = limits;
77 }
78 }
79
80}
81
82#endif //PID_CONTROLLER_H
PID controller implementation.
Definition pid_controller.h:19
void set_control_limits(std::pair< real_t, real_t > limits)
Definition pid_controller.h:73
PIDController(real_t Kp, real_t Ki, real_t Kd)
Definition pid_controller.h:64
real_t get_kp() const noexcept
Definition pid_controller.h:30
bool is_limited() const noexcept
Definition pid_controller.h:36
real_t get_ki() const noexcept
Definition pid_controller.h:31
real_t get_kd() const noexcept
Definition pid_controller.h:32
ctrl_signal_type compute_ctrl_signal(real_t current, real_t target, real_t dt)
Definition pid_controller.cpp:10
real_t ctrl_signal_type
Definition pid_controller.h:22
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23