controls  3.0.0
FeedbackController.h
Go to the documentation of this file.
1 #ifndef CONTROLS_CONTROLLER_FEEDBACK_CONTROLLER_H
2 #define CONTROLS_CONTROLLER_FEEDBACK_CONTROLLER_H
3 
5 
15  static constexpr double MAX_DT = 0.1;
16  static constexpr double EXPLODE_THRESHOLD = 1e4;
17  static constexpr double INTEGRAL_CLAMP = 5.0;
18  static constexpr double INTEGRAL_DECAY_FACTOR = 0.5;
19 
20 private:
21  double error_saturation_limit_ = 1;
22 
24  Vector18d e_ = Vector18d::Zero();
25 
26  Vector6d body_integral_error_ = Vector6d::Zero();
27  Vector6d body_pose_error_ = Vector6d::Zero();
28  Vector6d body_twist_error_ = Vector6d::Zero();
29 
31  Vector6d integral_ = Vector6d::Zero();
32 
39  Vector6d saved_integral_ = Vector6d::Zero();
40 
41  Vector6d force_i_ = Vector6d::Zero();
42  Vector6d force_p_ = Vector6d::Zero();
43  Vector6d force_d_ = Vector6d::Zero();
44 
45 public:
47 
50 
53 
57  void reset() override;
58 
63 
73  Vector6d get_force(const State& goal, const State& curr, double dt) override;
74 
80  void save_integral();
81 
85  void load_integral();
86 
92  void ramp_integral(double ratio);
93 
100 
106  Vector6d get_pose_error() const;
107 
113  Vector6d get_twist_error() const;
114 
121 
127  void set_integral(const Vector6d& i);
128 };
129 
130 #endif // CONTROLS_CONTROLLER_FEEDBACK_CONTROLLER_H
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Types.h:29
Eigen::Matrix< double, 18, 1 > Vector18d
Definition: Types.h:30
Abstract base class for a single-responsibility force controller.
Definition: BaseControllerInterface.h:15
BaseControllerInterface()=default
PID feedback controller with anti-windup integral clamping.
Definition: FeedbackController.h:14
void reset_all_except_depth_integral()
Resets all internal state except the depth (Z) integral term.
Definition: FeedbackController.cpp:20
bool saturated_on_depth_roll_pitch_axis_
True when the Z, Roll, or Pitch thruster axes are saturated.
Definition: FeedbackController.h:52
Vector6d get_pose_error() const
Returns the most recently computed body-frame pose error.
Definition: FeedbackController.cpp:236
Vector6d get_twist_error() const
Returns the most recently computed body-frame twist error.
Definition: FeedbackController.cpp:240
void ramp_integral(double ratio)
Interpolates the integral term between its current value and the saved snapshot.
Definition: FeedbackController.cpp:226
Vector6d get_integral_force() const
Returns the most recently computed integral force contribution.
Definition: FeedbackController.cpp:244
void reset() override
Resets all internal state including the integral term.
Definition: FeedbackController.cpp:6
void load_integral()
Restores the integral term from the most recent saved snapshot.
Definition: FeedbackController.cpp:222
Vector6d get_force(const State &goal, const State &curr, double dt) override
Computes the PID feedback force from the goal and current state.
Definition: FeedbackController.cpp:26
void save_integral()
Saves a snapshot of the current integral term for later restoration.
Definition: FeedbackController.cpp:203
Vector6d get_integral_error() const
Returns the most recently computed body-frame integral error.
Definition: FeedbackController.cpp:232
bool saturated_on_yaw_xy_axis_
True when the X, Y, or Yaw thruster axes are saturated.
Definition: FeedbackController.h:49
void set_integral(const Vector6d &i)
Directly sets the integral accumulator.
Definition: FeedbackController.cpp:248
Full kinematic state of the vehicle.
Definition: Types.h:63