@@ -25,10 +25,13 @@ A revolute joint
2525 @named partial_frames = PartialTwoFrames ()
2626 @unpack frame_a, frame_b = partial_frames
2727 @named fixed = Rotational. Fixed ()
28+ systems = [frame_a, frame_b, fixed]
2829
2930 if use_flange
30- @named flange_a = Rotational. Flange (phi, tau)
31+ @named flange_a = Rotational. Flange (; phi, tau)
32+ push! (systems, flange_a)
3133 @named support = Rotational. Support ()
34+ push! (systems, support)
3235 end
3336
3437 vars = @variables begin
@@ -41,7 +44,7 @@ A revolute joint
4144 eqs = [
4245 ω ~ D (phi),
4346 α ~ D (ω),
44- # rigidly connect position
47+ # rigidly connect positions
4548 frame_a. x ~ frame_b. x,
4649 frame_a. y ~ frame_b. y,
4750 frame_a. phi + phi ~ frame_b. phi,
@@ -54,14 +57,105 @@ A revolute joint
5457 ]
5558
5659 if use_flange
60+ push! (eqs, connect (fixed. flange, support))
61+ else
5762 # actutation torque
63+ push! (eqs, j ~ 0 )
64+ end
65+
66+ pars = []
67+
68+ return compose (ODESystem (eqs, t, vars, pars; name = name),
69+ systems... )
70+ end
71+
72+ """
73+ Prismatic(; name, rx, ry, f, s = 0, use_flange = false)
74+ A prismatic joint
75+
76+ # parameters
77+ - `rx`: [m] x-direction of the rod wrt. body system at phi=0
78+ - `ry`: [m] y-direction of the rod wrt. body system at phi=0
79+ - `ex`: [m] x-component of unit vector in direction of r
80+ - `ey`: [m] y-component of unit vector in direction of r
81+ - `f`: [N] Force in direction of elongation
82+ - `s`: [m] Elongation of the joint"
83+ - `use_flange=false`: If `true`, a force flange is enabled, otherwise implicitly grounded"
84+
85+ # states
86+ - `s(t)`: [m] Elongation of the joint
87+ - `v(t)`: [m/s] Velocity of elongation
88+ - `a(t)`: [m/s²] Acceleration of elongation
89+ - `e0x(t)`: [m] x-component of unit vector resolved w.r.t inertial frame
90+ - `e0y(t)`: [m] y-component of unit vector resolved w.r.t inertial frame
91+ - `r0x(t)`: [m] x-component of the rod resolved w.r.t to inertal frame
92+ - `r0y(t)`: [m] y-length of the rod resolved w.r.t to inertal frame
93+ - `cos_phi(t)`: [degree] cos(phi)
94+ - `sin_phi(t)`: [degree] sin(phi)
95+
96+
97+ # Connectors
98+ - `frame_a` [Frame](@ref)
99+ - `frame_b` [Frame](@ref)
100+ - `fixed` [Fixed](@ref) if `use_flange == false`
101+ - `flange_a` [Flange](@ref) if `use_flange == true`
102+ - `support` [Support](@ref) if `use_flange == true`
103+ """
104+ @component function Prismatic (; name, rx, ry, ex, ey, f = 0 , s = 0 , use_flange = false )
105+ @named partial_frames = PartialTwoFrames ()
106+ @unpack frame_a, frame_b = partial_frames
107+ @named fixed = TranslationalModelica. Support ()
108+ systems = [frame_a, frame_b, fixed]
109+
110+ if use_flange
111+ @named flange_a = TranslationalModelica. Flange (; f, s)
112+ push! (systems, flange_a)
113+ @named support = TranslationalModelica. Support ()
114+ push! (systems, support)
115+ end
116+
117+ vars = @variables begin
118+ s (t) = 0.0
119+ v (t) = 0.0
120+ a (t) = 0.0
121+ e0x (t)
122+ e0y (t)
123+ r0x (t)
124+ r0y (t)
125+ cos_phi (t)
126+ sin_phi (t)
127+ end
128+
129+ eqs = [
130+ v ~ D (s),
131+ a ~ D (v),
132+ # rigidly connect positions
133+ frame_a. x + rx ~ frame_b. x,
134+ frame_a. y + ry ~ frame_b. y,
135+ frame_a. phi ~ frame_b. phi,
136+ # balance forces
137+ frame_a. fx + frame_b. fx ~ 0 ,
138+ frame_a. fy + frame_b. fy ~ 0 ,
139+ # balance torques
140+ cos_phi ~ cos (frame_a. phi),
141+ sin_phi ~ sin (frame_a. phi),
142+ e0x ~ cos_phi * ex - sin_phi * ey,
143+ e0y ~ sin_phi * ex + cos_phi * ey,
144+ r0x ~ e0x * s,
145+ r0y ~ e0y * s,
146+ frame_a. j + frame_b. j + r0x * (frame_b. fy - frame_a. fy) - r0y * (frame_b. fx - frame_a. fx) ~ 0 ,
147+ frame_a. fx * e0y - frame_a. fy * e0x ~ f,
148+ ]
149+
150+ if use_flange
58151 push! (eqs, connect (fixed. flange, support))
59152 else
60- push! (eqs, j ~ phi)
153+ # actutation torque
154+ push! (eqs, f ~ 0 )
61155 end
62156
63157 pars = []
64158
65159 return compose (ODESystem (eqs, t, vars, pars; name = name),
66- frame_a, frame_b, fixed )
160+ systems ... )
67161end
0 commit comments