Skip to content

Commit 69a250e

Browse files
committed
pid reset feature, if needed it can be reinitialised to 0
1 parent da9b7a3 commit 69a250e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/common/pid.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ float PIDController::operator() (float error){
5656
timestamp_prev = timestamp_now;
5757
return output;
5858
}
59+
60+
void PIDController::reset(){
61+
integral_prev = 0.0f;
62+
output_prev = 0.0f;
63+
error_prev = 0.0f;
64+
}

src/common/pid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class PIDController
2323
~PIDController() = default;
2424

2525
float operator() (float error);
26+
void reset();
2627

2728
float P; //!< Proportional gain
2829
float I; //!< Integral gain

0 commit comments

Comments
 (0)