forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JointSSP.mo
359 lines (348 loc) · 15.4 KB
/
JointSSP.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
within Modelica.Mechanics.MultiBody.Joints.Assemblies;
model JointSSP
"Spherical - spherical - prismatic joint aggregation with mass (no constraints, no potential states)"
import Modelica.Mechanics.MultiBody.Types;
extends Interfaces.PartialTwoFramesDoubleSize;
Modelica.Mechanics.MultiBody.Interfaces.Frame_b frame_ib
"Coordinate system at origin of frame_b fixed at connecting rod of spherical 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 spherical joint in the middle fixed at connecting rod of spherical 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 Boolean showMass=true
"= true, if point mass on rod 1 shall be shown (provided animation = true and rod1Mass > 0)";
parameter SI.Length rod1Length(min=Modelica.Constants.eps, start = 1)
"Distance between the origins of the two spherical joints";
parameter SI.Mass rod1Mass(min=0)=0
"Mass of rod 1 (= point mass located in middle of rod connecting the two spherical joints)";
parameter Modelica.Mechanics.MultiBody.Types.Axis n_b={0,0,1}
"Axis of prismatic joint fixed and resolved in frame_b";
parameter SI.Position rRod2_ib[3]={1,0,0}
"Vector from origin of frame_ib to spherical joint in the middle, resolved in frame_ib";
parameter SI.Position s_offset=0
"Relative distance offset of prismatic joint (distance between frame_b and frame_ib = 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.Diameter sphereDiameter=world.defaultJointLength
"Diameter of the spheres representing the two spherical joints"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color sphereColor=Modelica.Mechanics.MultiBody.Types.Defaults.
JointColor
"Color of the spheres representing the two spherical joints"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
parameter SI.Diameter rod1Diameter=sphereDiameter/Types.Defaults.
JointRodDiameterFraction
"Diameter of rod 1 connecting the two spherical joints"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color rod1Color=Modelica.Mechanics.MultiBody.Types.Defaults.
RodColor "Color of rod 1 connecting the two spherical joint"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
parameter SI.Diameter rod2Diameter=rod1Diameter
"Diameter of rod 2 connecting the revolute joint and spherical joint 2"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color rod2Color=rod1Color
"Color of rod 2 connecting the revolute joint and spherical joint 2"
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 box, 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=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of prismatic joint box"
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"));
Real aux
"Denominator used to compute force in rod connecting universal and spherical joint";
SI.Force f_rod
"Constraint force in direction of the rod (positive, if rod is pressed)";
SI.Power totalPower
"Total power flowing into this element, if checkTotalPower=true (otherwise dummy)";
Modelica.Mechanics.MultiBody.Joints.Internal.PrismaticWithLengthConstraint prismatic(
animation=animation,
length=rod1Length,
n=n_b,
s_offset=s_offset,
s_guess=s_guess,
boxWidthDirection=boxWidthDirection,
boxWidth=boxWidth,
boxHeight=boxHeight,
specularCoefficient=specularCoefficient,
boxColor=boxColor) annotation (Placement(transformation(extent={{75,-20},{35,20}})));
Modelica.Mechanics.MultiBody.Joints.SphericalSpherical rod1(
animation=animation,
showMass=showMass,
m=rod1Mass,
rodLength=rod1Length,
rodDiameter=rod1Diameter,
sphereDiameter=sphereDiameter,
rodColor=rod1Color,
kinematicConstraint=false,
specularCoefficient=specularCoefficient,
sphereColor=sphereColor,
constraintResidue=rod1.f_rod - f_rod) annotation (Placement(transformation(extent={{-89,-20},{-49,20}})));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation rod2(
animation=animation,
width=rod2Diameter,
height=rod2Diameter,
specularCoefficient=specularCoefficient,
color=rod2Color,
r=rRod2_ib) annotation (Placement(transformation(extent={{15,-20},{-25,
20}})));
Sensors.RelativePosition relativePosition(resolveInFrame=Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB.frame_a)
annotation (Placement(transformation(extent={{60,-70},{40,-90}})));
Modelica.Blocks.Sources.Constant position_b[3](k=rRod2_ib)
annotation (Placement(transformation(extent={{-20,-50},{0,-30}})));
equation
/* Compute the unknown force in the rod of the rod1 joint
by a force balance:
0 = frame_b.f + frame_ib.f + frame_im.f +
Frames.resolve2(rod1.R_rel, rod1.f_rod*rod1.eRod_a)
The condition is that the projection of the force in the prismatic
joint along the axis of the prismatic joint is equal to the driving
axis force in the flange:
-prismatic.f = prismatic.e*frame_b.f
Therefore, we have with e=prismatic.e and f=prismatic.f
f = e*(frame_ib.f + frame_im.f +
Frames.resolve2(rod1.R_rel, rod1.f_rod*rod1.eRod_a))
= e*(frame_ib.f + frame_im.f +
rod1.f_rod*Frames.resolve2(rod1.R_rel, rod1.eRod_a))
Solving this equation for f_rod results in
rod1.f_rod = (f - e*(frame_ib.f + frame_im.f))
/ (e*Frames.resolve2(rod1.R_rel, rod1.eRod_a))
Additionally, a guard against division by zero is introduced
*/
aux = prismatic.e*Frames.resolveRelative(rod1.eRod_a, rod1.frame_a.R,
rod1.frame_b.R);
f_rod = (-prismatic.f - prismatic.e*(frame_ib.f + frame_im.f))/
noEvent(if abs(aux) < 1e-10 then 1e-10 else aux);
// Measure power for test purposes
if checkTotalPower then
totalPower = frame_a.f*Frames.resolve2(frame_a.R, der(frame_a.r_0)) +
frame_b.f*Frames.resolve2(frame_b.R, der(frame_b.r_0)) + frame_ib.f*
Frames.resolve2(frame_ib.R, der(frame_ib.r_0)) + frame_im.f*
Frames.resolve2(frame_im.R, der(frame_im.r_0)) + frame_a.t*
Frames.angularVelocity2(frame_a.R) + frame_b.t*
Frames.angularVelocity2(frame_b.R) + frame_ib.t*
Frames.angularVelocity2(frame_ib.R) + frame_im.t*
Frames.angularVelocity2(frame_im.R) + axis.f*der(axis.s) + bearing.f*
der(bearing.s) + (-rod1Mass)*(der(rod1.v_CM_0) -
world.gravityAcceleration(rod1.r_CM_0))*rod1.v_CM_0;
else
totalPower = 0;
end if;
connect(prismatic.frame_b, rod2.frame_a) annotation (Line(
points={{35,0},{15,0}},
color={95,95,95},
thickness=0.5));
connect(rod2.frame_b, rod1.frame_b) annotation (Line(
points={{-25,0},{-49,0}},
color={95,95,95},
thickness=0.5));
connect(prismatic.frame_a, frame_b) annotation (Line(
points={{75,0},{100,0}},
color={95,95,95},
thickness=0.5));
connect(rod2.frame_a, frame_ib) annotation (Line(
points={{15,0},{26,0},{26,70},{80,70},{80,100}},
color={95,95,95},
thickness=0.5));
connect(rod1.frame_a, frame_a) annotation (Line(
points={{-89,0},{-100,0}},
color={95,95,95},
thickness=0.5));
connect(relativePosition.frame_b, frame_a)
annotation (Line(
points={{40,-80},{-95,-80},{-95,0},{-100,0}},
color={95,95,95},
pattern=LinePattern.Dot));
connect(relativePosition.frame_a, frame_b)
annotation (Line(
points={{60,-80},{96,-80},{96,0},{100,0}},
color={95,95,95},
pattern=LinePattern.Dot));
connect(position_b.y, prismatic.position_b) annotation (Line(
points={{1,-40},{20,-40},{20,-12},{31,-12}}, color={0,0,127}));
connect(prismatic.axis, axis) annotation (Line(points={{39,14},{40,14},{
40,60},{90,60},{90,80},{100,80}}));
connect(prismatic.bearing, bearing)
annotation (Line(points={{63,14},{63,40},{100,40}}));
connect(rod2.frame_b, frame_im) annotation (Line(
points={{-25,0},{-35,0},{-35,60},{0,60},{0,100}},
color={95,95,95},
thickness=0.5));
connect(relativePosition.r_rel, prismatic.position_a)
annotation (Line(
points={{50,-69},{50,-50},{90,-50},{90,-12},{79,-12}}, color={0,0,127}));
annotation (
Documentation(info="<html>
<p>
This component consists of a <strong>spherical</strong> joint 1 at frame_a, a <strong>prismatic</strong>
joint at frame_b and a <strong>spherical</strong> joint 2 which is connected via rod 1
to the spherical joint 1 and via rod 2 to the prismatic joint, see the default
animation in the following figure (the axes vectors are not part of the
default animation):
</p>
<div>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Assemblies/JointSSP.png\" alt=\"model Joints.Assemblies.JointSSP\">
</div>
<p>
Besides an optional point mass in the middle of rod 1,
this joint aggregation has no mass and no inertia,
and introduces neither constraints nor potential state variables.
It should be used in kinematic loops whenever possible since
the non-linear system of equations introduced by this joint aggregation
is solved <strong>analytically</strong> (i.e., a solution is always computed, if a
unique solution exists).
</p>
<p>
An additional <strong>frame_ib</strong> is present. It is <strong>fixed</strong> in rod 2
connecting the prismatic and the spherical joint at the side of the prismatic
joint that is connected to this rod (= rod2.frame_a = prismatic.frame_a).
</p>
<p>
An additional <strong>frame_im</strong> is present. It is <strong>fixed</strong> in rod 2
connecting the prismatic and the spherical joint at the side of spherical
joint 2 that is connected to this rod (= rod2.frame_b).
It is always parallel to <strong>frame_ib</strong>.
</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_b and frame_ib of the JointSSP joint
should be parallel to each other when defining an instance of this
component).
</p>
</html>"),
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
initialScale=0.2), graphics={
Rectangle(
extent={{10,6},{61,-6}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={192,192,192}),
Ellipse(
extent={{-100,-24},{-52,24}},
startAngle=70,
endAngle=290,
lineColor={0,0,0},
fillColor={192,192,192},
fillPattern=FillPattern.Sphere,
closure=EllipseClosure.Radial),
Ellipse(
extent={{-94,-18},{-58,18}},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
startAngle=65,
endAngle=295,
lineColor={255,255,255}),
Ellipse(
extent={{-94,-18},{-58,18}},
startAngle=70,
endAngle=290,
lineColor={0,0,0},
closure=EllipseClosure.None),
Ellipse(
extent={{-34,-24},{14,24}},
startAngle=-110,
endAngle=110,
lineColor={0,0,0},
fillColor={192,192,192},
fillPattern=FillPattern.Sphere,
closure=EllipseClosure.Radial),
Ellipse(
extent={{-28,-18},{8,18}},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
startAngle=-115,
endAngle=115,
lineColor={255,255,255}),
Ellipse(
extent={{-28,-18},{8,18}},
startAngle=-110,
endAngle=110,
lineColor={0,0,0},
closure=EllipseClosure.None),
Rectangle(
extent={{-76,5},{-10,-5}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={192,192,192}),
Rectangle(
extent={{50,20},{80,-20}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{80,30},{100,-30}},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{50,14},{80,20}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{80,24},{100,30}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(
points={{50,6},{50,80},{80,80},{80,100}},
color={95,95,95},
thickness=0.5),
Line(
points={{101,80},{80,80}},
color={95,95,95},
thickness=0.5),
Line(
points={{99,40},{90,40},{90,30}},
color={95,95,95},
thickness=0.5),
Ellipse(
extent={{-20,10},{0,-10}},
fillPattern=FillPattern.Sphere,
fillColor={192,192,192}),
Ellipse(
extent={{-86,10},{-66,-10}},
fillPattern=FillPattern.Sphere,
fillColor={192,192,192}),
Line(
points={{14,0},{14,80},{0,80},{0,100}},
color={95,95,95},
thickness=0.5),
Text(
extent={{-43,110},{-10,90}},
textColor={128,128,128},
textString="im"),
Text(
extent={{40,110},{77,90}},
textColor={128,128,128},
textString="ib"),
Text(
extent={{-140,-45},{140,-70}},
textColor={0,0,255},
textString="%name")}));
end JointSSP;