You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/examples/free_motion.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,11 @@ nothing # hide
49
49
```
50
50
51
51
52
-
If we instead model a body suspended in springs without the presence of any joint, we need to give the body state variables. We do this by saying `isroot = true` when we create the body, we also use quaternions to represent angles using `quat = true`.
52
+
## Body suspended in springs
53
+
If we instead model a body suspended in springs without the presence of any joint, we need to _give the body state variables_. We do this by saying `isroot = true` when we create the body, we also use quaternions to represent angular state using `quat = true`.
53
54
54
55
```@example FREE_MOTION
56
+
using Multibody.Rotations: QuatRotation, RotXYZ
55
57
@named begin
56
58
body = BodyShape(m = 1, I_11 = 1, I_22 = 1, I_33 = 1, r = [0.4, 0, 0],
Copy file name to clipboardExpand all lines: src/components.jl
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,8 @@ Representing a body with 3 translational and 3 rotational degrees-of-freedom.
230
230
I_31 =0,
231
231
I_32 =0,
232
232
isroot =false,
233
+
state =false,
234
+
vel_from_R =false,
233
235
phi0 =zeros(3),
234
236
phid0 =zeros(3),
235
237
r_0 =0,
@@ -283,13 +285,18 @@ Representing a body with 3 translational and 3 rotational degrees-of-freedom.
283
285
284
286
# DRa = D(Ra)
285
287
288
+
if state
289
+
# @warn "Make the body have state variables by using isroot=true rather than state=true"
290
+
isroot =true
291
+
end
292
+
286
293
dvs = [r_0;v_0;a_0;g_0;w_a;z_a;]
287
294
eqs =if isroot # isRoot
288
295
289
296
if quat
290
297
@named frame_a =Frame(varw =false)
291
298
Ra =ori(frame_a, false)
292
-
nonunit_quaternion_equations(Ra, w_a);
299
+
qeeqs =nonunit_quaternion_equations(Ra, w_a)
293
300
else
294
301
@named frame_a =Frame(varw =true)
295
302
Ra =ori(frame_a, true)
@@ -303,8 +310,11 @@ Representing a body with 3 translational and 3 rotational degrees-of-freedom.
303
310
phidd .~D.(phid)
304
311
Ra ~ ar
305
312
Ra.w .~ w_a
306
-
# w_a .~ angular_velocity2(ori(frame_a, false)) # This is required for FreeBody tests to pass, but the other one required for harmonic osciallator without joint to pass. FreeBody passes with quat=true so we use that instead
307
-
w_a .~ ar.w # This one for most systems
313
+
if vel_from_R
314
+
w_a .~angular_velocity2(ori(frame_a, false)) # This is required for FreeBody and ThreeSprings tests to pass, but the other one required for harmonic osciallator without joint to pass. FreeBody passes with quat=true so we use that instead
Copy file name to clipboardExpand all lines: src/orientation.jl
+37-26Lines changed: 37 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,11 @@ Create a new [`RotationMatrix`](@ref) struct with symbolic elements. `R,w` deter
36
36
The primary difference between `NumRotationMatrix` and `RotationMatrix` is that the `NumRotationMatrix` constructor is used in the constructor of a [`Frame`](@ref) in order to introduce the frame variables, whereas `RorationMatrix` (the struct) only wraps existing variables.
37
37
38
38
- `varw`: If true, `w` is a variable, otherwise it is derived from the derivative of `R` as `w = get_w(R)`.
39
+
40
+
Never call this function directly from a component constructor, instead call `f = Frame(); R = ori(f)` and add `f` to the subsystems.
39
41
"""
40
-
functionNumRotationMatrix(; R =collect(1.0I(3)), w =zeros(3), name, varw =false, state_priority=nothing)
42
+
functionNumRotationMatrix(; R =collect(1.0I(3)), w =zeros(3), name=:R, varw =false, state_priority=nothing)
43
+
# The reason for not calling this directly is that all R vaiables have to have the same name since they are treated as connector variables (otherwise a connection error is thrown). A component with more than one rotation matrix will thus have two different R variables that overwrite each other
# The reason for not calling this directly is that all R vaiables have to have the same name since they are treated as connector variables (otherwise a connection error is thrown). A component with more than one rotation matrix will thus have two different R variables that overwrite each other
# They also have w_a = angularVelocity2(frame_a.R) even for quaternions, so w_a = angularVelocity2(Q, der(Q)), this is their link between w_a and D(Q), while ours is D(Q̂) .~ (Ω * Q̂)
D.(Q̂) .~ (Ω'* Q̂) ./2+ c * Q̂# We use Ω' which is the same as using -w to handle the fact that w coming in here is typically described frame_a rather than in frame_b, the paper is formulated with w being expressed in the rotating body frame (frame_b)
0 commit comments