(* PID controller. The generic parallel one parameterized by *) (* [int] and [filter] functions *) let hybrid pid_par(int)(filter)(p, i, d, u) = c where rec c_p = p *. u and i_p = run int(i, 0.0, u) and c_d = run filter(d, u) and c = c_p +. i_p +. c_d let hybrid pid(n)(p, i, d, u) = pid_par(Cint.int)(Cint.filter(n))(p, i, d, u) (* a generic linear filter parameterized by the integration function *) let hybrid filter(n)(int)(k, u) = udot where rec udot = n *. (u -. f) and f = run int (k, 0.0, udot) (* a wrongly typed function *) (* let hybrid pid(h)(p, i, d, u) = pid_par(Cint.int)(Dint.derivative(h))(p, i, d, u) *)