Skip to content

Commit d4f219a

Browse files
committed
ic to guesses
1 parent 4a851bd commit d4f219a

3 files changed

Lines changed: 11 additions & 25 deletions

File tree

src/fancy_joints.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ This joint aggregation can be used in cases where in reality a rod with spherica
331331
render = render, [description="Whether or not to render the joint in animations"]
332332
end
333333

334-
pars = collect_all(pars)
334+
# pars = collect_all(pars)
335335

336336
vars = @variables begin
337337
f_rod(t), [description="Constraint force in direction of the rod (positive on frame_a, when directed from frame_a to frame_b)"]
@@ -340,14 +340,14 @@ This joint aggregation can be used in cases where in reality a rod with spherica
340340
# e3_ia(t)[1:3], [description="Unit vector perpendicular to eRod_ia and e2_ia, resolved in frame_ia"]
341341
f_b_a1(t)[1:3], [description="frame_b.f without f_rod part, resolved in frame_a (needed for analytic loop handling)"]
342342
eRod_a(t)[1:3], [description="Unit vector in direction of rRod_a, resolved in frame_a (needed for analytic loop handling)"]
343-
rRod_0(t)[1:3] = rRod_ia, [description="Position vector from frame_a to frame_b resolved in world frame"]
344-
rRod_a(t)[1:3] = rRod_ia, [description="Position vector from frame_a to frame_b resolved in frame_a"]
345-
(constraint_residue(t) = 0), [description="Constraint equation of joint in residue form: Either length constraint (= default) or equation to compute rod force (for analytic solution of loops in combination with Internal.RevoluteWithLengthConstraint/PrismaticWithLengthConstraint)"]
343+
rRod_0(t)[1:3], [guess = rRod_ia, description="Position vector from frame_a to frame_b resolved in world frame"]
344+
rRod_a(t)[1:3], [guess = rRod_ia, description="Position vector from frame_a to frame_b resolved in frame_a"]
345+
(constraint_residue(t)), [guess = 0, description="Constraint equation of joint in residue form: Either length constraint (= default) or equation to compute rod force (for analytic solution of loops in combination with Internal.RevoluteWithLengthConstraint/PrismaticWithLengthConstraint)"]
346346
f_b_a(t)[1:3], [description="frame_b.f resolved in frame_a"]
347347
f_ia_a(t)[1:3], [description="frame_ia.f resolved in frame_a"]
348348
t_ia_a(t)[1:3], [description="frame_ia.t resolved in frame_a"]
349349
n2_a(t)[1:3], [description="Vector in direction of axis 2 of the universal joint (e2_ia), resolved in frame_a"]
350-
(length2_n2_a(t) = 1), [description="Square of length of vector n2_a"]
350+
(length2_n2_a(t)), [guess = 1, description="Square of length of vector n2_a"]
351351
length_n2_a(t), [description="Length of vector n2_a"]
352352
e2_a(t)[1:3], [description="Unit vector in direction of axis 2 of the universal joint (e2_ia), resolved in frame_a"]
353353
e3_a(t)[1:3], [description="Unit vector perpendicular to eRod_ia and e2_a, resolved in frame_a"]

test/test_fourbar.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ D = Differential(t)
1111
world = Multibody.world
1212

1313
systems = @named begin
14-
j1 = Revolute(n = [1, 0, 0], w0 = 5.235987755982989, state_priority=10.0, radius=0.1f0) # Increase state priority to ensure that this joint coordinate is chosen as state variable
14+
j1 = Revolute(n = [1, 0, 0], w0 = 5.235987755982989, state_priority=10, radius=0.1f0) # Increase state priority to ensure that this joint coordinate is chosen as state variable
1515
j2 = Prismatic(n = [1, 0, 0], s0 = -0.2)
1616
b1 = BodyShape(r = [0, 0.5, 0.1], radius=0.03)
1717
b2 = BodyShape(r = [0, 0.2, 0], radius=0.03)
@@ -38,7 +38,6 @@ connections = [connect(j2.frame_b, b2.frame_a)
3838
connect(b0.frame_b, j2.frame_a)
3939
]
4040
@named fourbar2 = System(connections, t, systems = [world; systems])
41-
fourbar2 = complete(fourbar2)
4241
ssys = multibody(fourbar2)
4342

4443
prob = ODEProblem(ssys, [], (0.0, 1.4399)) # The end time is chosen to make the animation below appear to loop forever
@@ -49,7 +48,7 @@ sol = solve(prob, FBDF(autodiff=true));
4948

5049

5150
systems = @named begin
52-
j1 = Revolute(n = [1, 0, 0], w0 = 5.235987755983, state_priority=12.0, radius=0.1f0) # Increase state priority to ensure that this joint coordinate is chosen as state variable
51+
j1 = Revolute(n = [1, 0, 0], w0 = 5.235987755983, phi0=nothing, state_priority=12, radius=0.1f0) # Increase state priority to ensure that this joint coordinate is chosen as state variable
5352
j2 = Prismatic(n = [1, 0, 0], s0 = -0.2)
5453
b1 = BodyShape(r = [0, 0.5, 0.1], radius=0.03)
5554
b2 = BodyShape(r = [0, 0.2, 0], radius=0.03)
@@ -67,9 +66,8 @@ connections = [connect(j2.frame_b, b2.frame_a)
6766
]
6867

6968
@named model = System(connections, t, systems = [world; systems])
70-
model = complete(model)
71-
ssys = multibody(model)
72-
prob = ODEProblem(ssys, [], (0.0, 1.4399)) # The end time is chosen to make the animation below appear to loop forever
69+
ssys = multibody(model, allow_symbolic=true)
70+
prob = ODEProblem(ssys, [], (0.0, 1.4399), guesses = [ssys.j1.phi => 0]) # The end time is chosen to make the animation below appear to loop forever
7371
sol2 = solve(prob, FBDF(autodiff=true)) # 3.9x faster than above
7472
# plot(sol2, idxs=[j2.s]) # Plot the joint coordinate of the prismatic joint (green in the animation below)
7573

test/test_wheels.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using LinearAlgebra
1414
I_long = 0.12,
1515
x0 = 0.2,
1616
z0 = 0.2,
17+
angles = [0,0,0],
1718
der_angles = [0, -5, -1])
1819
end
1920

@@ -31,22 +32,9 @@ end
3132
@named worldwheel = WheelInWorld()
3233

3334
defs = Dict([
34-
35-
])
36-
37-
ssys = multibody(worldwheel)
38-
guesses = Dict([
39-
# collect(ssys.wheel.wheeljoint.angles) .=> [0,0,0];
40-
ssys.wheel.wheeljoint.v_0[2] => 0.00001;
41-
# (ssys.wheel.wheeljoint.f_wheel_0)[3] => 0
42-
# (ssys.wheel.wheeljoint.vContact_0)[3] => 0
43-
# (ssys.wheel.wheeljoint.delta_0)[2] => 0
44-
# (ssys.wheel.wheeljoint.f_wheel_0)[2] => 0
45-
# (ssys.wheel.wheeljoint.f_wheel_0)[1] => 0
46-
# (ssys.wheel.wheeljoint.delta_0)[1] => 0
4735
])
4836

49-
prob = ODEProblem(ssys, [], (0, 4); guesses, missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG))
37+
prob = ODEProblem(ssys, defs, (0, 4); guesses, missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG))
5038
@test prob[collect(worldwheel.wheel.wheeljoint.der_angles)] == prob[collect(worldwheel.wheel.wheeljoint.der_angles)]
5139

5240
sol = solve(prob, Tsit5(), abstol=1e-8, reltol=1e-8)

0 commit comments

Comments
 (0)