Skip to content

Commit

Permalink
neg_w everywhere and default
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Jul 29, 2024
1 parent 3ea1a11 commit d7ba8b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/src/examples/free_motion.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If we instead model a body suspended in springs without the presence of any join
using Multibody.Rotations: QuatRotation, RotXYZ, params
@named begin
body = BodyShape(m = 1, I_11 = 1, I_22 = 1, I_33 = 1, r = [0.4, 0, 0],
r_0 = [0.2, -0.5, 0.1], isroot = true, quat=true, neg_w=true)
r_0 = [0.2, -0.5, 0.1], isroot = true, quat=true)
bar2 = FixedTranslation(r = [0.8, 0, 0])
spring1 = Multibody.Spring(c = 20, s_unstretched = 0)
spring2 = Multibody.Spring(c = 20, s_unstretched = 0)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/three_springs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ world = Multibody.world
systems = @named begin
body1 = Body(m = 0.8, I_11 = 0.1, I_22 = 0.1, I_33 = 0.1, r_0 = [0.5, -0.3, 0],
r_cm = [0, -0.2, 0], isroot=true, quat=true, neg_w=true)
r_cm = [0, -0.2, 0], isroot=true, quat=true)
bar1 = FixedTranslation(r = [0.3, 0, 0])
bar2 = FixedTranslation(r = [0, 0, 0.3])
spring1 = Multibody.Spring(c = 20, m = 0, s_unstretched = 0.1, fixed_rotation_at_frame_b=true,
Expand Down
6 changes: 3 additions & 3 deletions src/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ This component has a single frame, `frame_a`. To represent bodies with more than
isroot = false,
state = false,
sequence = [1,2,3],
neg_w = false,
neg_w = true,
phi0 = zeros(3),
phid0 = zeros(3),
r_0 = 0,
Expand Down Expand Up @@ -267,7 +267,7 @@ This component has a single frame, `frame_a`. To represent bodies with more than
]
@variables g_0(t)[1:3] [guess = 0, description = "gravity acceleration"]
@variables w_a(t)[1:3]=w_a [guess = 0,
state_priority = state_priority+2quat*state,
state_priority = state_priority-1+2quat*state,
description = "Absolute angular velocity of frame_a resolved in frame_a",
]
@variables z_a(t)[1:3] [guess = 0,
Expand Down Expand Up @@ -619,7 +619,7 @@ Rigid body with cylinder shape. The mass properties of the body (mass, center of
state = false
quat = false
sequence = [1,2,3]
neg_w = false
neg_w = true
end

@parameters begin
Expand Down
4 changes: 2 additions & 2 deletions src/joints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Joint with 3 constraints that define that the origin of `frame_a` and the origin
z_rel_a_fixed = false, sequence = [1, 2, 3], phi = 0,
phid = 0,
d = 0,
neg_w = false,
neg_w = true,
phidd = 0,
color = [1, 1, 0, 1],
radius = 0.1,
Expand Down Expand Up @@ -720,7 +720,7 @@ The relative position vector `r_rel_a` from the origin of `frame_a` to the origi
state_priority = 4,
phid = 0,
phidd = 0,
neg_w = false,
neg_w = true,
w_rel_b = 0,
r_rel_a = 0,
v_rel_a = 0,
Expand Down
7 changes: 4 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ t = Multibody.t
D = Differential(t)
@testset "spring - harmonic oscillator" begin

@named body = Body(; m = 1, isroot = true, r_cm = [0, 1, 0], quat=false) # This time the body isroot since there is no joint containing state
@named body = Body(; m = 1, isroot = true, r_cm = [0, -1, 0], quat=true, neg_w=true) # This time the body isroot since there is no joint containing state
@named spring = Multibody.Spring(c = 1)

connections = [connect(world.frame_b, spring.frame_a)
Expand All @@ -87,10 +87,11 @@ D = Differential(t)

# @test_skip begin # Yingbo: instability
prob = ODEProblem(ssys, [
collect(body.w_a) .=> 0.01;
collect(body.r_0) .=> [0, -1e-5, 0]; # To make sure the spring has non-zero extent
collect(body.w_a) .=> 0.00;
collect(body.v_0) .=> 0;
], (0, 10))
sol = solve(prob, Rodas5P(), u0 = prob.u0 .+ 1e-5 .* randn.())
sol = solve(prob, Rodas5P(), u0 = prob.u0 .+ 0*1e-5 .* randn.())
@test SciMLBase.successful_retcode(sol)
@test sol(2pi, idxs = body.r_0[1])0 atol=1e-3
@test sol(2pi, idxs = body.r_0[2])0 atol=1e-3
Expand Down

0 comments on commit d7ba8b5

Please sign in to comment.