Skip to content

Commit

Permalink
Merge pull request #376 from JuliaRobotics/21Q1/backcompat/iif20
Browse files Browse the repository at this point in the history
fix test on v0.11.3 w/ IIF v0.20
  • Loading branch information
dehann authored Jan 6, 2021
2 parents 4b0bab7 + 6aa6737 commit e6e8f4c
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 44 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DistributedFactorGraphs = "0.10.2, 0.11"
Distributions = "0.21, 0.22, 0.23, 0.24"
DocStringExtensions = "0.7, 0.8"
FileIO = "1.0.2, 1.1, 1.2"
IncrementalInference = "0.17, 0.18, 0.19"
IncrementalInference = "0.18, 0.19, 0.20"
JLD2 = "0.2, 0.3"
KernelDensityEstimate = "0.5.1, 0.6"
Optim = "0.22, 1.0"
Expand All @@ -49,7 +49,8 @@ julia = "1.4"

[extras]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Flux"]
test = ["Test", "Flux", "Pkg"]
23 changes: 23 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,31 @@

using RoME
using Test
using Pkg


pkgversion(m::Module) = Pkg.TOML.parsefile(joinpath(dirname(string(first(methods(m.eval)).file)), "..", "Project.toml"))["version"]

@show pkgversion(IncrementalInference)

function _defaultFactorMetadataRoME(Xi::AbstractVector{<:DFGVariable};
solvefor::Symbol=:null,
arrRef=Vector{Matrix{Float64}}(),
cachedata::T=nothing ) where T
#


#NOTE temp for IIF v0.20 migration
# FIXME standardize fmd, see #927
iifv = pkgversion(IncrementalInference) |> string |> VersionNumber
ret = if iifv < v"0.20"
FactorMetadata(solvefor,map(x->x.label,Xi),cachedata,copy(Xi), arrRef)
else
FactorMetadata(copy(Xi), map(x->x.label,Xi), arrRef, solvefor, cachedata)
end
return ret
end

@error("must restore testG2oParser.jl")
# "testG2oParser.jl"; ]

Expand Down
2 changes: 1 addition & 1 deletion test/testBearingRange2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ li = zeros(2,1); li[1,1] = 20.0;
zi = (zeros(2,1),); zi[1][2,1] = 20.0

# dummy fmd during refactoring and consolidation work
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

idx = 1
res = zeros(2)
Expand Down
46 changes: 23 additions & 23 deletions test/testBeehive2D_CliqByCliq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,36 @@ tree, smt, hist = solveTree!(fg) #, recordcliqs=ls(fg))
# drawTree(tree, show=true)
# smt[3]

@test 55 < sum(-3.0 .< getPoints(getKDE(fg, :x0))[1,:] .< 3.0)
@test 55 < sum(-3.0 .< getPoints(getKDE(fg, :x0))[2,:] .< 3.0)
@test 55 < sum(-0.3 .< getPoints(getKDE(fg, :x0))[3,:] .< 0.3)
@test 45 < sum(-3.0 .< getPoints(getKDE(fg, :x0))[1,:] .< 3.0)
@test 45 < sum(-3.0 .< getPoints(getKDE(fg, :x0))[2,:] .< 3.0)
@test 45 < sum(-0.3 .< getPoints(getKDE(fg, :x0))[3,:] .< 0.3)

@test 55 < sum(7.0 .< getPoints(getKDE(fg, :x1))[1,:] .< 13.0)
@test 55 < sum(-3.0 .< getPoints(getKDE(fg, :x1))[2,:] .< 3.0)
@test 55 < sum(0.7 .< getPoints(getKDE(fg, :x1))[3,:] .< 1.3)
@test 45 < sum(7.0 .< getPoints(getKDE(fg, :x1))[1,:] .< 13.0)
@test 45 < sum(-3.0 .< getPoints(getKDE(fg, :x1))[2,:] .< 3.0)
@test 45 < sum(0.7 .< getPoints(getKDE(fg, :x1))[3,:] .< 1.3)

@test 55 < sum(12.0 .< getPoints(getKDE(fg, :x2))[1,:] .< 18.0)
@test 55 < sum(6.0 .< getPoints(getKDE(fg, :x2))[2,:] .< 11.0)
@test 55 < sum(1.8 .< getPoints(getKDE(fg, :x2))[3,:] .< 2.4)
@test 45 < sum(12.0 .< getPoints(getKDE(fg, :x2))[1,:] .< 18.0)
@test 45 < sum(6.0 .< getPoints(getKDE(fg, :x2))[2,:] .< 11.0)
@test 45 < sum(1.8 .< getPoints(getKDE(fg, :x2))[3,:] .< 2.4)

@test 55 < sum(7.0 .< getPoints(getKDE(fg, :x3))[1,:] .< 13.0)
@test 55 < sum(15.0 .< getPoints(getKDE(fg, :x3))[2,:] .< 20.0)
# @test 55 < sum(-0.3 .< getPoints(getKDE(fg, :x3))[3,:] .< 0.3)
@test 45 < sum(7.0 .< getPoints(getKDE(fg, :x3))[1,:] .< 13.0)
@test 45 < sum(15.0 .< getPoints(getKDE(fg, :x3))[2,:] .< 20.0)
# @test 45 < sum(-0.3 .< getPoints(getKDE(fg, :x3))[3,:] .< 0.3)

@test 55 < sum(-5.0 .< getPoints(getKDE(fg, :x4))[1,:] .< 5.0)
@test 55 < sum(13.0 .< getPoints(getKDE(fg, :x4))[2,:] .< 22.0)
@test 55 < sum(-2.8 .< getPoints(getKDE(fg, :x4))[3,:] .< -1.5)
@test 45 < sum(-5.0 .< getPoints(getKDE(fg, :x4))[1,:] .< 5.0)
@test 45 < sum(13.0 .< getPoints(getKDE(fg, :x4))[2,:] .< 22.0)
@test 45 < sum(-2.8 .< getPoints(getKDE(fg, :x4))[3,:] .< -1.5)

@test 55 < sum(-8.0 .< getPoints(getKDE(fg, :x5))[1,:] .< -2.0)
@test 55 < sum(6.0 .< getPoints(getKDE(fg, :x5))[2,:] .< 11.0)
@test 55 < sum(-1.3 .< getPoints(getKDE(fg, :x5))[3,:] .< -0.7)
@test 45 < sum(-8.0 .< getPoints(getKDE(fg, :x5))[1,:] .< -2.0)
@test 45 < sum(6.0 .< getPoints(getKDE(fg, :x5))[2,:] .< 11.0)
@test 45 < sum(-1.3 .< getPoints(getKDE(fg, :x5))[3,:] .< -0.7)

@test 55 < sum(-3.0 .< getPoints(getKDE(fg, :x6))[1,:] .< 3.0)
@test 55 < sum(-3.0 .< getPoints(getKDE(fg, :x6))[2,:] .< 3.0)
@test 55 < sum(-0.3 .< getPoints(getKDE(fg, :x6))[3,:] .< 0.3)
@test 45 < sum(-3.0 .< getPoints(getKDE(fg, :x6))[1,:] .< 3.0)
@test 45 < sum(-3.0 .< getPoints(getKDE(fg, :x6))[2,:] .< 3.0)
@test 45 < sum(-0.3 .< getPoints(getKDE(fg, :x6))[3,:] .< 0.3)

@test 55 < sum(17.0 .< getPoints(getKDE(fg, :l1))[1,:] .< 23.0)
@test 55 < sum(-5.0 .< getPoints(getKDE(fg, :l1))[2,:] .< 5.0)
@test 45 < sum(17.0 .< getPoints(getKDE(fg, :l1))[1,:] .< 23.0)
@test 45 < sum(-5.0 .< getPoints(getKDE(fg, :l1))[2,:] .< 5.0)



Expand Down
13 changes: 7 additions & 6 deletions test/testDidsonFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ addFactor!(fg, [:x0;:x1], meas)

##

fmd = IIF._defaultFactorMetadata([X0;X1], arrRef=t)
fmd = _defaultFactorMetadataRoME([X0;X1], arrRef=t)

ccw = CommonConvWrapper(meas, t[2], zDim, t, fmd, measurement=measurement, varidx=2)

# TODO remove
ccw.measurement = measurement
ccw.cpt[1].res = zeros(1)

@time ccw(zeros(3), zeros(3))
@time ccw(zeros(3))
# deprecated
# @time ccw(zeros(3), zeros(3))
# @time ccw(zeros(3))



Expand Down Expand Up @@ -78,7 +79,7 @@ X0 = addVariable!(fg, :x0, Pose3)
X1 = addVariable!(fg, :x1, Pose3)
addFactor!(fg, [:x0;:x1], meas)

fmd = IIF._defaultFactorMetadata([X0;X1], arrRef=t)
fmd = _defaultFactorMetadataRoME([X0;X1], arrRef=t)

ccw = CommonConvWrapper(meas, t[1], zDim, t, fmd, varidx=1, measurement=measurement)

Expand All @@ -87,8 +88,8 @@ ccw.measurement = measurement
ccw.cpt[1].res = zeros(1)

# pre-emptively populate the measurements, kept separate since nlsolve calls fp(x, res) multiple times
@time ccw(zeros(3), zeros(6))
@time ccw(zeros(6))
# @time ccw(zeros(3), zeros(6))
# @time ccw(zeros(6))


@time for n in 1:N
Expand Down
18 changes: 9 additions & 9 deletions test/testPartialXYH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ res = zeros(6)
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

testpp3(res, fmd, 1, (veeEuler(x1Tx2),), vectoarr2(veeEuler(wTx1)), vectoarr2(veeEuler(wTx2)))
@test norm(res[1:3]) < 1e-10
Expand Down Expand Up @@ -66,7 +66,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

# z translation only
wTx = Vector{AffineMap}(undef,2)
Expand Down Expand Up @@ -115,7 +115,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

# different orientation, roll
wTx = Vector{AffineMap}(undef, 2)
Expand Down Expand Up @@ -167,7 +167,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, roll
Expand Down Expand Up @@ -221,7 +221,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, pitch
Expand Down Expand Up @@ -274,7 +274,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, pitch
Expand Down Expand Up @@ -329,7 +329,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, pitch
Expand Down Expand Up @@ -385,7 +385,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, pitch
Expand Down Expand Up @@ -445,7 +445,7 @@ end
fg_ = initfg()
X0 = addVariable!(fg_, :x0, Pose3)
X1 = addVariable!(fg_, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

wTx = Vector{AffineMap}(undef, 2)
# different orientation, yaw
Expand Down
5 changes: 3 additions & 2 deletions test/testhigherdimroots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ X0 = addVariable!(fg,:x0,Sphere1)
X1 = addVariable!(fg,:x1,Sphere1)
addFactor!(fg, [:x0;:x1], rr)

fmd = IIF._defaultFactorMetadata([X0;X1], arrRef=t)
fmd = _defaultFactorMetadataRoME([X0;X1], arrRef=t)

ccw = CommonConvWrapper(rr, t[1], zDim, t, fmd, measurement=(eul,)) # old bug where measurement is not patched through fixed in IIF v0.3.9

Expand All @@ -106,7 +106,8 @@ ccw = CommonConvWrapper(rr, t[1], zDim, t, fmd, measurement=(eul,)) # old bug wh
# TODO remove
ccw.measurement = (eul,)

ccw(res, x0)
# deprecated
# ccw(res, x0)

# and return complete fr/gwp
n = 1
Expand Down
2 changes: 1 addition & 1 deletion test/testpartialpose3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
tfg = initfg()
X0 = addVariable!(tfg, :x0, Pose3)
X1 = addVariable!(tfg, :x1, Pose3)
fmd = IIF._defaultFactorMetadata([X0;X1])
fmd = _defaultFactorMetadataRoME([X0;X1])

res = zeros(3)
idx = 1
Expand Down

0 comments on commit e6e8f4c

Please sign in to comment.