aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/transport
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-01-03 11:31:34 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-01-03 11:31:34 -0800
commit68c9dbe69414bb19e0d810304c48dc417d82a4c8 (patch)
treef50f02f89b7d4e3e96a8dc1c1da1bef14e383bec /test/core/transport
parent88d81bffd181d047eefd131acde8b018ee85671b (diff)
Add clamping to pid controller, make arguments more readable
Diffstat (limited to 'test/core/transport')
-rw-r--r--test/core/transport/pid_controller_test.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c
index 3935a25322..af53d5b8cb 100644
--- a/test/core/transport/pid_controller_test.c
+++ b/test/core/transport/pid_controller_test.c
@@ -33,6 +33,7 @@
#include "src/core/lib/transport/pid_controller.h"
+#include <float.h>
#include <math.h>
#include <grpc/support/alloc.h>
@@ -45,7 +46,14 @@
static void test_noop(void) {
gpr_log(GPR_INFO, "test_noop");
grpc_pid_controller pid;
- grpc_pid_controller_init(&pid, 0, 1, 1, 1);
+ grpc_pid_controller_init(
+ &pid, (grpc_pid_controller_args){.gain_p = 1,
+ .gain_i = 1,
+ .gain_d = 1,
+ .initial_control_value = 1,
+ .min_control_value = DBL_MIN,
+ .max_control_value = DBL_MAX,
+ .integral_range = DBL_MAX});
}
static void test_simple_convergence(double gain_p, double gain_i, double gain_d,
@@ -55,7 +63,14 @@ static void test_simple_convergence(double gain_p, double gain_i, double gain_d,
"start=%lf",
gain_p, gain_i, gain_d, dt, set_point, start);
grpc_pid_controller pid;
- grpc_pid_controller_init(&pid, start, 0.2, 0.1, 0.1);
+ grpc_pid_controller_init(
+ &pid, (grpc_pid_controller_args){.gain_p = gain_p,
+ .gain_i = gain_i,
+ .gain_d = gain_d,
+ .initial_control_value = start,
+ .min_control_value = DBL_MIN,
+ .max_control_value = DBL_MAX,
+ .integral_range = DBL_MAX});
for (int i = 0; i < 1000; i++) {
grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid),