rename jar.$target to java.test.$target
[liba.git] / python / test / pid_neuro.py
blobc5a2334cf0718834a0ef64e49c4a5aaa25a6626f
1 #!/usr/bin/env python
2 import os, sys
4 base = os.path.dirname(__file__)
5 path = os.path.dirname(base)
6 sys.path.insert(0, path)
7 if len(sys.argv) > 1:
8 sys.stdout = open(sys.argv[1], "w")
10 import liba # type: ignore
12 Ts = 0.001
14 k = 4000
15 kp = 4
16 ki = 0.04
17 kd = 1.0
18 wp = 1
19 wi = 0
20 wd = 0
22 num = [6.59492796e-05, 6.54019884e-05]
23 den = [1.0, -1.97530991, 0.97530991]
25 tf = liba.tf(num, den[1:])
26 pid_neuro = liba.pid_neuro().kpid(k, kp, ki, kd).wpid(wp, wi, wd)
28 t = 0
29 x = []
30 while t <= 0.2:
31 x.append(t)
32 t += Ts
34 r = 1
35 y = 0
36 for i in range(len(x)):
37 y = tf(pid_neuro.inc(r, y))
38 print("%g,%g" % (x[i], y))
40 pid_neuro.k = pid_neuro.k
41 pid_neuro.kp = pid_neuro.kp
42 pid_neuro.ki = pid_neuro.ki
43 pid_neuro.kd = pid_neuro.kd
44 pid_neuro.wp = pid_neuro.wp
45 pid_neuro.wi = pid_neuro.wi
46 pid_neuro.wd = pid_neuro.wd
47 pid_neuro.outmax = pid_neuro.outmax
48 pid_neuro.outmin = pid_neuro.outmin
49 pid_neuro.out
50 pid_neuro.fdb
51 pid_neuro.err
52 pid_neuro.ec