FancySafeBot 0.0.1
A safe robotics library
Loading...
Searching...
No Matches
fsb_pid.h
1#ifndef FSB_PID_H
2#define FSB_PID_H
3
4#include <cstdint>
5#include "fsb_types.h"
6
7namespace fsb
8{
9
19enum class PidType : uint8_t
20{
24 TRAPEZOIDAL = 0,
29 BACKWARDS = 1
30};
31
36{
37public:
38 PidController() = default;
39
50 void initialize(
51 Real step_size, Real gain_kp, Real gain_ki, Real gain_kd, Real filter_tf,
53
62 void reset(Real command, Real measured);
63
71 Real evaluate(Real command, Real measured);
72
73private:
75 Real m_kp = 0.0;
77 Real m_ki = 0.0;
79 Real m_kd = 0.0;
81 Real m_tf = 0.0;
83 Real m_step_size = 0.0;
86
88 Real m_e1 = 0.0;
89 Real m_e2 = 0.0;
90 Real m_u1 = 0.0;
91 Real m_u2 = 0.0;
92};
93
98} // namespace fsb
99
100#endif
PID Controller.
Definition fsb_pid.h:36
void reset(Real command, Real measured)
Reset PID to given command and measure.
Definition fsb_pid.cpp:57
Real evaluate(Real command, Real measured)
Evalaute PID.
Definition fsb_pid.cpp:68
void initialize(Real step_size, Real gain_kp, Real gain_ki, Real gain_kd, Real filter_tf, PidType type=PidType::TRAPEZOIDAL)
Initialize PID.
Definition fsb_pid.cpp:40
PidType
Type of discretization.
Definition fsb_pid.h:20
@ BACKWARDS
Backwards difference discretization.
@ TRAPEZOIDAL
Trapezoidal discretization.