6 static A_INLINE a_float
input(a_float
const x
)
8 #if defined(LIBA_MATH_H)
9 return a_float_sin(4 * A_FLOAT_PI
* x
);
15 int main(int argc
, char *argv
[]) /* NOLINT(misc-definitions-in-headers) */
18 a_float num
[] = {A_FLOAT_C(6.59492796e-05), A_FLOAT_C(6.54019884e-05)};
19 a_float den
[] = {A_FLOAT_C(-1.97530991), A_FLOAT_C(0.97530991)};
22 a_float pos_input
[A_LEN(num
)];
23 a_float pos_output
[A_LEN(den
)];
27 a_float inc_input
[A_LEN(num
)];
28 a_float inc_output
[A_LEN(den
)];
31 main_init(argc
, argv
, 1);
32 a_tf_init(&pos_tf
, A_LEN(num
), num
, pos_input
, A_LEN(den
), den
, pos_output
);
33 a_tf_init(&inc_tf
, A_LEN(num
), num
, inc_input
, A_LEN(den
), den
, inc_output
);
35 pos_pid
.kp
= A_FLOAT_C(100.0);
36 pos_pid
.ki
= A_FLOAT_C(0.01);
37 pos_pid
.kd
= A_FLOAT_C(1200.0);
38 pos_pid
.summax
= +A_FLOAT_MAX
;
39 pos_pid
.summin
= -A_FLOAT_MAX
;
40 pos_pid
.outmax
= +A_FLOAT_MAX
;
41 pos_pid
.outmin
= -A_FLOAT_MAX
;
44 inc_pid
.kp
= A_FLOAT_C(100.0);
45 inc_pid
.ki
= A_FLOAT_C(0.01);
46 inc_pid
.kd
= A_FLOAT_C(1200.0);
47 inc_pid
.outmax
= +A_FLOAT_MAX
;
48 inc_pid
.outmin
= -A_FLOAT_MAX
;
51 for (i
= 0; i
< 100; ++i
)
53 a_float
const ix
= input(A_FLOAT_C(0.001) * a_float_c(i
));
54 a_tf_iter(&pos_tf
, a_pid_pos(&pos_pid
, ix
, *pos_tf
.output
));
55 a_tf_iter(&inc_tf
, a_pid_inc(&inc_pid
, ix
, *inc_tf
.output
));
56 debug("%+" A_FLOAT_PRI
"f,%+" A_FLOAT_PRI
"f,%+" A_FLOAT_PRI
"f,%+" A_FLOAT_PRI
"f\n",
57 A_FLOAT_C(0.001) * a_float_c(i
), ix
, *pos_tf
.output
, *inc_tf
.output
);
60 #if defined(__cplusplus) && (__cplusplus > 201100L)
61 A_BUILD_ASSERT(std::is_pod
<a_pid
>::value
);
62 #endif /* __cplusplus */