1 import dynamic_graph
as dg
2 import dynamic_graph.tutorial
as dgt
3 import matplotlib.pyplot
as pl
9 a = dgt.InvertedPendulum(
"IP")
11 a.setPendulumMass(1.0)
12 a.setPendulumLength(1.0)
14 b = dgt.FeedbackController(
"K")
17 stateOut = a.signal(
"state")
18 forceIn = a.signal(
"force")
19 stateIn = b.signal(
"state")
20 forceOut = b.signal(
"force")
22 dg.plug(stateOut, stateIn)
23 dg.plug(forceOut, forceIn)
29 s.value = np.array((0.0, 0.1, 0.0, 0.0))
31 gain = np.array((0.0, 27.0, 0.001, 0.001))
47 for x
in range(nbSteps):
50 values.append(s.value)
51 forces.append(f.value)
55 x = np.array(timeSteps)
56 y = np.array(values).transpose()
59 ax1 = fig.add_subplot(121)
60 ax2 = fig.add_subplot(122)
71 ax1.legend((
"x",
"theta"))
72 ax2.legend((
"dx",
"dtheta",
"force"))
77 if __name__ ==
"__main__":