forked from modelica/ModelicaStandardLibrary
/
Joints.mo
8700 lines (8265 loc) · 395 KB
/
Joints.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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within Modelica.Mechanics.MultiBody;
package Joints "Components that constrain the motion between two frames"
extends Modelica.Icons.Package;
model Prismatic
"Prismatic joint (1 translational degree-of-freedom, 2 potential states, optional axis flange)"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialElementaryJoint;
Modelica.Mechanics.Translational.Interfaces.Flange_a axis if useAxisFlange
"1-dim. translational flange that drives the joint"
annotation (Placement(transformation(extent={{90,50},{70,70}})));
Modelica.Mechanics.Translational.Interfaces.Flange_b support if useAxisFlange
"1-dim. translational flange of the drive support (assumed to be fixed in the world frame, NOT in the joint)"
annotation (Placement(transformation(extent={{-30,50},{-50,70}})));
parameter Boolean useAxisFlange=false "= true, if axis flange is enabled"
annotation(Evaluate=true, HideResult=true, choices(checkBox=true));
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Modelica.Mechanics.MultiBody.Types.Axis n={1,0,0}
"Axis of translation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter Types.Axis boxWidthDirection={0,1,0}
"Vector in width direction of box, resolved in frame_a"
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 StateSelect stateSelect=StateSelect.prefer
"Priority to use distance s and v=der(s) as states" annotation(Dialog(tab="Advanced"));
final parameter Real e[3](each final unit="1")=
Modelica.Math.Vectors.normalizeWithAssert(n)
"Unit vector in direction of prismatic axis n";
SI.Position s(start=0, final stateSelect=stateSelect)
"Relative distance between frame_a and frame_b"
annotation (unassignedMessage="
The relative distance s of a prismatic joint cannot be determined.
Possible reasons:
- A non-zero mass might be missing on either side of the parts
connected to the prismatic joint.
- Too many StateSelect.always are defined and the model
has less degrees of freedom as specified with this setting
(remove all StateSelect.always settings).
");
SI.Velocity v(start=0,final stateSelect=stateSelect)
"First derivative of s (relative velocity)";
SI.Acceleration a(start=0) "Second derivative of s (relative acceleration)";
SI.Force f "Actuation force in direction of joint axis";
protected
Visualizers.Advanced.Shape box(
shapeType="box",
color=boxColor,
specularCoefficient=specularCoefficient,
length=if noEvent(abs(s) > 1.e-6) then s else 1.e-6,
width=boxWidth,
height=boxHeight,
lengthDirection=e,
widthDirection=boxWidthDirection,
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
Translational.Components.Fixed fixed
annotation (Placement(transformation(extent={{-50,30},{-30,50}})));
Translational.Interfaces.InternalSupport internalAxis(f = f)
annotation (Placement(transformation(extent={{70,50},{90,30}})));
Translational.Sources.ConstantForce constantForce(f_constant=0) if not useAxisFlange
annotation (Placement(transformation(extent={{40,30},{60,50}})));
equation
v = der(s);
a = der(v);
// relationships between kinematic quantities of frame_a and of frame_b
frame_b.r_0 = frame_a.r_0 + Frames.resolve1(frame_a.R, e*s);
frame_b.R = frame_a.R;
// Force and torque balance
zeros(3) = frame_a.f + frame_b.f;
zeros(3) = frame_a.t + frame_b.t + cross(e*s, frame_b.f);
// d'Alemberts principle
f = -e*frame_b.f;
// Connection to internal connectors
s = internalAxis.s;
connect(fixed.flange, support) annotation (Line(
points={{-40,40},{-40,60}}, color={0,127,0}));
connect(internalAxis.flange, axis) annotation (Line(
points={{80,40},{80,60}}, color={0,127,0}));
connect(constantForce.flange, internalAxis.flange) annotation (Line(
points={{60,40},{80,40}}, color={0,127,0}));
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,-50},{-30,41}},
pattern=LinePattern.None,
fillColor={192,192,192},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{-100,40},{-30,50}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{-30,-30},{100,20}},
pattern=LinePattern.None,
fillColor={192,192,192},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(
extent={{-30,20},{100,30}},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(points={{-30,-50},{-30,50}}),
Line(points={{100,-30},{100,21}}),
Text(
extent={{60,12},{96,-13}},
textColor={128,128,128},
textString="b"),
Text(
extent={{-95,13},{-60,-9}},
textColor={128,128,128},
textString="a"),
Text(
visible=useAxisFlange,
extent={{-150,-135},{150,-95}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-150,-90},{150,-60}},
textString="n=%n"),
Rectangle(
visible=useAxisFlange,
extent={{90,30},{100,70}},
pattern=LinePattern.None,
fillColor={192,192,192},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Text(
visible=not useAxisFlange,
extent={{-150,60},{150,100}},
textString="%name",
textColor={0,0,255})}),
Documentation(info="<html>
<p>
Joint where frame_b is translated along axis n which is fixed in frame_a.
The two frames coincide when the relative distance \"s = 0\".
</p>
<p>
Optionally, two additional 1-dimensional mechanical flanges
(flange \"axis\" represents the driving flange and
flange \"support\" represents the bearing) can be enabled via
parameter <strong>useAxisFlange</strong>. The enabled axis flange can be
driven with elements of the
<a href=\"modelica://Modelica.Mechanics.Translational\">Modelica.Mechanics.Translational</a>
library.
</p>
<p>
In the \"Advanced\" menu it can be defined via parameter <strong>stateSelect</strong>
that the relative distance \"s\" and its derivative shall be definitely
used as states by setting stateSelect=StateSelect.always.
Default is StateSelect.prefer to use the relative distance and its
derivative as preferred states. The states are usually selected automatically.
In certain situations, especially when closed kinematic loops are present,
it might be slightly more efficient, when using the StateSelect.always setting.
</p>
<p>
In the following figure the animation of a prismatic
joint is shown. The light blue coordinate system is
frame_a and the dark blue coordinate system is
frame_b of the joint. The black arrow is parameter
vector \"n\" defining the translation axis
(here: n = {1,1,0}).
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Prismatic.png\">
</p>
</html>"));
end Prismatic;
model Revolute
"Revolute joint (1 rotational degree-of-freedom, 2 potential states, optional axis flange)"
Modelica.Mechanics.Rotational.Interfaces.Flange_a axis if useAxisFlange
"1-dim. rotational flange that drives the joint"
annotation (Placement(transformation(extent={{10,90},{-10,110}})));
Modelica.Mechanics.Rotational.Interfaces.Flange_b support if useAxisFlange
"1-dim. rotational flange of the drive support (assumed to be fixed in the world frame, NOT in the joint)"
annotation (Placement(transformation(extent={{-70,90},{-50,110}})));
Modelica.Mechanics.MultiBody.Interfaces.Frame_a frame_a
"Coordinate system fixed to the joint with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})));
Modelica.Mechanics.MultiBody.Interfaces.Frame_b frame_b
"Coordinate system fixed to the joint with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{84,-16},{116,16}})));
parameter Boolean useAxisFlange=false "= true, if axis flange is enabled"
annotation(Evaluate=true, HideResult=true, choices(checkBox=true));
parameter Boolean animation=true
"= true, if animation shall be enabled (show axis as cylinder)";
parameter Modelica.Mechanics.MultiBody.Types.Axis n={0,0,1}
"Axis of rotation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of cylinder representing the joint axis"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of cylinder representing the joint axis"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.Types.Color cylinderColor=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of cylinder representing the joint axis"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.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 StateSelect stateSelect=StateSelect.prefer
"Priority to use joint angle phi and w=der(phi) as states" annotation(Dialog(tab="Advanced"));
SI.Angle phi(start=0, final stateSelect=stateSelect)
"Relative rotation angle from frame_a to frame_b"
annotation (unassignedMessage="
The rotation angle phi of a revolute joint cannot be determined.
Possible reasons:
- A non-zero mass might be missing on either side of the parts
connected to the revolute joint.
- Too many StateSelect.always are defined and the model
has less degrees of freedom as specified with this setting
(remove all StateSelect.always settings).
");
SI.AngularVelocity w(start=0, stateSelect=stateSelect)
"First derivative of angle phi (relative angular velocity)";
SI.AngularAcceleration a(start=0)
"Second derivative of angle phi (relative angular acceleration)";
SI.Torque tau "Driving torque in direction of axis of rotation";
SI.Angle angle "= phi";
protected
outer Modelica.Mechanics.MultiBody.World world;
parameter Real e[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(n)
"Unit vector in direction of rotation axis, resolved in frame_a (= same as in frame_b)";
Frames.Orientation R_rel
"Relative orientation object from frame_a to frame_b or from frame_b to frame_a";
Visualizers.Advanced.Shape cylinder(
shapeType="cylinder",
color=cylinderColor,
specularCoefficient=specularCoefficient,
length=cylinderLength,
width=cylinderDiameter,
height=cylinderDiameter,
lengthDirection=e,
widthDirection={0,1,0},
r_shape=-e*(cylinderLength/2),
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
protected
Modelica.Mechanics.Rotational.Components.Fixed fixed
"support flange is fixed to ground"
annotation (Placement(transformation(extent={{-70,70},{-50,90}})));
Rotational.Interfaces.InternalSupport internalAxis(tau=tau)
annotation (Placement(transformation(extent={{-10,90},{10,70}})));
Rotational.Sources.ConstantTorque constantTorque(tau_constant=0) if not useAxisFlange
annotation (Placement(transformation(extent={{40,70},{20,90}})));
equation
Connections.branch(frame_a.R, frame_b.R);
assert(cardinality(frame_a) > 0,
"Connector frame_a of revolute joint is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of revolute joint is not connected");
angle = phi;
w = der(phi);
a = der(w);
// relationships between quantities of frame_a and of frame_b
frame_b.r_0 = frame_a.r_0;
if Connections.rooted(frame_a.R) then
R_rel = Frames.planarRotation(e, phi, w);
frame_b.R = Frames.absoluteRotation(frame_a.R, R_rel);
frame_a.f = -Frames.resolve1(R_rel, frame_b.f);
frame_a.t = -Frames.resolve1(R_rel, frame_b.t);
else
R_rel = Frames.planarRotation(-e, phi, w);
frame_a.R = Frames.absoluteRotation(frame_b.R, R_rel);
frame_b.f = -Frames.resolve1(R_rel, frame_a.f);
frame_b.t = -Frames.resolve1(R_rel, frame_a.t);
end if;
// d'Alemberts principle
tau = -frame_b.t*e;
// Connection to internal connectors
phi = internalAxis.phi;
connect(fixed.flange, support) annotation (Line(
points={{-60,80},{-60,100}}));
connect(internalAxis.flange, axis) annotation (Line(
points={{0,80},{0,100}}));
connect(constantTorque.flange, internalAxis.flange) annotation (Line(
points={{20,80},{0,80}}));
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,-60},{-30,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{30,-60},{100,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(extent={{-100,60},{-30,-60}}, lineColor={64,64,64}, radius=10),
Rectangle(extent={{30,60},{100,-60}}, lineColor={64,64,64}, radius=10),
Text(
extent={{-90,14},{-54,-11}},
textColor={128,128,128},
textString="a"),
Text(
extent={{51,11},{87,-14}},
textColor={128,128,128},
textString="b"),
Line(
visible=useAxisFlange,
points={{-20,80},{-20,60}}),
Line(
visible=useAxisFlange,
points={{20,80},{20,60}}),
Rectangle(
visible=useAxisFlange,
extent={{-10,100},{10,50}},
fillPattern=FillPattern.VerticalCylinder,
fillColor={192,192,192}),
Polygon(
visible=useAxisFlange,
points={{-10,30},{10,30},{30,50},{-30,50},{-10,30}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-30,11},{30,-10}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Polygon(
visible=useAxisFlange,
points={{10,30},{30,50},{30,-50},{10,-30},{10,30}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Text(
extent={{-150,-110},{150,-80}},
textString="n=%n"),
Text(
visible=useAxisFlange,
extent={{-150,-155},{150,-115}},
textString="%name",
textColor={0,0,255}),
Line(
visible=useAxisFlange,
points={{-20,70},{-60,70},{-60,60}}),
Line(
visible=useAxisFlange,
points={{20,70},{50,70},{50,60}}),
Line(
visible=useAxisFlange,
points={{-90,100},{-30,100}}),
Line(
visible=useAxisFlange,
points={{-30,100},{-50,80}}),
Line(
visible=useAxisFlange,
points={{-49,100},{-70,80}}),
Line(
visible=useAxisFlange,
points={{-70,100},{-90,80}}),
Text(
visible=not useAxisFlange,
extent={{-150,70},{150,110}},
textString="%name",
textColor={0,0,255})}),
Documentation(info="<html>
<p>
Joint where frame_b rotates around axis n which is fixed in frame_a.
The two frames coincide when the rotation angle \"phi = 0\".
</p>
<p>
Optionally, two additional 1-dimensional mechanical flanges
(flange \"axis\" represents the driving flange and
flange \"support\" represents the bearing) can be enabled via
parameter <strong>useAxisFlange</strong>. The enabled axis flange can be
driven with elements of the
<a href=\"modelica://Modelica.Mechanics.Rotational\">Modelica.Mechanics.Rotational</a>
library.
</p>
<p>
In the \"Advanced\" menu it can be defined via parameter <strong>stateSelect</strong>
that the rotation angle \"phi\" and its derivative shall be definitely
used as states by setting stateSelect=StateSelect.always.
Default is StateSelect.prefer to use the joint angle and its
derivative as preferred states. The states are usually selected automatically.
In certain situations, especially when closed kinematic loops are present,
it might be slightly more efficient, when using the StateSelect.always setting.
</p>
<p>
If a <strong>planar loop</strong> is present, e.g., consisting of 4 revolute joints
where the joint axes are all parallel to each other, then there is no
longer a unique mathematical solution and the symbolic algorithms will
fail. Usually, an error message will be printed pointing out this
situation. In this case, one revolute joint of the loop has to be replaced
by a Joints.RevolutePlanarLoopConstraint joint. The
effect is that from the 5 constraints of a usual revolute joint,
3 constraints are removed and replaced by appropriate known
variables (e.g., the force in the direction of the axis of rotation is
treated as known with value equal to zero; for standard revolute joints,
this force is an unknown quantity).
</p>
<p>
In the following figure the animation of a revolute
joint is shown. The light blue coordinate system is
frame_a and the dark blue coordinate system is
frame_b of the joint. The black arrow is parameter
vector \"n\" defining the translation axis
(here: n = {0,0,1}, phi.start = 45<sup>o</sup>).
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Revolute.png\">
</p>
</html>"));
end Revolute;
model RevolutePlanarLoopConstraint
"Revolute joint that is described by 2 positional constraints for usage in a planar loop (the ambiguous cut-force perpendicular to the loop and the ambiguous cut-torques are set arbitrarily to zero)"
import T = Modelica.Mechanics.MultiBody.Frames.TransformationMatrices;
import Modelica.Mechanics.MultiBody.Types;
Interfaces.Frame_a frame_a
"Coordinate system fixed to the joint with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{-116,-16},{-84,16}})));
Interfaces.Frame_b frame_b
"Coordinate system fixed to the joint with one cut-force and cut-torque"
annotation (Placement(transformation(extent={{84,-16},{116,16}})));
parameter Boolean animation=true
"= true, if animation shall be enabled (show axis as cylinder)";
parameter Modelica.Mechanics.MultiBody.Types.Axis n={0,0,1}
"Axis of rotation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of cylinder representing the joint axis"
annotation (Dialog(group="if animation = true", enable=animation));
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of cylinder representing the joint axis"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Color cylinderColor=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of cylinder representing the joint axis"
annotation (Dialog(colorSelector=true, group="if animation = true", enable=animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(group="if animation = true", enable=animation));
protected
outer Modelica.Mechanics.MultiBody.World world;
parameter Real e[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(n)
"Unit vector in direction of rotation axis, resolved in frame_a (= same as in frame_b)";
parameter Real nnx_a[3](each final unit="1")=if abs(e[1]) > 0.1 then {0,1,0} else (if abs(e[2])
> 0.1 then {0,0,1} else {1,0,0})
"Arbitrary vector that is not aligned with rotation axis n"
annotation (Evaluate=true);
parameter Real ey_a[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(cross(e, nnx_a))
"Unit vector orthogonal to axis n of revolute joint, resolved in frame_a"
annotation (Evaluate=true);
parameter Real ex_a[3](each final unit="1")=cross(ey_a, e)
"Unit vector orthogonal to axis n of revolute joint and to ey_a, resolved in frame_a"
annotation (Evaluate=true);
Real ey_b[3](each final unit="1") "ey_a, resolved in frame_b";
Real ex_b[3](each final unit="1") "ex_a, resolved in frame_b";
Frames.Orientation R_rel
"Dummy or relative orientation object from frame_a to frame_b";
Modelica.SIunits.Position r_rel_a[3]
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
SI.Force f_c[2] "Dummy or constraint forces in direction of ex_a, ey_a";
Visualizers.Advanced.Shape cylinder(
shapeType="cylinder",
color=cylinderColor,
specularCoefficient=specularCoefficient,
length=cylinderLength,
width=cylinderDiameter,
height=cylinderDiameter,
lengthDirection=e,
widthDirection={0,1,0},
r_shape=-e*(cylinderLength/2),
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
equation
assert(cardinality(frame_a) > 0,
"Connector frame_a of revolute joint is not connected");
assert(cardinality(frame_b) > 0,
"Connector frame_b of revolute joint is not connected");
// Determine relative position vector resolved in frame_a
R_rel = Frames.relativeRotation(frame_a.R, frame_b.R);
r_rel_a = Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
// r_rel_a = T.resolve1(R_rel.T, T.resolve2(frame_b.R.T, frame_b.r_0 - frame_a.r_0));
// Constraint equations
0 = ex_a*r_rel_a;
0 = ey_a*r_rel_a;
/* Transform forces and torques
(the torques are assumed to be zero by the assumption
of a planar joint)
*/
frame_a.t = zeros(3);
frame_b.t = zeros(3);
frame_a.f = [ex_a, ey_a]*f_c;
frame_b.f = -Frames.resolve2(R_rel, frame_a.f);
// check that revolute joint is used in planar loop
ex_b = Frames.resolve2(R_rel, ex_a);
ey_b = Frames.resolve2(R_rel, ey_a);
assert(noEvent(abs(e*r_rel_a) <= 1e-10 and abs(e*ex_b) <= 1e-10 and
abs(e*ey_b) <= 1e-10), "
The MultiBody.Joints.RevolutePlanarLoopConstraint joint is used as cut-joint of a
planar loop. However, the revolute joint is not part of a planar loop where the
axis of the revolute joint (parameter n) is orthogonal to the possible movements.
Either use instead joint MultiBody.Joints.Revolute or correct the
definition of the axes vectors n in the revolute joints of the planar loop.
");
annotation (defaultComponentName="revolute",
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Text(
extent={{-150,70},{150,100}},
textString="n=%n"),
Text(
extent={{-150,-110},{150,-70}},
textString="%name",
textColor={0,0,255}),
Rectangle(
extent={{-20,10},{20,-10}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-100,-60},{-20,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{20,-60},{100,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(extent={{-100,60},{-20,-60}}, lineColor={64,64,64}, radius=10),
Rectangle(extent={{20,60},{100,-60}}, lineColor={64,64,64}, radius=10),
Text(
extent={{-90,14},{-54,-11}},
textColor={128,128,128},
textString="a"),
Text(
extent={{51,11},{87,-14}},
textColor={128,128,128},
textString="b"),
Line(
points={{-91,-76},{-33,15},{30,-49},{87,61}},
color={255,0,0},
thickness=0.5)}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,-60},{-20,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{-100,-60},{-20,60}},
lineColor={64,64,64},
radius=10),
Rectangle(
extent={{-20,10},{20,-10}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{20,-60},{100,60}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{20,-60},{100,60}},
lineColor={64,64,64},
radius=10)}),
Documentation(info="<html>
<p>
Joint where frame_b rotates around axis n which is fixed in frame_a and
where this joint is used in a planar loop providing 2 constraint equations
on position level.
</p>
<p>
If a <strong>planar loop</strong> is present, e.g., consisting of 4 revolute joints
where the joint axes are all parallel to each other, then there is no
unique mathematical solution if all revolute joints are modelled with
Joints.Revolute and the symbolic algorithms will
fail. The reason is that, e.g., the cut-forces in the revolute joints perpendicular
to the planar loop are not uniquely defined when 3-dim. descriptions of revolute
joints are used. Usually, an error message will be printed pointing out this
situation. In this case, <strong>one</strong> revolute joint in the loop has to be replaced by
model Joints.RevolutePlanarLoopCutJoint. The
effect is that from the 5 constraints of a 3-dim. revolute joint,
3 constraints are removed and replaced by appropriate known
variables (e.g., the force in the direction of the axis of rotation is
treated as known with value equal to zero; for standard revolute joints,
this force is an unknown quantity).
</p>
</html>"));
end RevolutePlanarLoopConstraint;
model Cylindrical
"Cylindrical joint (2 degrees-of-freedom, 4 potential states)"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
parameter Boolean animation=true
"= true, if animation shall be enabled (show cylinder)";
parameter Modelica.Mechanics.MultiBody.Types.Axis n={1,0,0}
"Cylinder axis resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of cylinder"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color cylinderColor=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of cylinder"
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 StateSelect stateSelect=StateSelect.prefer
"Priority to use joint coordinates (phi, s, w, v) as states" annotation(Dialog(tab="Advanced"));
Prismatic prismatic(
n=n,
animation=false,
stateSelect=StateSelect.never) annotation (Placement(transformation(extent={{-70,-25},{
-15,25}})));
Revolute revolute(
n=n,
animation=false,
stateSelect=StateSelect.never) annotation (Placement(transformation(extent={{10,-25},{
65,25}})));
SI.Position s(start=0, stateSelect=stateSelect)
"Relative distance between frame_a and frame_b";
SI.Angle phi(start=0, stateSelect=stateSelect)
"Relative rotation angle from frame_a to frame_b";
SI.Velocity v(start=0, stateSelect=stateSelect)
"First derivative of s (relative velocity)";
SI.AngularVelocity w(start=0, stateSelect=stateSelect)
"First derivative of angle phi (relative angular velocity)";
SI.Acceleration a(start=0) "Second derivative of s (relative acceleration)";
SI.AngularAcceleration wd(start=0)
"Second derivative of angle phi (relative angular acceleration)";
protected
Visualizers.Advanced.Shape cylinder(
shapeType="cylinder",
color=cylinderColor,
specularCoefficient=specularCoefficient,
length=prismatic.s,
width=cylinderDiameter,
height=cylinderDiameter,
lengthDirection=prismatic.n,
widthDirection={0,1,0},
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation
annotation (Placement(transformation(extent={{-20,40},{0,60}})));
equation
phi = revolute.phi;
w = der(phi);
wd = der(w);
s = prismatic.s;
v = der(s);
a = der(v);
connect(frame_a, prismatic.frame_a)
annotation (Line(
points={{-100,0},{-70,0}},
color={95,95,95},
thickness=0.5));
connect(prismatic.frame_b, revolute.frame_a)
annotation (Line(
points={{-15,0},{10,0}},
color={95,95,95},
thickness=0.5));
connect(revolute.frame_b, frame_b)
annotation (Line(
points={{65,0},{100,0}},
color={95,95,95},
thickness=0.5));
annotation (
Documentation(info="<html>
<p>
Joint where frame_b rotates around and translates along axis n
which is fixed in frame_a. The two frames coincide when
\"phi=revolute.phi=0\" and \"s=prismatic.s=0\". This joint
has the following potential states;
</p>
<ul>
<li> The relative angle phi [rad] around axis n,</li>
<li> the relative distance s [m] along axis n,</li>
<li> the relative angular velocity w [rad/s] (= der(phi))
and</li>
<li> the relative velocity v [m/s] (= der(s)).</li>
</ul>
<p>
They are used as candidates for automatic selection of states
from the tool. This may be enforced by setting \"stateSelect=StateSelect.<strong>always</strong>\"
in the <strong>Advanced</strong> menu. The states are usually selected automatically.
In certain situations, especially when closed kinematic loops are present,
it might be slightly more efficient, when using the \"StateSelect.always\" setting.
</p>
<p>
In the following figure the animation of a cylindrical
joint is shown. The light blue coordinate system is
frame_a and the dark blue coordinate system is
frame_b of the joint. The black arrow is parameter
vector \"n\" defining the cylinder axis
(here: n = {0,0,1}).
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Cylindrical.png\">
</p>
</html>"), Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-30,-30},{100,30}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{-30,-30},{100,30}},
lineColor={64,64,64},
radius=10),
Rectangle(
extent={{-100,-50},{0,50}},
lineColor={64,64,64},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={255,255,255},
radius=10),
Rectangle(
extent={{-100,-50},{0,50}},
lineColor={64,64,64},
radius=10),
Text(
extent={{-150,100},{150,60}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-150,-65},{150,-95}},
textString="n=%n")}));
end Cylindrical;
model Universal "Universal joint (2 degrees-of-freedom, 4 potential states)"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Modelica.Mechanics.MultiBody.Types.Axis n_a={1,0,0}
"Axis of revolute joint 1 resolved in frame_a" annotation (Evaluate=true);
parameter Modelica.Mechanics.MultiBody.Types.Axis n_b={0,1,0}
"Axis of revolute joint 2 resolved in frame_b" annotation (Evaluate=true);
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of cylinders representing the joint axes"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of cylinders representing the joint axes"
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 joint axes"
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 StateSelect stateSelect=StateSelect.prefer
"Priority to use joint coordinates (phi_a, phi_b, w_a, w_b) as states" annotation(Dialog(tab="Advanced"));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute_a(
n=n_a,
stateSelect=StateSelect.never,
cylinderDiameter=cylinderDiameter,
cylinderLength=cylinderLength,
cylinderColor=cylinderColor,
specularCoefficient=specularCoefficient,
animation=animation) annotation (Placement(transformation(extent={{-60,
-25},{-10,25}})));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute_b(
n=n_b,
stateSelect=StateSelect.never,
animation=animation,
cylinderDiameter=cylinderDiameter,
cylinderLength=cylinderLength,
cylinderColor=cylinderColor,
specularCoefficient=specularCoefficient)
annotation (Placement(transformation(
origin={35,45},
extent={{-25,-25},{25,25}},
rotation=90)));
SI.Angle phi_a(start=0, stateSelect=stateSelect)
"Relative rotation angle from frame_a to intermediate frame";
SI.Angle phi_b(start=0, stateSelect=stateSelect)
"Relative rotation angle from intermediate frame to frame_b";
SI.AngularVelocity w_a(start=0, stateSelect=stateSelect)
"First derivative of angle phi_a (relative angular velocity a)";
SI.AngularVelocity w_b(start=0, stateSelect=stateSelect)
"First derivative of angle phi_b (relative angular velocity b)";
SI.AngularAcceleration a_a(start=0)
"Second derivative of angle phi_a (relative angular acceleration a)";
SI.AngularAcceleration a_b(start=0)
"Second derivative of angle phi_b (relative angular acceleration b)";
equation
phi_a = revolute_a.phi;
phi_b = revolute_b.phi;
w_a = der(phi_a);
w_b = der(phi_b);
a_a = der(w_a);
a_b = der(w_b);
connect(frame_a, revolute_a.frame_a)
annotation (Line(
points={{-100,0},{-60,0}},
color={95,95,95},
thickness=0.5));
connect(revolute_b.frame_b, frame_b) annotation (Line(
points={{35,70},{35,90},{70,90},{70,0},{100,0}},
color={95,95,95},
thickness=0.5));
connect(revolute_a.frame_b, revolute_b.frame_a) annotation (Line(
points={{-10,0},{35,0},{35,20}},
color={95,95,95},
thickness=0.5));
annotation (
Documentation(info="<html>
<p>
Joint where frame_a rotates around axis n_a which is fixed in frame_a
and frame_b rotates around axis n_b which is fixed in frame_b.
The two frames coincide when
\"revolute_a.phi=0\" and \"revolute_b.phi=0\". This joint
has the following potential states;
</p>
<ul>
<li> The relative angle phi_a = revolute_a.phi [rad] around axis n_a,</li>
<li> the relative angle phi_b = revolute_b.phi [rad] around axis n_b,</li>
<li> the relative angular velocity w_a (= der(phi_a)) and</li>
<li> the relative angular velocity w_b (= der(phi_b)).</li>
</ul>
<p>
They are used as candidates for automatic selection of states
from the tool. This may be enforced by setting \"stateSelect=StateSelect.<strong>always</strong>\"
in the <strong>Advanced</strong> menu. The states are usually selected automatically.
In certain situations, especially when closed kinematic loops are present,
it might be slightly more efficient, when using the \"StateSelect.always\" setting.
</p>
<p>
In the following figure the animation of a universal
joint is shown. The light blue coordinate system is
frame_a and the dark blue coordinate system is
frame_b of the joint
(here: n_a = {0,0,1}, n_b = {0,1,0}, phi_a.start = 90<sup>o</sup>,
phi_b.start = 45<sup>o</sup>).
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Joints/Universal.png\">
</p>
</html>"),
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(
extent={{-100,15},{-65,-15}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={235,235,235}),
Ellipse(
extent={{-80,-80},{80,80}},
lineColor={160,160,164},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-60,-60},{60,60}},
lineColor={160,160,164},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Text(
extent={{-150,-80},{150,-120}},
textString="%name",
textColor={0,0,255}),
Rectangle(
extent={{12,82},{80,-82}},
lineColor={255,255,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{56,15},{100,-15}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={235,235,235}),
Line(
points={{12,78},{12,-78}},
thickness=0.5),
Ellipse(
extent={{-52,-40},{80,40}},
lineColor={160,160,164},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-32,-20},{60,26}},
lineColor={160,160,164},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-22,-54},{-60,0},{-22,50},{40,52},{-22,-54}},
pattern=LinePattern.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(
points={{12,78},{12,-20}},
thickness=0.5),
Line(
points={{32,38},{-12,-36}},
thickness=0.5)}));
end Universal;
model Planar "Planar joint (3 degrees-of-freedom, 6 potential states)"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter Modelica.Mechanics.MultiBody.Types.Axis n={0,0,1}
"Axis orthogonal to unconstrained plane, resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter Modelica.Mechanics.MultiBody.Types.Axis n_x={1,0,0}
"Vector in direction of x-axis of plane, resolved in frame_a (n_x shall be orthogonal to n)"
annotation (Evaluate=true);
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of revolute cylinder"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance cylinderDiameter=world.defaultJointWidth
"Diameter of revolute cylinder"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
input Types.Color cylinderColor=Modelica.Mechanics.MultiBody.Types.Defaults.JointColor
"Color of revolute cylinder"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
parameter SI.Distance boxWidth=0.3*cylinderDiameter
"Width of prismatic joint boxes"