Skip to content

Commit 7908a3b

Browse files
committed
add broken test
1 parent b584d5a commit 7908a3b

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/fancy_joints.jl

+11-10
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ end
447447
angle ~ compute_angle2(length_constraint, e_array, r_a_array, r_b_array, positive_branch)[1]
448448
# angle ~ Symbolics.term(compute_angle2, length_constraint, e_array, r_a_array, r_b_array, positive_branch, type=Real)
449449
else
450-
angle ~ compute_angle2(length_constraint, e, r_a, r_b, positive_branch)[1]
450+
# angle ~ Symbolics.term(compute_angle, length_constraint, e..., r_a..., r_b..., positive_branch, type=Real)
451+
angle ~ compute_angle(length_constraint, e, r_a, r_b, positive_branch)
451452
end
452453
]
453454

@@ -721,7 +722,7 @@ end
721722
eltype = Bool
722723
end
723724

724-
function compute_angle(L::Real, e::AbstractVector, r_a::AbstractVector, r_b::AbstractVector, positive_branch)
725+
function compute_angle(L::Real, e, r_a, r_b, positive_branch)
725726
e_r_a = e'r_a
726727
e_r_b = e'r_b
727728
A = -2*(r_b'r_a - e_r_b'e_r_a)
@@ -730,7 +731,7 @@ function compute_angle(L::Real, e::AbstractVector, r_a::AbstractVector, r_b::Abs
730731
k1 = A^2 + B^2
731732
k1a = k1 - C^2
732733
if k1a isa AbstractFloat
733-
k1a > 1e-10 || error("Singular position of loop (either no or two analytic solutions; the mechanism has lost one-degree-of freedom in this position). Try to use another joint-assembly component. In most cases it is best to let joints outside of the JointXXX component be revolute and _not_ prismatic joints. If this also leads to singular positions, it could be that this kinematic loop cannot be solved analytically. In this case you have to build up the loop with basic joints (_no_ aggregation JointXXX components) and rely on dynamic state selection, i.e., during simulation the states will be dynamically selected in such a way that in no position a degree of freedom is lost.")
734+
# k1a > 1e-10 || error("Singular position of loop (either no or two analytic solutions; the mechanism has lost one-degree-of freedom in this position). Try to use another joint-assembly component. In most cases it is best to let joints outside of the JointXXX component be revolute and _not_ prismatic joints. If this also leads to singular positions, it could be that this kinematic loop cannot be solved analytically. In this case you have to build up the loop with basic joints (_no_ aggregation JointXXX components) and rely on dynamic state selection, i.e., during simulation the states will be dynamically selected in such a way that in no position a degree of freedom is lost.")
734735
end
735736
k1b = max(k1a, 1.0e-12)
736737
k2 = sqrt(k1b)
@@ -747,7 +748,7 @@ function compute_angle2(L::Real, e::AbstractVector, r_a::AbstractVector, r_b::Ab
747748
C = r_a'r_a + r_b'r_b - L^2 - 2*e_r_b'e_r_a
748749
k1 = A^2 + B^2
749750
k1a = k1 - C^2
750-
k1a > 1e-10 || error("Singular position of loop (either no or two analytic solutions; the mechanism has lost one-degree-of freedom in this position). Try to use another joint-assembly component. In most cases it is best to let joints outside of the JointXXX component be revolute and _not_ prismatic joints. If this also leads to singular positions, it could be that this kinematic loop cannot be solved analytically. In this case you have to build up the loop with basic joints (_no_ aggregation JointXXX components) and rely on dynamic state selection, i.e., during simulation the states will be dynamically selected in such a way that in no position a degree of freedom is lost.")
751+
# k1a > 1e-10 || error("Singular position of loop (either no or two analytic solutions; the mechanism has lost one-degree-of freedom in this position). Try to use another joint-assembly component. In most cases it is best to let joints outside of the JointXXX component be revolute and _not_ prismatic joints. If this also leads to singular positions, it could be that this kinematic loop cannot be solved analytically. In this case you have to build up the loop with basic joints (_no_ aggregation JointXXX components) and rely on dynamic state selection, i.e., during simulation the states will be dynamically selected in such a way that in no position a degree of freedom is lost.")
751752
k1b = max(k1a, 1.0e-12)
752753
k2 = sqrt(k1b)
753754
kcos1 = -A*C + B*k2*ifelse(positive_branch == true, 1, -1)
@@ -764,9 +765,9 @@ end
764765

765766
# @register_symbolic compute_angle(L::Num, e1::Num, e1::Num, e2::Num, r_a1::Num, r_a2::Num, r_a3::Num, r_b1::Num, r_b2::Num, r_b3::Num, positive_branch)
766767

767-
# function compute_angle(L::Real, e1::Real, e2::Real, e3::Real, r_a1::Real, r_a2::Real, r_a3::Real, r_b1::Real, r_b2::Real, r_b3::Real, positive_branch)
768-
# e = SA[e1, e2, e3]
769-
# r_a = SA[r_a1, r_a2, r_a3]
770-
# r_b = SA[r_b1, r_b2, r_b3]
771-
# compute_angle(L, e, r_a, r_b, positive_branch)
772-
# end
768+
function compute_angle(L::Real, e1::Real, e2::Real, e3::Real, r_a1::Real, r_a2::Real, r_a3::Real, r_b1::Real, r_b2::Real, r_b3::Real, positive_branch)
769+
e = SA[e1, e2, e3]
770+
r_a = SA[r_a1, r_a2, r_a3]
771+
r_b = SA[r_b1, r_b2, r_b3]
772+
compute_angle(L, e, r_a, r_b, positive_branch)
773+
end

src/joints.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ If a planar loop is present, e.g., consisting of 4 revolute joints where the joi
616616

617617
Rrel0 = planar_rotation(n, 0, 0)
618618
varw = false
619-
@named Rrel = NumRotationMatrix(; R = Rrel0.R, w = Rrel0.w, varw)
619+
@named Rrel = NumRotationMatrix(; R = Rrel0.R, w = Rrel0.w, varw, state_priority = -1)
620620

621621
n = collect(n)
622622
ey_a = collect(ey_a)

test/test_JointUSR_RRR.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ end
3232
@named model = TestUSR()
3333
model = complete(model)
3434
ssys = structural_simplify(IRSystem(model))
35-
prob = ODEProblem(ssys, [], (0.0, 1.0))
36-
sol = solve(prob, FBDF(autodiff=true))
35+
##
3736

37+
prob = ODEProblem(ssys, [model.b1.a_0[1]=>0.0, D(D(model.p1.s))=>0.0], (0.0, 1.0))
38+
sol = solve(prob, FBDF(autodiff=true))
39+
@test_broken !all(iszero, sol(1.0))
3840

3941
# NOTE: I was working on trying to register the compute_angle function so that there are no symbolic arguments left in the generated code
4042

0 commit comments

Comments
 (0)