1
2
3 """
4 Realizes the simulation of the inverted pendulum.
5
6 Calculates the simulation in steps of about 10ms.
7 (So we don't need the correct differential equations.)
8
9 Beside the movement is also tries to model static and slipping friction.
10 Both values are set to the same value and simply modeled as force against
11 the movement direction. If the friction force is larger then the driving
12 force (external or own mass in movement) the movement stops.
13
14 Also contains some modifiable parameters.
15 """
16 from simulation import Process,Pendulum
17 import math
18
19
21 """Simulation of real process."""
22
23
25 """Initialize the simulation."""
26 Process.Process.__init__(self)
27 Pendulum.Pendulum.__init__(self)
28
29 self.X = 0.0
30 self.dX_dT = 0.0
31 self.Phi = math.radians(45.0)
32 self.dPhi_dT = 0.0
33
34 self.a = 0.0
35
36 self.l = 1.0
37 self.m = 10.0
38 self.M_P = 0.1
39 self.a_W = 0.1
40
41 self.W = 2.0
42 self.Z = 0.01
43
45 self.X = dict["X"]
46 self.dX_dT = dict["dX_dT"]
47 self.Phi = math.radians(dict["Phi"])
48 self.dPhi_dT = math.radians(dict["dPhi_dT"])
49
51 dict["X"] = self.X
52 dict["dX_dT"] = self.dX_dT
53 dict["Phi"] = math.degrees(self.Phi)
54 dict["dPhi_dT"] = math.degrees(self.dPhi_dT)
55 return dict
56
58 try:
59 self.a = dict["a"]
60 except KeyError:
61 pass
62 return dict
63
65 return {
66 "a":0.0,
67 }
68