Skip to content

Commit

Permalink
Merge pull request #1841 from JuliaRobotics/maint/mani_v0.10
Browse files Browse the repository at this point in the history
Updates for manifolds v0.10
  • Loading branch information
Affie authored Oct 3, 2024
2 parents 03fb278 + 500c82c commit b4a6b50
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ JSON3 = "1"
KernelDensityEstimate = "0.5.6"
LinearAlgebra = "1.10"
ManifoldDiff = "0.3"
Manifolds = "0.9.12"
Manifolds = "0.10"
ManifoldsBase = "0.15"
Manopt = "0.4.40"
Manopt = "0.4.40, 0.5"
MetaGraphs = "0.7"
Optim = "1"
OrderedCollections = "1"
PrecompileTools = "1"
ProgressMeter = "1"
RecursiveArrayTools = "2.31.1, 3"
RecursiveArrayTools = "3"
Reexport = "1"
SparseDiffTools = "2"
StaticArrays = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/services/FGOSUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function manikde!(
variableType::Union{InstanceType{<:InferenceVariable}, InstanceType{<:AbstractFactor}},
pts::AbstractVector{P};
kw...,
) where {P <: Union{<:AbstractArray, <:Number, <:Manifolds.ArrayPartition}}
) where {P <: Union{<:AbstractArray, <:Number, <: ArrayPartition}}
#
M = getManifold(variableType)
# @info "pts" P typeof(pts[1]) pts[1]
Expand Down
2 changes: 1 addition & 1 deletion src/services/GraphInit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ function initVariable!(
# TODO ArrayPartition inputs
_prodrepr(pt) = pt
# _prodrepr(pt::Tuple) = Manifolds.ProductRepr(pt...)
_prodrepr(pt::Tuple) = Manifolds.ArrayPartition(pt...)
_prodrepr(pt::Tuple) = ArrayPartition(pt...)

M = getManifold(vari)
pp = manikde!(M, _prodrepr.(pts); bw)
Expand Down
2 changes: 1 addition & 1 deletion src/services/SolverAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function solveTree!(
runtaskmonitor::Bool = true,
algorithm::Symbol = :default,
solveKey::Symbol = algorithm,
multithread::Bool = true,
multithread::Bool = false,
)
#
# workaround in case isolated variables occur
Expand Down
2 changes: 1 addition & 1 deletion test/basicGraphsOperations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ varT = LinearRelative{1}
manikde!(varT, pts)


DFG.@defVariable _TestManiKde IIF.Manifolds.SpecialEuclidean(2) ArrayPartition([0;0.], [1 0; 0 1.])
DFG.@defVariable _TestManiKde IIF.Manifolds.SpecialEuclidean(2; vectors=HybridTangentRepresentation()) ArrayPartition([0;0.], [1 0; 0 1.])

# construct directly with ArrayPartition
pts = [ArrayPartition(randn(2), [1 0; 0 1.]) for _ in 1:100]
Expand Down
2 changes: 1 addition & 1 deletion test/manifolds/factordiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end
##


M = SpecialEuclidean(2)
M = SpecialEuclidean(2; vectors=HybridTangentRepresentation())
z = ArrayPartition(SA[10.0; 0.0], SMatrix{2,2}(0.0, -1.0, 1.0, 0.0))

p1 = ArrayPartition(SA[0.0; 0.0], SMatrix{2,2}(1, 0, 0, 1.))
Expand Down
8 changes: 4 additions & 4 deletions test/manifolds/manifolddiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ sol = Optim.optimize(f, g_FD!, x0, Optim.ConjugateGradient(; manifold=ManifoldWr
end


@testset "Modified Manifolds.jl ManifoldWrapper <: Optim.Manifold for SpecialEuclidean(2)" begin
@testset "Modified Manifolds.jl ManifoldWrapper <: Optim.Manifold for SpecialEuclidean(2; vectors=HybridTangentRepresentation())" begin
##

M = Manifolds.SpecialEuclidean(2)
M = Manifolds.SpecialEuclidean(2; vectors=HybridTangentRepresentation())
e0 = ArrayPartition([0,0.], [1 0; 0 1.])

x0 = deepcopy(e0)
Expand Down Expand Up @@ -171,7 +171,7 @@ end
##


M = Manifolds.SpecialEuclidean(3)
M = Manifolds.SpecialEuclidean(3; vectors=HybridTangentRepresentation())
e0 = ArrayPartition([0,0,0.], Matrix(_Rot.RotXYZ(0,0,0.)))

x0 = deepcopy(e0)
Expand Down Expand Up @@ -217,7 +217,7 @@ end
@testset "Optim.Manifolds, SpecialEuclidean(3), using IIF.optimizeManifold_FD" begin
##

M = Manifolds.SpecialEuclidean(3)
M = Manifolds.SpecialEuclidean(3; vectors=HybridTangentRepresentation())
e0 = ArrayPartition([0,0,0.], Matrix(_Rot.RotXYZ(0,0,0.)))

x0 = deepcopy(e0)
Expand Down
2 changes: 1 addition & 1 deletion test/testBasicManifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Test

w = [-0.0;-0.78;-0.18]

M = SpecialEuclidean(3)
M = SpecialEuclidean(3; vectors=HybridTangentRepresentation())
Mr = M.manifold[2]
pPq = ArrayPartition(zeros(3), exp(Mr, Identity(Mr), hat(Mr, Identity(Mr), w)))
rPc_ = exp(M, Identity(M), hat(M, Identity(M), [zeros(3);w]))
Expand Down
76 changes: 38 additions & 38 deletions test/testSpecialEuclidean2Mani.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Rotations as _Rot

@defVariable TranslationGroup2 TranslationGroup(2) @SVector[0.0, 0.0]

@defVariable SpecialEuclidean2 SpecialEuclidean(2) ArrayPartition(@SVector([0.0,0.0]), @SMatrix([1.0 0.0; 0.0 1.0]))
@defVariable SpecialEuclidean2 SpecialEuclidean(2; vectors=HybridTangentRepresentation()) ArrayPartition(@SVector([0.0,0.0]), @SMatrix([1.0 0.0; 0.0 1.0]))
# @defVariable SpecialEuclidean2 SpecialEuclidean(2) ArrayPartition([0.0,0.0], [1.0 0.0; 0.0 1.0])

##
Expand All @@ -20,7 +20,7 @@ import Rotations as _Rot
##

M = getManifold(SpecialEuclidean2)
@test M == SpecialEuclidean(2)
@test M == SpecialEuclidean(2; vectors=HybridTangentRepresentation())
pT = getPointType(SpecialEuclidean2)
# @test pT == ArrayPartition{Float64,Tuple{Vector{Float64}, Matrix{Float64}}}
# @test pT == ArrayPartition{Tuple{MVector{2, Float64}, MMatrix{2, 2, Float64, 4}}}
Expand All @@ -38,8 +38,8 @@ v0 = addVariable!(fg, :x0, SpecialEuclidean2)

# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal(Diagonal(abs2.([0.01, 0.01, 0.01]))))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition([0.0,0.0], [1.0 0.0; 0.0 1.]), MvNormal(Diagonal(abs2.([0.01, 0.01, 0.01]))))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(SA[0.0,0.0], SA[1.0 0.0; 0.0 1.]), MvNormal(Diagonal(abs2.(SA[0.01, 0.01, 0.01]))))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition([0.0,0.0], [1.0 0.0; 0.0 1.]), MvNormal(Diagonal(abs2.([0.01, 0.01, 0.01]))))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(SA[0.0,0.0], SA[1.0 0.0; 0.0 1.]), MvNormal(Diagonal(abs2.(SA[0.01, 0.01, 0.01]))))
p = addFactor!(fg, [:x0], mp)


Expand All @@ -54,7 +54,7 @@ vnd = getVariableSolverData(fg, :x0)

##
v1 = addVariable!(fg, :x1, SpecialEuclidean2)
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal(SA[1,2,pi/4], SA[0.01,0.01,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal(SA[1,2,pi/4], SA[0.01,0.01,0.01]))
f = addFactor!(fg, [:x0, :x1], mf)

doautoinit!(fg, :x1)
Expand All @@ -77,7 +77,7 @@ vnd = getVariableSolverData(fg, :x1)
@test all(is_point.(Ref(M), vnd.val))

v1 = addVariable!(fg, :x2, SpecialEuclidean2)
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal(SA[1,2,pi/4], SA[0.01,0.01,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal(SA[1,2,pi/4], SA[0.01,0.01,0.01]))
f = addFactor!(fg, [:x1, :x2], mf)

##
Expand Down Expand Up @@ -140,7 +140,7 @@ struct ManifoldFactorSE2{T <: SamplableBelief} <: IIF.AbstractManifoldMinimize
end

ManifoldFactorSE2() = ManifoldFactorSE2(MvNormal(Diagonal([1,1,1])))
DFG.getManifold(::ManifoldFactorSE2) = SpecialEuclidean(2)
DFG.getManifold(::ManifoldFactorSE2) = SpecialEuclidean(2; vectors=HybridTangentRepresentation())

IIF.selectFactorType(::Type{<:SpecialEuclidean2}, ::Type{<:SpecialEuclidean2}) = ManifoldFactorSE2

Expand Down Expand Up @@ -168,7 +168,7 @@ M = getManifold(SpecialEuclidean2)
fg = initfg()
v0 = addVariable!(fg, :x0, SpecialEuclidean2)

mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([10.0,10.0]), Matrix([-1.0 0.0; 0.0 -1.0])), MvNormal([0.1, 0.1, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([10.0,10.0]), Matrix([-1.0 0.0; 0.0 -1.0])), MvNormal([0.1, 0.1, 0.01]))
p = addFactor!(fg, [:x0], mp)

##
Expand All @@ -177,16 +177,16 @@ for i in 0:5
psym = Symbol("x$i")
nsym = Symbol("x$(i+1)")
addVariable!(fg, nsym, SpecialEuclidean2)
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([10.0,0,pi/3], [0.5,0.5,0.05]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([10.0,0,pi/3], [0.5,0.5,0.05]))
f = addFactor!(fg, [psym;nsym], mf)
end


addVariable!(fg, :l1, SpecialEuclidean2, tags=[:LANDMARK;])
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([10.0,0,0], [0.1,0.1,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([10.0,0,0], [0.1,0.1,0.01]))
addFactor!(fg, [:x0; :l1], mf)

mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([10.0,0,0], [0.1,0.1,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([10.0,0,0], [0.1,0.1,0.01]))
addFactor!(fg, [:x6; :l1], mf)

##
Expand Down Expand Up @@ -225,7 +225,7 @@ getSolverParams(fg).useMsgLikelihoods = true
addVariable!(fg, :x0, SpecialEuclidean2)
addVariable!(fg, :x1, SpecialEuclidean2)

mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([10.0,10.0]), Matrix([-1.0 0.0; 0.0 -1.0])), MvNormal(diagm([0.1, 0.1, 0.01].^2)))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([10.0,10.0]), Matrix([-1.0 0.0; 0.0 -1.0])), MvNormal(diagm([0.1, 0.1, 0.01].^2)))
p = addFactor!(fg, [:x0], mp)

doautoinit!(fg,:x0)
Expand All @@ -238,7 +238,7 @@ initAll!(fg)

pred, meas = approxDeconv(fg, :x0x1f1)

@test mmd(SpecialEuclidean(2), pred, meas) < 1e-1
@test mmd(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), pred, meas) < 1e-1

p_t = map(x->x.x[1], pred)
m_t = map(x->x.x[1], meas)
Expand Down Expand Up @@ -278,7 +278,7 @@ DFG.getManifold(::ManiPose2Point2) = TranslationGroup(2)
# define the conditional probability constraint
function (cfo::CalcFactor{<:ManiPose2Point2})(measX, p, q)
#
M = SpecialEuclidean(2)
M = SpecialEuclidean(2; vectors=HybridTangentRepresentation())
q_SE = ArrayPartition(q, identity_element(SpecialOrthogonal(2), p.x[2]))

X_se2 = log(M, identity_element(M, p), Manifolds.compose(M, inv(M, p), q_SE))
Expand All @@ -288,7 +288,7 @@ function (cfo::CalcFactor{<:ManiPose2Point2})(measX, p, q)
end

##
@testset "Test SpecialEuclidean(2)" begin
@testset "Test SpecialEuclidean(2; vectors=HybridTangentRepresentation())" begin
##

# Base.convert(::Type{<:Tuple}, M::TranslationGroup{Tuple{2},ℝ}) = (:Euclid, :Euclid)
Expand All @@ -299,7 +299,7 @@ fg = initfg()

v0 = addVariable!(fg, :x0, SpecialEuclidean2)

mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
p = addFactor!(fg, [:x0], mp)

##
Expand Down Expand Up @@ -413,7 +413,7 @@ solveGraph!(fg; smtasks);

##

mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01],[1 0 0;0 1 0;0 0 1.]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01],[1 0 0;0 1 0;0 0 1.]))
f1 = addFactor!(fg, [:x0], mp, graphinit=false)

@test length(ls(fg, :x0)) == 2
Expand Down Expand Up @@ -471,15 +471,15 @@ f0 = addFactor!(fg, [:x0], pthru, graphinit=false)

## test the inference functions
addVariable!(fg, :x1, SpecialEuclidean2)
# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
# mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
f1 = addFactor!(fg, [:x1], mp, graphinit=false)

doautoinit!(fg, :x1)

## connect with relative and check calculation size on x0

mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
f2 = addFactor!(fg, [:x0, :x1], mf, graphinit=false)

##
Expand Down Expand Up @@ -507,10 +507,10 @@ hmd = LevelSetGridNormal(img_, (x_,y_), 5.5, 0.1, N=120)
pthru = PartialPriorPassThrough(hmd, (1,2))
f0 = addFactor!(fg, [:x0], pthru, graphinit=false)
addVariable!(fg, :x1, SpecialEuclidean2)
# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
# mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
f1 = addFactor!(fg, [:x1], mp, graphinit=false)
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
f2 = addFactor!(fg, [:x0, :x1], mf, graphinit=false)

##
Expand All @@ -531,16 +531,16 @@ initAll!(fg)
end


@testset "Test SpecialEuclidean(2) to TranslationGroup(2) multihypo" begin
@testset "Test SpecialEuclidean(2; vectors=HybridTangentRepresentation()) to TranslationGroup(2) multihypo" begin
##

fg = initfg()
# fg.solverParams.attemptGradients=false

v0 = addVariable!(fg, :x0, SpecialEuclidean2)

# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
# mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
p = addFactor!(fg, [:x0], mp)

##
Expand All @@ -552,7 +552,7 @@ f = addFactor!(fg, [:x0, :x1a, :x1b], mf; multihypo=[1,0.5,0.5])
solveTree!(fg)

vnd = getVariableSolverData(fg, :x0)
@test isapprox(SpecialEuclidean(2), mean(SpecialEuclidean(2), vnd.val), ArrayPartition([0.0,0.0], [1.0 0; 0 1]), atol=0.1)
@test isapprox(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), mean(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), vnd.val), ArrayPartition([0.0,0.0], [1.0 0; 0 1]), atol=0.1)

#FIXME I would expect close to 50% of particles to land on the correct place
# Currently software works so that 33% should land there so testing 20 for now
Expand All @@ -573,8 +573,8 @@ addVariable!(fg, :x0, SpecialEuclidean2)
addVariable!(fg, :x1a, TranslationGroup2)
addVariable!(fg, :x1b, TranslationGroup2)

# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([10, 10, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal(zeros(3),diagm([10, 10, 0.01])))
# mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([10, 10, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal(zeros(3),diagm([10, 10, 0.01])))
p = addFactor!(fg, [:x0], mp)
mp = ManifoldPrior(TranslationGroup(2), [1.,0], MvNormal([0.01, 0.01]))
p = addFactor!(fg, [:x1a], mp)
Expand All @@ -595,44 +595,44 @@ pnts = getPoints(fg, :x0)
@error "Invalid multihypo test"
if false
# FIXME ManiPose2Point2 factor mean [1.,0] cannot go "backwards" from [0,0] to [-1,0] with covariance 0.01 -- wholly inconsistent test design
@test 10 < sum(isapprox.(Ref(SpecialEuclidean(2)), pnts, Ref(ArrayPartition([-1.0,0.0], [1.0 0; 0 1])), atol=0.5))
@test 10 < sum(isapprox.(Ref(SpecialEuclidean(2)), pnts, Ref(ArrayPartition([1.0,0.0], [1.0 0; 0 1])), atol=0.5))
@test 10 < sum(isapprox.(Ref(SpecialEuclidean(2; vectors=HybridTangentRepresentation())), pnts, Ref(ArrayPartition([-1.0,0.0], [1.0 0; 0 1])), atol=0.5))
@test 10 < sum(isapprox.(Ref(SpecialEuclidean(2; vectors=HybridTangentRepresentation())), pnts, Ref(ArrayPartition([1.0,0.0], [1.0 0; 0 1])), atol=0.5))
end

##
end

@testset "Test SpecialEuclidean(2) to SpecialEuclidean(2) multihypo" begin
@testset "Test SpecialEuclidean(2; vectors=HybridTangentRepresentation()) to SpecialEuclidean(2; vectors=HybridTangentRepresentation()) multihypo" begin
##

fg = initfg()
# fg.solverParams.attemptGradients=false

v0 = addVariable!(fg, :x0, SpecialEuclidean2)

# mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
# mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
mp = ManifoldPrior(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), ArrayPartition(Vector([0.0,0.0]), Matrix([1.0 0.0; 0.0 1.0])), MvNormal([0.01, 0.01, 0.01]))
p = addFactor!(fg, [:x0], mp)

##
addVariable!(fg, :x1a, SpecialEuclidean2)
addVariable!(fg, :x1b, SpecialEuclidean2)
mf = ManifoldFactor(SpecialEuclidean(2), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
mf = ManifoldFactor(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), MvNormal([1,2,pi/4], [0.01,0.01,0.01]))
f = addFactor!(fg, [:x0, :x1a, :x1b], mf; multihypo=[1,0.5,0.5])

solveTree!(fg)

vnd = getVariableSolverData(fg, :x0)
@test isapprox(SpecialEuclidean(2), mean(SpecialEuclidean(2), vnd.val), ArrayPartition([0.0,0.0], [1.0 0; 0 1]), atol=0.1)
@test isapprox(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), mean(SpecialEuclidean(2; vectors=HybridTangentRepresentation()), vnd.val), ArrayPartition([0.0,0.0], [1.0 0; 0 1]), atol=0.1)

#FIXME I would expect close to 50% of particles to land on the correct place
# Currently software works so that 33% should land there so testing 20 for now
pnt = getPoints(fg, :x1a)
@test sum(isapprox.(Ref(SpecialEuclidean(2)), pnt, Ref(ArrayPartition([1.0,2.0], [0.7071 -0.7071; 0.7071 0.7071])), atol=0.1)) > 20
@test sum(isapprox.(Ref(SpecialEuclidean(2; vectors=HybridTangentRepresentation())), pnt, Ref(ArrayPartition([1.0,2.0], [0.7071 -0.7071; 0.7071 0.7071])), atol=0.1)) > 20

#FIXME I would expect close to 50% of particles to land on the correct place
pnt = getPoints(fg, :x1b)
@test sum(isapprox.(Ref(SpecialEuclidean(2)), pnt, Ref(ArrayPartition([1.0,2.0], [0.7071 -0.7071; 0.7071 0.7071])), atol=0.1)) > 20
@test sum(isapprox.(Ref(SpecialEuclidean(2; vectors=HybridTangentRepresentation())), pnt, Ref(ArrayPartition([1.0,2.0], [0.7071 -0.7071; 0.7071 0.7071])), atol=0.1)) > 20

##
end
Expand Down

0 comments on commit b4a6b50

Please sign in to comment.