Ticket #6200: PrismaticConstraint.mo

File PrismaticConstraint.mo, 5.4 KB (added by Francesco Casella, 3 years ago)
Line 
1within ;
2model PrismaticConstraint
3 "Body attached by one spring and two prismatic joints or constrained to environment"
4 extends Modelica.Icons.Example;
5 parameter Boolean animation=true "True, if animation shall be enabled";
6
7 Modelica.Mechanics.MultiBody.Joints.Constraints.Prismatic constraint(x_locked=
8 false, y_locked=false)
9 annotation (Placement(transformation(extent={{60,10},{40,30}})));
10 Modelica.Mechanics.MultiBody.Sensors.RelativeSensor sensorConstraintRelative(
11 resolveInFrame=Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB.frame_a,
12 get_r_rel=true,
13 get_a_rel=false,
14 get_angles=true)
15 annotation (Placement(transformation(extent={{60,60},{40,40}})));
16 Modelica.Mechanics.MultiBody.Parts.BodyShape bodyOfConstraint(
17 I_11=1,
18 I_22=1,
19 I_33=1,
20 width=0.05,
21 w_0_fixed=false,
22 final color={0,128,0},
23 r={0.4,0,0},
24 r_CM={0.2,0,0},
25 m=1,
26 angles_fixed=false,
27 angles_start={0.17453292519943,0.95993108859688,1.1868238913561})
28 annotation (Placement(transformation(extent={{-10,10},{10,-10}},rotation=180,
29 origin={-10,20})));
30 Modelica.Mechanics.MultiBody.Forces.Spring springOfConstraint(
31 width=0.1,
32 coilWidth=0.005,
33 c=20,
34 s_unstretched=0,
35 numberOfWindings=5) annotation (Placement(transformation(
36 origin={-50,20},
37 extent={{-10,-10},{10,10}})));
38 inner Modelica.Mechanics.MultiBody.World world(enableAnimation=false)
39 annotation (Placement(
40 transformation(extent={{-100,-100},{-80,-80}})));
41 Modelica.Mechanics.MultiBody.Parts.FixedRotation fixedRotation(
42 r={0.2,-0.3,0.2},
43 rotationType=Modelica.Mechanics.MultiBody.Types.RotationTypes.PlanarRotationSequence,
44 angles={10,55,68})
45 annotation (Placement(transformation(extent={{-10,-10},{10,10}},
46 rotation=90,
47 origin={90,-50})));
48
49 Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation(animation=
50 false, r={0.8,0,0.3})
51 annotation (Placement(transformation(extent={{-10,-10},{10,10}},
52rotation=90,
53 origin={-70,-50})));
54 Modelica.Mechanics.MultiBody.Joints.FreeMotionScalarInit freeMotionScalarInit(
55 use_r=true,
56 use_v=true,
57 v_rel_a_2(fixed=true, start=0),
58 v_rel_a_3(fixed=true, start=0),
59 use_w=true,
60 w_rel_b_1(fixed=false),
61 w_rel_b_2(fixed=false),
62 w_rel_b_3(fixed=false),
63 angle_d_3(fixed=false),
64 r_rel_a_2(fixed=true, start=0),
65 r_rel_a_3(fixed=true, start=0),
66 angle_1(fixed=false))
67 annotation (Placement(transformation(extent={{60,70},{40,90}})));
68equation
69 connect(fixedTranslation.frame_a, world.frame_b)
70 annotation (Line(
71 points={{-70,-60},{-70,-90},{-80,-90}},
72 color={95,95,95},
73 thickness=0.5));
74 connect(bodyOfConstraint.frame_b, springOfConstraint.frame_b)
75 annotation (Line(
76 points={{-20,20},{-40,20}},
77 color={95,95,95},
78 thickness=0.5));
79 connect(world.frame_b, fixedRotation.frame_a) annotation (Line(
80 points={{-80,-90},{90,-90},{90,-60}},
81 color={95,95,95},
82 thickness=0.5));
83 connect(fixedRotation.frame_b, constraint.frame_a) annotation (Line(
84 points={{90,-40},{90,20},{60,20}},
85 color={95,95,95},
86 thickness=0.5));
87 connect(constraint.frame_a,sensorConstraintRelative. frame_a)
88 annotation (Line(
89 points={{60,20},{70,20},{70,50},{60,50}},
90 color={95,95,95},
91 thickness=0.5));
92 connect(sensorConstraintRelative.frame_b, constraint.frame_b) annotation (
93 Line(
94 points={{40,50},{30,50},{30,20},{40,20}},
95 color={95,95,95},
96 thickness=0.5));
97 connect(fixedTranslation.frame_b, springOfConstraint.frame_a)
98 annotation (Line(
99 points={{-70,-40},{-70,20},{-60,20}},
100 color={95,95,95},
101 thickness=0.5));
102 connect(bodyOfConstraint.frame_a, constraint.frame_b) annotation (Line(
103 points={{0,20},{40,20}},
104 color={95,95,95},
105 thickness=0.5));
106 connect(freeMotionScalarInit.frame_a, fixedRotation.frame_b) annotation (
107 Line(
108 points={{60,80},{90,80},{90,-40}},
109 color={95,95,95},
110 thickness=0.5));
111 connect(freeMotionScalarInit.frame_b, bodyOfConstraint.frame_a) annotation (
112 Line(
113 points={{40,80},{10,80},{10,20},{0,20}},
114 color={95,95,95},
115 thickness=0.5));
116 annotation (
117 experiment(StopTime=10),
118 Documentation(info="<html>
119<p>This example demonstrates the functionality of <strong>constraint</strong> representing <strong>prismatic joint</strong>. Each of two bodies is at one of its end connected by spring to the world. The other end is also connected to the world either by two serial coupled prismatic joints or by appropriate constraint. Therefore, the body can only perform translation in two directions specified in the two joints depending on working forces.</p>
120<p><strong>Simulation results</strong></p>
121<p>After simulating the model, see the animation of the multibody system and compare movement of body connected by joint (blue colored) with movement of that one connected by constraint (of green color). Additionally, the outputs from <code>sensorConstraintRelative</code> depict both position and angle deviations in the constraining element.</p>
122</html>"),
123 uses(Modelica(version="3.2.3")));
124end PrismaticConstraint;