Skip to content

Commit d9ec5bf

Browse files
committed
add use_arrays kwarg
1 parent 2d6a55a commit d9ec5bf

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/fancy_joints.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ end
377377

378378

379379
@component function RevoluteWithLengthConstraint(; name, n = Float64[0, 0, 1], axisflange = false,
380-
positive_branch = true, radius = 0.05, length = radius, color = [0.5019608f0,0.0f0,0.5019608f0,1.0f0], state_priority = 1.0, phi_offset=0, phi_guess=0, length_constraint=1)
380+
positive_branch = true, radius = 0.05, length = radius, color = [0.5019608f0,0.0f0,0.5019608f0,1.0f0], state_priority = 1.0, phi_offset=0, phi_guess=0, length_constraint=1, use_arrays = false)
381381
systems = @named begin
382382
frame_a = Frame()
383383
frame_b = Frame()
@@ -401,11 +401,11 @@ end
401401
description = "Driving torque in direction of axis of rotation",
402402
]
403403
@variables phi(t) [
404-
# state_priority = state_priority,
404+
state_priority = 1,
405405
description = "Relative rotation angle from frame_a to frame_b",
406406
]
407407
@variables angle(t) [
408-
# state_priority = -1,
408+
state_priority = -1,
409409
description = "= phi + phi_offset (relative rotation angle between frame_a and frame_b)",
410410
]
411411
@variables r_a(t)[1:3], [description = "Position vector from frame_a to frame_a side of length constraint, resolved in frame_a of revolute joint"]
@@ -443,9 +443,12 @@ end
443443
0 .~ collect(frame_a.f .+ resolve1(Rrel, frame_b.f))
444444
0 .~ collect(frame_a.tau .+ resolve1(Rrel, frame_b.tau))
445445

446-
# angle ~ compute_angle2(length_constraint, e_array, r_a_array, r_b_array, positive_branch)[1]
447-
# angle ~ Symbolics.term(compute_angle2, length_constraint, e_array, r_a_array, r_b_array, positive_branch, type=Real)
448-
angle ~ compute_angle(length_constraint, e, r_a, r_b, positive_branch)
446+
if use_arrays
447+
angle ~ compute_angle2(length_constraint, e_array, r_a_array, r_b_array, positive_branch)[1]
448+
# angle ~ Symbolics.term(compute_angle2, length_constraint, e_array, r_a_array, r_b_array, positive_branch, type=Real)
449+
else
450+
angle ~ compute_angle2(length_constraint, e, r_a, r_b, positive_branch)[1]
451+
end
449452
]
450453

451454
sys = ODESystem(eqs, t; name=:nothing, systems)#, parameter_dependencies = [positive_branch => select_branch(length_constraint, e, phi_offset + phi_guess, r_a, r_b)]) # JuliaSimCompiler ignores parameter dependencies, the user has to provide it instead
@@ -502,6 +505,7 @@ The rest of this joint aggregation is defined by the following parameters:
502505
phi_offset = 0,
503506
phi_guess = 0,
504507
positive_branch,
508+
use_arrays = false,
505509
)
506510
systems = @named begin
507511
frame_a = Frame()
@@ -550,6 +554,7 @@ The rest of this joint aggregation is defined by the following parameters:
550554
phi_offset,
551555
phi_guess,
552556
positive_branch,
557+
use_arrays,
553558
)
554559
push!(more_systems, revolute)
555560

test/test_JointUSR_RRR.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ W(args...; kwargs...) = Multibody.world
1616
@mtkmodel TestUSR begin
1717
@components begin
1818
world = W()
19-
j1 = JointUSR(positive_branch=true)
19+
j1 = JointUSR(positive_branch=true, use_arrays=false)
2020
fixed = FixedTranslation(r=[1,0,0])
2121
b1 = Body(isroot=false, neg_w=true)
2222
p1 = Prismatic(state_priority=100)
@@ -32,7 +32,7 @@ end
3232
@named model = TestUSR()
3333
model = complete(model)
3434
ssys = structural_simplify(IRSystem(model))
35-
prob = ODEProblem(ssys, [model.b1.a_0[1] => 0, D(D(model.p1.s)) => 0], (0.0, 1.0))
35+
prob = ODEProblem(ssys, [], (0.0, 1.0))
3636
sol = solve(prob, FBDF(autodiff=true))
3737

3838

0 commit comments

Comments
 (0)