-
Notifications
You must be signed in to change notification settings - Fork 164
/
JointRRP.mo
329 lines (321 loc) · 13.7 KB
/
JointRRP.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
within Modelica.Mechanics.MultiBody.Joints.Assemblies;
model JointRRP
"Planar revolute - revolute - prismatic joint aggregation (no constraints, no potential states)"
import Modelica.Mechanics.MultiBody.Types;
import Modelica.Units.Conversions.to_unit1;
extends Interfaces.PartialTwoFramesDoubleSize;
Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame_ia
"Coordinate system at origin of frame_a fixed at connecting rod of revolute joints"
annotation (Placement(transformation(
origin={-80,100},
extent={{-8,-8},{8,8}},
rotation=90)));
Modelica.Mechanics.MultiBody.Interfaces.Frame_b frame_ib
"Coordinate system at origin of frame_b fixed at connecting rod of revolute and prismatic joint"
annotation (Placement(transformation(
origin={80,100},
extent={{-8,8},{8,-8}},
rotation=270)));
Modelica.Mechanics.MultiBody.Interfaces.Frame_b frame_im
"Coordinate system at origin of revolute joint in the middle fixed at connecting rod of revolute and prismatic joint"
annotation (Placement(transformation(
origin={0,100},
extent={{8,-8},{-8,8}},
rotation=270)));
Modelica.Mechanics.Translational.Interfaces.Flange_a axis
"1-dim. translational flange that drives the prismatic joint"
annotation (Placement(transformation(extent={{95,75},{105,85}})));
Modelica.Mechanics.Translational.Interfaces.Flange_b bearing
"1-dim. translational flange of the drive bearing of the prismatic joint"
annotation (Placement(transformation(extent={{105,35},{95,45}})));
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Modelica.Mechanics.MultiBody.Types.Axis n_a={0,0,1}
"Axes of the two revolute joints resolved in frame_a (both axes are parallel to each other)"
annotation (Evaluate=true);
parameter Modelica.Mechanics.MultiBody.Types.Axis n_b={-1,0,0}
"Axis of prismatic joint fixed and resolved in frame_b (must be orthogonal to revolute joint axes)"
annotation (Evaluate=true);
parameter SI.Position rRod1_ia[3]={1,0,0}
"Vector from origin of frame_a to revolute joint in the middle, resolved in frame_ia"
annotation (Evaluate=true);
parameter SI.Position rRod2_ib[3]={-1,0,0}
"Vector from origin of frame_ib to revolute joint in the middle, resolved in frame_ib (frame_ib is parallel to frame_b)";
parameter SI.Position s_offset=0
"Relative distance offset of prismatic joint (distance between the prismatic joint frames = s(t) + s_offset)";
parameter SI.Position s_guess=0
"Select the configuration such that at initial time |s(t0)-s_guess| is minimal";
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of cylinders representing the revolute joints"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of cylinders representing the revolute joints"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color cylinderColor=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of cylinders representing the revolute joints"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
parameter Types.Axis boxWidthDirection={0,1,0}
"Vector in width direction of prismatic joint, resolved in frame_b"
annotation (Evaluate=true, Dialog(tab="Animation", group=
"if animation = true", enable=animation));
parameter SI.Distance boxWidth=world.defaultJointWidth
"Width of prismatic joint box"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance boxHeight=boxWidth "Height of prismatic joint box"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color boxColor=cylinderColor "Color of prismatic joint box"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
parameter SI.Diameter rodDiameter=1.1*cylinderDiameter
"Diameter of the two rods connecting the joints"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color rodColor=Modelica.Mechanics.MultiBody.Types.Defaults.RodColor
"Color of the two rods connecting the joints"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter Boolean checkTotalPower=false
"= true, if total power flowing into this component shall be determined (must be zero)"
annotation (Dialog(tab="Advanced"));
final parameter Real e_a[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(
n_a)
"Unit vector along axes of rotations, resolved in frame_a";
final parameter Real e_ia[3](each final unit="1")=jointUSP.e2_ia
"Unit vector along axes of rotations, resolved in frame_ia";
final parameter Real e_im[3](each final unit="1", each fixed=false)
"Unit vector along axes of rotations, resolved in frame_im";
final parameter Real e_b[3](each final unit="1")=jointUSP.prismatic.e
"Unit vector along axes of translation of the prismatic joint, resolved in frame_b and frame_ib";
SI.Power totalPower=jointUSP.totalPower
"Total power flowing into this element, if checkTotalPower=true (otherwise dummy)";
JointUSP jointUSP(
animation=false,
showUniversalAxes=false,
n1_a=n_a,
n_b=n_b,
s_offset=s_offset,
s_guess=s_guess,
rRod1_ia=rRod1_ia,
rRod2_ib=rRod2_ib,
checkTotalPower=checkTotalPower) annotation (Placement(transformation(
extent={{-30,-20},{10,20}})));
protected
Visualizers.Advanced.Shape shape_rev1(
shapeType="cylinder",
color=cylinderColor,
specularCoefficient=specularCoefficient,
length=cylinderLength,
width=cylinderDiameter,
height=cylinderDiameter,
lengthDirection=e_a,
widthDirection={0,1,0},
r_shape=-e_a*(cylinderLength/2),
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape_rev2(
shapeType="cylinder",
color=cylinderColor,
specularCoefficient=specularCoefficient,
length=cylinderLength,
width=cylinderDiameter,
height=cylinderDiameter,
lengthDirection=e_im,
widthDirection={0,1,0},
r_shape=-e_im*(cylinderLength/2),
r=frame_im.r_0,
R=frame_im.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape_prism(
shapeType="box",
color=boxColor,
specularCoefficient=specularCoefficient,
length=jointUSP.prismatic.distance,
width=boxWidth,
height=boxHeight,
lengthDirection=e_b,
widthDirection=e_im,
r=frame_b.r_0,
R=frame_b.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape_rod1(
shapeType="cylinder",
color=rodColor,
specularCoefficient=specularCoefficient,
length=Modelica.Math.Vectors.length(
rRod1_ia),
width=rodDiameter,
height=rodDiameter,
lengthDirection = to_unit1(rRod1_ia),
widthDirection=e_ia,
r=frame_ia.r_0,
R=frame_ia.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape_rod2(
shapeType="cylinder",
color=rodColor,
specularCoefficient=specularCoefficient,
length=Modelica.Math.Vectors.length(
rRod2_ib),
width=rodDiameter,
height=rodDiameter,
lengthDirection = to_unit1(rRod2_ib),
widthDirection=e_b,
r=frame_ib.r_0,
R=frame_ib.R) if world.enableAnimation and animation;
initial equation
e_im = Frames.resolve2(frame_im.R, Frames.resolve1(frame_a.R, e_a));
equation
connect(jointUSP.frame_a, frame_a)
annotation (Line(
points={{-30,0},{-100,0}},
color={95,95,95},
thickness=0.5));
connect(jointUSP.frame_b, frame_b)
annotation (Line(
points={{10,0},{100,0}},
color={95,95,95},
thickness=0.5));
connect(jointUSP.frame_ia, frame_ia) annotation (Line(
points={{-26,20},{-26,70},{-80,70},{-80,100}},
color={95,95,95},
thickness=0.5));
connect(jointUSP.frame_im, frame_im) annotation (Line(
points={{-10,20},{-10,70},{0,70},{0,100}},
color={95,95,95},
thickness=0.5));
connect(jointUSP.frame_ib, frame_ib) annotation (Line(
points={{6,20},{6,50},{80,50},{80,100}},
color={95,95,95},
thickness=0.5));
connect(jointUSP.axis, axis)
annotation (Line(points={{10,16},{86,16},{86,80},{100,80}}));
connect(jointUSP.bearing, bearing)
annotation (Line(points={{10,8},{94,8},{94,40},{100,40}}));
annotation (
Documentation(info="<html>
<p>
This component consists of <strong>2 revolute</strong> joints with parallel
axes of rotation that and a <strong>prismatic</strong> joint with a translational
axis that is orthogonal to the revolute joint axes, see the default
animation in the following figure (the axes vectors are not part of the
default animation):
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Assemblies/JointRRP.png\" alt=\"model Joints.Assemblies.JointRRP\">
</p>
<p>
This joint aggregation introduces neither constraints nor state variables and
should therefore be used in kinematic loops whenever possible to
avoid non-linear systems of equations. It is only meaningful to
use this component in <strong>planar loops</strong>. Basically, the position
and orientation of the 3 joints as well as of frame_ia, frame_ib, and
frame_im are calculated by solving analytically a non-linear equation,
given the position and orientation at frame_a and at frame_b.
</p>
<p>
Connector <strong>frame_a</strong> is the \"left\" side of the first revolute joint
whereas <strong>frame_ia</strong> is the \"right side of this revolute joint, fixed in rod 1.
Connector <strong>frame_b</strong> is the \"right\" side of the prismatic joint
whereas <strong>frame_ib</strong> is the \"left\" side of this prismatic joint, fixed in rod 2.
Finally, connector <strong>frame_im</strong> is the connector at the \"right\" side
of the revolute joint in the middle, fixed in rod 2. The frames
frame_b, frame_ib, frame_im are always parallel to each other.
</p>
<p>
The easiest way to define the parameters of this joint is by moving the
MultiBody system in a <strong>reference configuration</strong> where <strong>all frames</strong>
of all components are <strong>parallel</strong> to each other (alternatively,
at least frame_a, frame_ia, frame_im, frame_ib, frame_b of the JointRRP joint
should be parallel to each other when defining an instance of this
component).
</p>
<p>
Basically, the JointRRP model consists internally of a universal -
spherical - prismatic joint aggregation (= JointUSP). In a planar
loop this will behave as if 2 revolute joints with parallel axes
and 1 prismatic joint are connected by rigid rods.
</p>
</html>"),
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
initialScale=0.2), graphics={
Rectangle(
extent={{-90,90},{90,-90}},
lineColor={255,255,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Text(
extent={{-139,-53},{141,-78}},
textColor={0,0,255},
textString="%name"),
Text(
extent={{26,124},{68,93}},
textColor={128,128,128},
textString="ib"),
Text(
extent={{-134,128},{-94,94}},
textColor={128,128,128},
textString="ia"),
Ellipse(
extent={{-100,25},{-50,-25}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-85,10},{-65,-10}},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-26,80},{24,30}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-10,66},{10,46}},
fillPattern=FillPattern.Solid),
Polygon(
points={{-71,9},{-24,45},{-19,39},{-66,3},{-71,9}},
fillPattern=FillPattern.Solid),
Polygon(
points={{54,5},{5,47},{8,53},{58,11},{54,5}},
fillPattern=FillPattern.Solid),
Text(
extent={{-128,-29},{139,-47}},
textString="n_a=%n_a"),
Line(
points={{0,57},{0,86},{0,86},{0,100}},
color={95,95,95},
thickness=0.5),
Text(
extent={{-55,126},{-15,92}},
textColor={128,128,128},
textString="im"),
Line(
points={{-80,100},{-80,8}},
color={95,95,95},
thickness=0.5),
Line(
points={{80,80},{101,80}},
color={95,95,95},
thickness=0.5),
Line(
points={{100,40},{93,40},{93,3}},
color={95,95,95},
thickness=0.5),
Rectangle(
extent={{80,15},{100,21}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{53,5},{80,11}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{53,5},{80,-15}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{80,15},{100,-21}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(
points={{80,100},{80,80},{57,11}},
color={95,95,95},
thickness=0.5)}));
end JointRRP;