@@ -76,17 +76,16 @@ https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b70839146
76
76
end
77
77
78
78
"""
79
- Prismatic(; name, rx, ry, f, s = 0, use_flange = false)
79
+ Prismatic(; name, f, s = 0, axisflange = false)
80
80
A prismatic joint
81
81
82
- # parameters
83
- - `x`: [m] x-direction of the rod wrt. body system at phi=0
84
- - `y`: [m] y-direction of the rod wrt. body system at phi=0
82
+ # Parameters
83
+ - `r`: [m, m] x,y-direction of the rod wrt. body system at phi=0
85
84
- `constant_f`: [N] Constant force in direction of elongation
86
85
- `constant_s`: [m] Constant elongation of the joint"
87
- - `use_flange =false`: If `true`, a force flange is enabled, otherwise implicitly grounded"
86
+ - `axisflange =false`: If `true`, a force flange is enabled, otherwise implicitly grounded"
88
87
89
- # states
88
+ # Variables
90
89
- `s(t)`: [m] Elongation of the joint
91
90
- `v(t)`: [m/s] Velocity of elongation
92
91
- `a(t)`: [m/s²] Acceleration of elongation
@@ -95,67 +94,77 @@ A prismatic joint
95
94
# Connectors
96
95
- `frame_a` [Frame](@ref)
97
96
- `frame_b` [Frame](@ref)
98
- - `fixed` [Fixed](@ref) if `use_flange == false`
99
- - `flange_a` [Flange](@ref) if `use_flange == true`
100
- - `support` [Support](@ref) if `use_flange == true`
97
+ - `fixed` [Fixed](@ref) if `axisflange == false`
98
+ - `flange_a` [Flange](@ref) if `axisflange == true`
99
+ - `support` [Support](@ref) if `axisflange == true`
101
100
102
101
https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b708391461cbe2523/PlanarMechanics/Joints/Prismatic.mo
103
102
"""
104
103
@component function Prismatic (;
105
104
name,
106
- x,
107
- y,
105
+ r = [0 ,0 ],
106
+ s = 0 ,
107
+ v = 0 ,
108
108
constant_f = 0 ,
109
109
constant_s = 0 ,
110
- use_flange = false )
110
+ axisflange = false ,
111
+ render = true ,
112
+ radius = 0.1 ,
113
+ color = [0 ,0.8 ,1 ,1 ],
114
+ )
111
115
@named partial_frames = PartialTwoFrames ()
116
+ systems = @named begin
117
+ fixed = TranslationalModelica. Support ()
118
+ end
112
119
@unpack frame_a, frame_b = partial_frames
113
- @named fixed = TranslationalModelica. Support ()
114
- systems = [frame_a, frame_b, fixed]
115
120
116
- if use_flange
117
- @named flange_a = TranslationalModelica. Flange (; f = constant_f, constant_s)
118
- push! (systems, flange_a)
119
- @named support = TranslationalModelica. Support ()
120
- push! (systems, support)
121
+ if axisflange
122
+ more_systems = @named begin
123
+ flange_a = TranslationalModelica. Flange (; f = constant_f, constant_s)
124
+ support = TranslationalModelica. Support ()
125
+ end
126
+ systems = [systems, more_systems]
121
127
end
122
128
123
- vars = @variables begin
124
- s (t) = 0.0
125
- v (t) = 0.0
126
- a (t) = 0.0
127
- f (t) = 0.0
129
+ pars = @parameters begin
130
+ (r[ 1 : 2 ] = r), [description = " Direction of the rod wrt. body system at phi=0 " ]
131
+ render = render, [description = " Render the joint in animations " ]
132
+ radius = radius, [description = " Radius of the body in animations " ]
133
+ color[ 1 : 4 ] = color, [description = " Color of the body in animations " ]
128
134
end
129
135
130
- R = [cos (frame_a. phi) - sin (frame_a. phi);
131
- sin (frame_a. phi) cos (frame_a. phi)]
132
- e0 = R * [x, y]
133
- r0 = e0 * s
136
+ vars = @variables begin
137
+ (s (t) = s), [state_priority = 2 , description= " Joint coordinate" ]
138
+ (v (t) = v), [state_priority = 2 ]
139
+ a (t)
140
+ f (t)
141
+ e0 (t)[1 : 2 ]
142
+ (r0 (t)[1 : 2 ]= r), [description= " Translation vector of the prismatic rod resolved w.r.t. inertial frame" ]
143
+ end
134
144
145
+ e = Multibody. _normalize (r)
146
+ R = ori_2d (frame_a)
147
+
135
148
eqs = [
136
- # ifelse(constant_s === nothing, s ~ s, s ~ constant_s),
137
- ifelse (constant_f === nothing , f ~ f, f ~ constant_f),
138
- v ~ D (s),
139
- a ~ D (v),
149
+ e0 .~ R * e
150
+ r0 .~ e0 * s
151
+ v ~ D (s)
152
+ a ~ D (v)
140
153
# rigidly connect positions
141
- frame_a. x + r0[1 ] ~ frame_b. x,
142
- frame_a. y + r0[2 ] ~ frame_b. y,
143
- frame_a. phi ~ frame_b. phi,
144
- frame_a. fx + frame_b. fx ~ 0 ,
145
- frame_a. fy + frame_b. fy ~ 0 ,
146
- frame_a. tau + frame_b. tau + r0[1 ] * frame_b. fy - r0[2 ] * frame_b. fx ~ 0 ,
154
+ frame_a. x + r0[1 ] ~ frame_b. x
155
+ frame_a. y + r0[2 ] ~ frame_b. y
156
+ frame_a. phi ~ frame_b. phi
157
+ frame_a. fx + frame_b. fx ~ 0
158
+ frame_a. fy + frame_b. fy ~ 0
159
+ frame_a. tau + frame_b. tau + r0[1 ] * frame_b. fy - r0[2 ] * frame_b. fx ~ 0
147
160
e0[1 ] * frame_a. fx + e0[2 ] * frame_a. fy ~ f
148
161
]
149
162
150
- if use_flange
163
+ if axisflange
151
164
push! (eqs, connect (fixed. flange, support))
152
165
else
153
166
# actutation torque
154
- push! (eqs, constant_f ~ 0 )
167
+ push! (eqs, f ~ 0 )
155
168
end
156
-
157
- pars = []
158
-
159
- return compose (ODESystem (eqs, t, vars, pars; name = name),
160
- systems... )
169
+ return extend (ODESystem (eqs, t, vars, pars; name, systems), partial_frames)
161
170
end
0 commit comments