3#include "gtest/gtest.h"
9TEST(PidTests, TestAntiWindUp1) {
33TEST(PidTests, TestAntiWindUp2) {
57TEST(PidTests, TestAntiWindUp3) {
80TEST(PidTests, ProportionalTerm) {
150TEST(PidTests, DerivativeTerm1) {
163 float measurement = 3;
174TEST(PidTests, DerivativeTerm2) {
187 float measurement = -4;
215 EXPECT_FLOAT_EQ(0.8, pid.
out_);
239 EXPECT_FLOAT_EQ(1, pid.
out_);
263 EXPECT_FLOAT_EQ(-1, pid.
out_);
286 float measurement = 2;
292 pid.
update(setpoint, measurement);
293 EXPECT_NEAR(0.924, pid.
out_, 0.001);
void calculate_integral_term(double error)
Calculate the integral term.
void calculate_derivative_term(double measurement)
Calculate the derivative term (derivative on measurement)
void compute_output()
Compute the output value and apply limits.
double differentiator_
Differentiator term current value.
double proportional_
Proportional term current value.
double update(double setpoint, double measurement)
Calculate the output value.
double out_
Current output value.
double integrator_
Integrator term current value.
void anti_wind_up()
Anti-wind-up via dynamic integrator clamping.
double prev_measurement_
Previous measurement value, required for defferentiator.
double prev_error_
Previous error value, required for integrator.
void calculate_proportional_term(double error)
Calculate the proportional term.
TEST(PidTests, TestAntiWindUp1)
Test PID class - AntiWindUp Anti windup when output is saturated (limMax)
double pid_max_positive_error_
double pid_max_negative_error_