-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmustache-modelica.txt
125 lines (111 loc) · 4.7 KB
/
mustache-modelica.txt
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
// Modelica model automatically generated by sdf_modelica from {{fileName}}
// Model stucture heavily inspired by Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.Components.MechanicalStructure
model {{modelName}}
"Model of the mechanical part of the {{modelName}} robot"
import SI = Modelica.SIunits;
parameter Boolean animation=true "= true, if animation shall be enabled";
parameter SI.Acceleration g=9.81 "Gravity acceleration";
// Position, velocity, acceleration and torques/force variables for each joint
{{#joints}}
{{#isType_revolute}}
SI.Angle q_{{name}} "Joint angle for joint {{name}}";
SI.AngularVelocity qd_{{name}} "Joint speed for joint {{name}}";
SI.AngularAcceleration qdd_{{name}} "Joint acceleration for joint {{name}}";
SI.Torque tau_{{name}} "Joint torque for joint {{name}}";
{{/isType_revolute}}
{{#isType_prismatic}}
SI.Position q_{{name}} "Joint position for joint {{name}}";
SI.Velocity qd_{{name}} "Joint speed for joint {{name}}";
SI.Acceleration qdd_{{name}} "Joint acceleration for joint {{name}}";
SI.Force tau_{{name}} "Joint force for joint {{name}}";
{{/isType_prismatic}}
{{/joints}}
// Interface of the model: the driving flanges for each joint
{{#joints}}
{{#isType_revolute}}
Modelica.Mechanics.Rotational.Interfaces.Flange_a axis_{{name}} annotation({{flangeGraphicsAnnotation}});
{{/isType_revolute}}
{{#isType_prismatic}}
Modelica.Mechanics.Translational.Interfaces.Flange_a axis_{{name}} annotation({{flangeGraphicsAnnotation}});
{{/isType_prismatic}}
{{/joints}}
// TODO(traversaro) : document this
inner Modelica.Mechanics.MultiBody.World world(
g=(g),
n={0,-1,0},
animateWorld=false,
animateGravity=false,
enableAnimation=animation) annotation({{worldGraphicsAnnotation}});
// Instantiate a Modelica.Mechanics.MultiBody.Joints for each joint
{{#joints}}
{{#isType_revolute}}
Modelica.Mechanics.MultiBody.Joints.Revolute {{name}}(n={{modelicaAxis}}, useAxisFlange=true,
animation=animation) annotation({{jointGraphicsAnnotation}});
{{/isType_revolute}}
{{#isType_prismatic}}
Modelica.Mechanics.MultiBody.Joints.Prismatic {{name}}(n={{modelicaAxis}}, useAxisFlange=true,
animation=animation) annotation({{jointGraphicsAnnotation}});
{{/isType_prismatic}}
Modelica.Mechanics.MultiBody.Parts.FixedRotation {{name}}_fixedRotation(angle={{fixedTransformAngle}}, n={{fixedTransformAxis}}, r={{fixedTransformTrans}}, rotationType = Modelica.Mechanics.MultiBody.Types.RotationTypes.RotationAxis) annotation({{fixedTranformGraphicsAnnotation}});
{{/joints}}
// Instantiate a Modelica.Mechanics.MultiBody.Parts.Body for each link
{{#links}}
Modelica.Mechanics.MultiBody.Parts.Body {{name}}(
r_CM={{centerOfMass}},
m={{mass}},
I_11={{I_11}},
I_22={{I_22}},
I_33={{I_33}},
I_21={{I_21}},
I_32={{I_23}},
I_31={{I_31}}) annotation({{graphicsAnnotation}});
{{/links}}
equation
{{#joints}}
{{#isType_revolute}}
q_{{name}} = {{name}}.phi;
qd_{{name}} = der(q_{{name}});
qdd_{{name}} = der(qd_{{name}});
tau_{{name}} = {{name}}.tau;
{{/isType_revolute}}
{{#isType_prismatic}}
q_{{name}} = {{name}}.s;
qd_{{name}} = der(q_{{name}});
qdd_{{name}} = der(qd_{{name}});
tau_{{name}} = {{name}}.f;
{{/isType_prismatic}}
{{#parentLinkIsWorld}}
connect({{parentLink}}.frame_b, {{name}}_fixedRotation.frame_a) annotation({{parent2fixedRotationGraphicsAnnotation}});
{{/parentLinkIsWorld}}
{{^parentLinkIsWorld}}
connect({{parentLink}}.frame_a, {{name}}_fixedRotation.frame_a) annotation({{parent2fixedRotationGraphicsAnnotation}});
{{/parentLinkIsWorld}}
{{^isType_fixed}}
connect({{name}}_fixedRotation.frame_b, {{name}}.frame_a) annotation({{fixedRotation2jointGraphicsAnnotation}});
connect({{name}}.frame_b, {{childLink}}.frame_a) annotation({{joint2childGraphicsAnnotation}});
connect({{name}}.axis, axis_{{name}}) annotation({{flange2jointGraphicsAnnotation}});
{{/isType_fixed}}
{{#isType_fixed}}
connect({{name}}_fixedRotation.frame_b, {{childLink}}.frame_a) annotation({{fixedRotation2childGraphicsAnnotation}});
{{/isType_fixed}}
{{/joints}}
annotation (
Documentation(info="<html>
<p>
This model contains the mechanical components of a SDF
multibody system.
</p>
</html>"),
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={ {-200,-200},{200,200} }), graphics={
Rectangle(
extent={ {-200,200},{200,-200} },
lineColor={0,0,0},
fillColor={192,192,192},
fillPattern=FillPattern.Solid)
{{& iconFlangeLabels}}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={ {-200,-200},{200,200} })));
end {{modelName}};