@@ -133,11 +133,12 @@ The `BodyShape` component is similar to a [`Body`](@ref), but it has two frames
133133 body = Body (; r= r_cm, I, m, gy)
134134 frame_a = Frame ()
135135 frame_b = Frame ()
136+ frame_cm = Frame ()
136137 end
137138 @equations begin
138139 connect (frame_a, translation. frame_a, translation_cm. frame_a)
139140 connect (frame_b, translation. frame_b)
140- connect (translation_cm. frame_b, body. frame_a)
141+ connect (translation_cm. frame_b, body. frame_a, frame_cm )
141142 end
142143end
143144
@@ -168,6 +169,7 @@ A fixed translation between two components (rigid rod)
168169 ]
169170 radius = 0.1 , [description = " Radius of the rod in animations" ]
170171 render = true , [description = " Render the rod in animations" ]
172+ color[1 : 4 ] = purple, [description = " Color of the rod in animations" ]
171173 end
172174 begin
173175 r = collect (r)
@@ -343,8 +345,8 @@ Linear 2D translational spring damper model
343345- `d_x`: [N.s/m] Damping constant in x dir
344346- `d_y`: [N.s/m] Damping constant in y dir
345347- `d_phi`: [N.m.s/rad] Damping constant in phi dir
346- - `s_relx0`: [m] Unstretched spring length
347- - `s_rely0`: [m] Unstretched spring length
348+ - `s_relx0`: [m] Unstretched spring extension (direction important)
349+ - `s_rely0`: [m] Unstretched spring extension (direction important)
348350- `phi_rel0`: [rad] Unstretched spring angle
349351- `s_small`: [m] Prevent zero-division if distance between frame_a and frame_b is zero
350352- `num_windings`: [Int] Number of windings of the coil when rendered
@@ -367,8 +369,8 @@ Linear 2D translational spring damper model
367369 d_x = 1 , [description = " Damping constant in x dir" ]
368370 d_y = 1 , [description = " Damping constant in y dir" ]
369371 d_phi = 1 , [description = " Damping constant in phi dir" ]
370- s_relx0 = 0 , [description = " Unstretched spring length " ]
371- s_rely0 = 0 , [description = " Unstretched spring length " ]
372+ s_relx0 = 0 , [description = " Unstretched spring extensions (signed) " ]
373+ s_rely0 = 0 , [description = " Unstretched spring extensions (signed) " ]
372374 phi_rel0 = 0 , [description = " Unstretched spring angle" ]
373375 s_small = 1.e-10 ,
374376 [
@@ -385,12 +387,15 @@ Linear 2D translational spring damper model
385387 v_relx (t)
386388 v_rely (t)
387389 w_rel (t) = 0
388- s_relx (t)
389- s_rely (t)
390- phi_rel (t) = 0
391- f_x (t)
392- f_y (t)
393- tau (t)
390+ s_relx (t), [description = " Spring extension in x dir" ]
391+ s_rely (t), [description = " Spring extension in y dir" ]
392+ phi_rel (t) = 0 , [description = " Spring extension angle" ]
393+ delta_x (t), [description = " Spring deflection in x dir" ]
394+ delta_y (t), [description = " Spring deflection in y dir" ]
395+ delta_phi (t), [description = " Spring deflection in phi dir" ]
396+ f_x (t), [description = " Spring-damper force in x dir" ]
397+ f_y (t), [description = " Spring-damper force in y dir" ]
398+ tau (t), [description = " Rotational spring-damper torque" ]
394399 end
395400
396401 begin
@@ -407,11 +412,14 @@ Linear 2D translational spring damper model
407412 v_rely ~ D (s_rely)
408413 w_rel ~ D (phi_rel)
409414
410- tau ~ c_phi * (phi_rel - phi_rel0) + d_phi * w_rel
411415 frame_a. tau ~ - tau
412416 frame_b. tau ~ tau
413- f_x ~ c_x * (s_relx - s_relx0) + d_x * v_relx
414- f_y ~ c_y * (s_rely - s_rely0) + d_y * v_rely
417+ delta_x ~ s_relx - s_relx0
418+ delta_y ~ s_rely - s_rely0
419+ delta_phi ~ phi_rel - phi_rel0
420+ f_x ~ c_x * delta_x + d_x * v_relx
421+ f_y ~ c_y * delta_y + d_y * v_rely
422+ tau ~ c_phi * delta_phi + d_phi * w_rel
415423 frame_a. fx ~ - f_x
416424 frame_b. fx ~ f_x
417425 frame_a. fy ~ - f_y
0 commit comments