-
Notifications
You must be signed in to change notification settings - Fork 164
/
Revolute.mo
167 lines (156 loc) · 7.23 KB
/
Revolute.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
within Modelica.Mechanics.MultiBody.Joints.Constraints;
model Revolute
"Revolute cut-joint and translational directions may be constrained or released"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
parameter Boolean x_locked=true
"= true: constraint force in x-direction, resolved in frame_a"
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
parameter Boolean y_locked=true
"= true: constraint force in y-direction, resolved in frame_a"
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
parameter Boolean z_locked=true
"= true: constraint force in z-direction, resolved in frame_a"
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
parameter Boolean animation=true
"= true, if animation shall be enabled (show sphere)";
parameter Types.Axis n={0,1,0}
"Axis of rotation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
parameter SI.Distance sphereDiameter=world.defaultJointLength /3
"Diameter of sphere representing the spherical joint"
annotation (Dialog(group="if animation = true", enable=animation));
input Types.Color sphereColor=Types.Defaults.JointColor
"Color of sphere representing the spherical joint"
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
Frames.Orientation R_rel
"Dummy or relative orientation object from frame_a to frame_b";
SI.Position r_rel_a[3]
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
SI.InstantaneousPower P;
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";
public
Visualizers.Advanced.Shape sphere(
shapeType="sphere",
color=sphereColor,
specularCoefficient=specularCoefficient,
length=sphereDiameter,
width=sphereDiameter,
height=sphereDiameter,
lengthDirection={1,0,0},
widthDirection={0,1,0},
r_shape={-0.5,0,0}*sphereDiameter,
r=frame_a.r_0,
R=frame_a.R) if world.enableAnimation and animation;
equation
// 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);
// Constraint equations concerning translations
if x_locked and y_locked and z_locked then
r_rel_a=zeros(3);
elseif x_locked and y_locked and not z_locked then
r_rel_a[1]=0;
r_rel_a[2]=0;
frame_a.f[3]=0;
elseif x_locked and not y_locked and z_locked then
r_rel_a[1]=0;
r_rel_a[3]=0;
frame_a.f[2]=0;
elseif x_locked and not y_locked and not z_locked then
r_rel_a[1]=0;
frame_a.f[2]=0;
frame_a.f[3]=0;
elseif not x_locked and y_locked and z_locked then
r_rel_a[2]=0;
r_rel_a[3]=0;
frame_a.f[1]=0;
elseif not x_locked and y_locked and not z_locked then
r_rel_a[2]=0;
frame_a.f[1]=0;
frame_a.f[3]=0;
elseif not x_locked and not y_locked and z_locked then
r_rel_a[3]=0;
frame_a.f[1]=0;
frame_a.f[2]=0;
else
frame_a.f=zeros(3);
end if;
// Constraint equations concerning rotations
0 = ex_a*R_rel.T*e;
0 = ey_a*R_rel.T*e;
frame_a.t*n=0;
zeros(3) = frame_a.f + Frames.resolve1(R_rel, frame_b.f);
zeros(3) = frame_a.t + Frames.resolve1(R_rel, frame_b.t) - cross(r_rel_a,
frame_a.f);
P = frame_a.t*Frames.angularVelocity2(frame_a.R) + frame_b.t*
Frames.angularVelocity2(frame_b.R) + Frames.resolve1(frame_b.R, frame_b.f)
*der(frame_b.r_0) + Frames.resolve1(frame_a.R, frame_a.f)*der(frame_a.r_0);
annotation ( defaultComponentName="constraint",
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Text(
extent={{-63,-63},{53,-93}},
textString="n=%n"),
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"),
Rectangle(
extent={{-30,11},{30,-10}},
lineColor={64,64,64},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(
points={{-81,-66},{-23,25},{40,-39},{97,71}},
color={255,0,0},
thickness=0.5),
Text(
extent={{-49,82},{45,59}},
textString="constraint"),
Text(
extent={{-150,120},{150,80}},
textColor={0,0,255},
textString="%name")}),
Documentation(info="<html>
<p>This model does not use explicit variables e.g. state variables in order to describe the relative motion of frame_b with respect to frame_a, but defines kinematic constraints between the frame_a and frame_b. The forces and torques at both frames are then evaluated in such a way that the constraints are satisfied. Sometimes this type of formulation is also called an implicit joint in literature.</p>
<p>As a consequence of the formulation the relative kinematics between frame_a and frame_b cannot be initialized.</p>
<p>In particular in complex multibody systems with closed loops this may help to simplify the system of non-linear equations. Please compare the translation log using the classical joint formulation and the alternative formulation used here in order to check whether this fact applies to the particular system under consideration.</p>
<p>In systems without closed loops the use of this implicit joint does not make sense or may even be disadvantageous.</p>
<p>See the subpackage <a href=\"Modelica://Modelica.Mechanics.MultiBody.Examples.Constraints\">Examples.Constraints</a> for testing the joint.</p>
</html>"));
end Revolute;