-
Notifications
You must be signed in to change notification settings - Fork 164
/
RollingWheel.mo
144 lines (132 loc) · 5.16 KB
/
RollingWheel.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
within Modelica.Mechanics.MultiBody.Parts;
model RollingWheel
"Ideal rolling wheel on flat surface z=0 (5 positional, 3 velocity degrees of freedom)"
parameter Boolean animation=true
"= true, if animation of wheel shall be enabled";
parameter SI.Radius radius "Radius of wheel";
parameter SI.Mass m "Mass of wheel";
parameter SI.Inertia I_axis "Inertia along the wheel axis";
parameter SI.Inertia I_long "Inertia perpendicular to the wheel axis";
parameter StateSelect stateSelect=StateSelect.always
"Priority to use generalized coordinates as states"
annotation (HideResult=true, Evaluate=true);
SI.Position x(
start=0,
fixed=true,
stateSelect=stateSelect) "x-coordinate of wheel axis";
SI.Position y(
start=0,
fixed=true,
stateSelect=stateSelect) "y-coordinate of wheel axis";
SI.Angle angles[3](
start={0,0,0},
each fixed=true,
each stateSelect=stateSelect)
"Angles to rotate world-frame in to frame_a around z-, y-, x-axis"
annotation (Dialog(group="Initialization",showStartAttribute=true));
SI.AngularVelocity der_angles[3](
start={0,0,0},
each fixed=true,
each stateSelect=stateSelect) "Derivative of angles"
annotation (Dialog(group="Initialization",showStartAttribute=true));
parameter SI.Distance width=0.035 "Width of wheel" annotation (Dialog(
tab="Animation",
group="if animation = true",
enable=animation));
parameter Real hollowFraction=0.8
"For ring-like visualization: wheel radius / inner hole radius; i.e. 1.0: completely hollow, 0.0: full disc" annotation (Dialog(
tab="Animation",
group="if animation = true",
enable=animation));
parameter Types.Color color={30,30,30} "Color of wheel"
annotation (Dialog(
colorSelector=true,
tab="Animation",
group="if animation = true",
enable=animation));
Modelica.Mechanics.MultiBody.Parts.Body body(
final r_CM={0,0,0},
final m=m,
final I_11=I_long,
final I_22=I_axis,
final I_33=I_long,
final I_21=0,
final I_31=0,
final I_32=0,
animation=false) annotation (Placement(transformation(extent={{20,-10},{40,10}})));
Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame_a
"Frame fixed in wheel center point (y-axis: along wheel axis, z-axis: upwards)"
annotation (Placement(transformation(extent={{-16,-16},{16,16}})));
Modelica.Mechanics.MultiBody.Joints.RollingWheel rollingWheel(
radius=radius, stateSelect=StateSelect.avoid)
annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
Modelica.Mechanics.MultiBody.Visualizers.FixedShape fixedShape(
final animation=animation,
final r_shape={0,-width,0},
final lengthDirection={0,1,0},
final widthDirection={1,0,0},
final length=2*width,
final width=2*radius,
final height=2*radius,
final color=color,
final extra=hollowFraction,
final shapeType="pipe") if animation
annotation (Placement(transformation(extent={{20,20},{40,40}})));
equation
rollingWheel.x = x;
rollingWheel.y = y;
rollingWheel.angles = angles;
rollingWheel.der_angles = der_angles;
connect(body.frame_a, frame_a) annotation (Line(
points={{20,0},{0,0}},
color={95,95,95},
thickness=0.5));
connect(rollingWheel.frame_a, frame_a) annotation (Line(
points={{-30,0},{0,0}},
color={95,95,95},
thickness=0.5));
connect(fixedShape.frame_a, frame_a) annotation (Line(
points={{20,30},{0,30},{0,0}},
color={95,95,95},
thickness=0.5));
annotation (defaultComponentName="wheel", Icon(coordinateSystem(
preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,-80},{100,-100}},
fillColor={175,175,175},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Ellipse(
extent={{-80,80},{80,-80}},
fillColor={215,215,215},
fillPattern=FillPattern.Sphere,
lineColor={175,175,175}),
Text(
extent={{-150,120},{150,80}},
textString="%name",
textColor={0,0,255}),
Line(
points={{-100,-80},{100,-80}}),
Ellipse(extent={{-80,80},{80,-80}}, lineColor={64,64,64})}),
Documentation(info="<html>
<p>
A wheel rolling on the x-y plane of the world frame including
wheel mass and simple visualization.
The rolling contact is considered being ideal, i.e. there is no
slip between the wheel and the ground.
The wheel can not take off but it can incline toward the ground.
The frame frame_a is placed in the wheel center point and rotates
with the wheel itself. Therefore, a
<a href=\"modelica://Modelica.Mechanics.MultiBody.Joints.Revolute\">rotational joint</a>
with rotation axis <code>n={0,1,0}</code> should be used to
connect the wheel to a carrier.
</p>
<h4>Note</h4>
<p>
To work properly, the gravity acceleration vector g of the world must point in the negative z-axis, i.e.
</p>
<blockquote><pre>
<span style=\"font-family:'Courier New',courier; color:#0000ff;\">inner</span> <span style=\"font-family:'Courier New',courier; color:#ff0000;\">Modelica.Mechanics.MultiBody.World</span> world(n={0,0,-1});
</pre></blockquote>
</html>"));
end RollingWheel;