Skip to content

Commit 26312b7

Browse files
committed
update SOn tests
1 parent b279c7a commit 26312b7

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

IncrementalInference/test/testSpecialOrthogonalMani.jl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using DistributedFactorGraphs
22
using IncrementalInference
33
using LineSearches
44
using Manifolds
5+
using LieGroups
56
using StaticArrays
67
using Test
78

@@ -12,10 +13,10 @@ using Test
1213
##
1314

1415
# @defVariable SpecialOrthogonal2 SpecialOrthogonal(2) @MMatrix([1.0 0.0; 0.0 1.0])
15-
@defVariable SpecialOrthogonal2 SpecialOrthogonal(2) SMatrix{2,2}(1.0, 0.0, 0.0, 1.0)
16+
@defVariable SpecialOrthogonal2 SpecialOrthogonalGroup(2) SMatrix{2,2}(1.0, 0.0, 0.0, 1.0)
1617

1718
M = getManifold(SpecialOrthogonal2)
18-
@test M == SpecialOrthogonal(2)
19+
@test M == SpecialOrthogonalGroup(2)
1920
pT = getPointType(SpecialOrthogonal2)
2021
# @test pT == MMatrix{2, 2, Float64, 4}
2122
@test pT == SMatrix{2,2,Float64,4}
@@ -28,7 +29,7 @@ fg = initfg()
2829

2930
v0 = addVariable!(fg, :x0, SpecialOrthogonal2)
3031

31-
mp = ManifoldPrior(SpecialOrthogonal(2), SA[1.0 0.0; 0.0 1.0], MvNormal([0.01]))
32+
mp = ManifoldPrior(SpecialOrthogonalGroup(2), SA[1.0 0.0; 0.0 1.0], MvNormal([0.01]))
3233
p = addFactor!(fg, [:x0], mp)
3334

3435
##
@@ -43,7 +44,7 @@ vnd = getVariableState(fg, :x0, :default)
4344
##
4445

4546
v1 = addVariable!(fg, :x1, SpecialOrthogonal2)
46-
mf = ManifoldFactor(SpecialOrthogonal(2), MvNormal([pi], [0.01]))
47+
mf = ManifoldFactor(SpecialOrthogonalGroup(2), MvNormal([pi], [0.01]))
4748
f = addFactor!(fg, [:x0, :x1], mf)
4849

4950
doautoinit!(fg, :x1)
@@ -60,18 +61,18 @@ solveTree!(fg) #; smtasks, verbose=true, recordcliqs=ls(fg))
6061
end
6162

6263

63-
@testset "Test SpecialOrthogonal(3) prior" begin
64+
@testset "Test SpecialOrthogonalGroup(3) prior" begin
6465

6566
##
6667

6768
# Base.convert(::Type{<:Tuple}, M::SpecialOrthogonal{3}) = (:Euclid, :Euclid, :Euclid)
6869
# Base.convert(::Type{<:Tuple}, ::IIF.InstanceType{SpecialOrthogonal{3}}) = (:Euclid, :Euclid, :Euclid)
6970

70-
# @defVariable SO3 SpecialOrthogonal(3) @MMatrix([1.0 0.0; 0.0 1.0])
71-
@defVariable SO3 SpecialOrthogonal(3) SMatrix{3,3}(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)
71+
# @defVariable SO3 SpecialOrthogonalGroup(3) @MMatrix([1.0 0.0; 0.0 1.0])
72+
@defVariable SO3 SpecialOrthogonalGroup(3) SMatrix{3,3}(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)
7273

7374
M = getManifold(SO3)
74-
@test M == SpecialOrthogonal(3)
75+
@test M == SpecialOrthogonalGroup(3)
7576
pT = getPointType(SO3)
7677
# @test pT == MMatrix{2, 2, Float64, 4}
7778
@test pT == SMatrix{3,3,Float64,9}
@@ -84,41 +85,41 @@ fg = initfg()
8485

8586
v0 = addVariable!(fg, :x0, SO3)
8687

87-
mp = ManifoldPrior(SpecialOrthogonal(3), SA[1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0], MvNormal([0.01, 0.01, 0.01]))
88+
mp = ManifoldPrior(SpecialOrthogonalGroup(3), SA[1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0], MvNormal([0.01, 0.01, 0.01]))
8889
p = addFactor!(fg, [:x0], mp)
8990

9091
doautoinit!(fg, :x0)
9192

9293
vnd = getVariableState(fg, :x0, :default)
93-
@test all(isapprox.( mean(SpecialOrthogonal(3),vnd.val), [1 0 0; 0 1 0; 0 0 1], atol=0.01))
94+
@test all(isapprox.( mean(SpecialOrthogonalGroup(3),vnd.val), [1 0 0; 0 1 0; 0 0 1], atol=0.01))
9495
@test all(is_point.(Ref(M), vnd.val))
9596

9697
points = sampleFactor(fg, :x0f1, 100)
97-
_M = SpecialOrthogonal(3)
98+
_M = SpecialOrthogonalGroup(3)
9899
std(_M, points .|> Matrix)
99100

100101
##
101102

102103
v1 = addVariable!(fg, :x1, SO3)
103-
mf = ManifoldFactor(SpecialOrthogonal(3), MvNormal([0.01,0.01,0.01], [0.01,0.01,0.01]))
104+
mf = ManifoldFactor(SpecialOrthogonalGroup(3), MvNormal([0.01,0.01,0.01], [0.01,0.01,0.01]))
104105
f = addFactor!(fg, [:x0, :x1], mf)
105106

106107
doautoinit!(fg, :x1)
107108

108109
vnd = getVariableState(fg, :x1, :default)
109-
@test all(isapprox.( mean(SpecialOrthogonal(3),vnd.val), [0.9999 -0.00995 0.01005; 0.01005 0.9999 -0.00995; -0.00995 0.01005 0.9999], atol=0.01))
110+
@test all(isapprox.( mean(SpecialOrthogonalGroup(3),vnd.val), [0.9999 -0.00995 0.01005; 0.01005 0.9999 -0.00995; -0.00995 0.01005 0.9999], atol=0.01))
110111
@test all(is_point.(Ref(M), vnd.val))
111112

112113
# smtasks = Task[]
113114
solveTree!(fg) # ; smtasks, verbose=true, recordcliqs=ls(fg))
114115

115116
# test them again after solve
116117
vnd = getVariableState(fg, :x0, :default)
117-
@test all(isapprox.( mean(SpecialOrthogonal(3),vnd.val), [1 0 0; 0 1 0; 0 0 1], atol=0.01))
118+
@test all(isapprox.( mean(SpecialOrthogonalGroup(3),vnd.val), [1 0 0; 0 1 0; 0 0 1], atol=0.01))
118119
@test all(is_point.(Ref(M), vnd.val))
119120

120121
vnd = getVariableState(fg, :x1, :default)
121-
@test all(isapprox.( mean(SpecialOrthogonal(3),vnd.val), [0.9999 -0.00995 0.01005; 0.01005 0.9999 -0.00995; -0.00995 0.01005 0.9999], atol=0.01))
122+
@test all(isapprox.( mean(SpecialOrthogonalGroup(3),vnd.val), [0.9999 -0.00995 0.01005; 0.01005 0.9999 -0.00995; -0.00995 0.01005 0.9999], atol=0.01))
122123
@test all(is_point.(Ref(M), vnd.val))
123124

124125
# 23Q2 default HagerZhang fails with `AssertionError: isfinite(phi_c) && isfinite(dphi_c)`, using alternate LineSearch

0 commit comments

Comments
 (0)