@@ -8,7 +8,7 @@ import IncrementalInference: HeatmapDensityRegular
88
99# # define new local variable types for testing
1010
11- @defVariable Point2 TranslationGroup (2 ) [0.0 , 0.0 ]
11+ @defVariable TranslationGroup2 TranslationGroup (2 ) [0.0 , 0.0 ]
1212
1313# @defVariable SpecialEuclidean2 SpecialEuclidean(2) ProductRepr(@MVector([0.0,0.0]), @MMatrix([1.0 0.0; 0.0 1.0]))
1414@defVariable SpecialEuclidean2 SpecialEuclidean (2 ) ProductRepr ([0.0 ,0.0 ], [1.0 0.0 ; 0.0 1.0 ])
@@ -195,7 +195,7 @@ mp = ManifoldPrior(SpecialEuclidean(2), ProductRepr(@MVector([0.0,0.0]), @MMatri
195195p = addFactor! (fg, [:x0 ], mp)
196196
197197# #
198- v1 = addVariable! (fg, :x1 , Point2 )
198+ v1 = addVariable! (fg, :x1 , TranslationGroup2 )
199199mf = ManiPose2Point2 (MvNormal ([1 ,2 ], [0.01 ,0.01 ]))
200200f = addFactor! (fg, [:x0 , :x1 ], mf)
201201
@@ -376,4 +376,98 @@ initAll!(fg)
376376end
377377
378378
379+ @testset " Test SpecialEuclidean(2) to TranslationGroup(2) multihypo" begin
380+
381+ # #
382+ fg = initfg ()
383+ # fg.solverParams.attemptGradients=false
384+
385+ v0 = addVariable! (fg, :x0 , SpecialEuclidean2)
386+
387+ mp = ManifoldPrior (SpecialEuclidean (2 ), ProductRepr (@MVector ([0.0 ,0.0 ]), @MMatrix ([1.0 0.0 ; 0.0 1.0 ])), MvNormal ([0.01 , 0.01 , 0.01 ]))
388+ p = addFactor! (fg, [:x0 ], mp)
389+
390+ # #
391+ addVariable! (fg, :x1a , TranslationGroup2)
392+ addVariable! (fg, :x1b , TranslationGroup2)
393+ mf = ManiPose2Point2 (MvNormal ([1 ,2 ], [0.01 ,0.01 ]))
394+ f = addFactor! (fg, [:x0 , :x1a , :x1b ], mf; multihypo= [1 ,0.5 ,0.5 ])
395+
396+ solveTree! (fg)
397+
398+ vnd = getVariableSolverData (fg, :x0 )
399+ @test isapprox (SpecialEuclidean (2 ), mean (SpecialEuclidean (2 ), vnd. val), ProductRepr ([0.0 ,0.0 ], [1.0 0 ; 0 1 ]), atol= 0.1 )
400+
401+ # FIXME I would expect close to 50% of particles to land on the correct place
402+ pnt = getPoints (fg, :x1a )
403+ @test sum (isapprox .(pnt, Ref ([1.0 ,2.0 ]), atol= 0.1 )) > 25
404+
405+ # FIXME I would expect close to 50% of particles to land on the correct place
406+ pnt = getPoints (fg, :x1b )
407+ @test sum (isapprox .(pnt, Ref ([1.0 ,2.0 ]), atol= 0.1 )) > 25
408+
409+
410+ # # other way around
411+
412+ fg = initfg ()
413+ fg. solverParams. attemptGradients= false
414+
415+ addVariable! (fg, :x0 , SpecialEuclidean2)
416+ addVariable! (fg, :x1a , TranslationGroup2)
417+ addVariable! (fg, :x1b , TranslationGroup2)
418+
419+ mp = ManifoldPrior (SpecialEuclidean (2 ), ProductRepr (@MVector ([0.0 ,0.0 ]), @MMatrix ([1.0 0.0 ; 0.0 1.0 ])), MvNormal ([10 , 10 , 0.01 ]))
420+ p = addFactor! (fg, [:x0 ], mp)
421+ mp = ManifoldPrior (TranslationGroup (2 ), [1. ,1 ], MvNormal ([0.01 , 0.01 ]))
422+ p = addFactor! (fg, [:x1a ], mp)
423+ mp = ManifoldPrior (TranslationGroup (2 ), [- 1. ,1 ], MvNormal ([0.01 , 0.01 ]))
424+ p = addFactor! (fg, [:x1b ], mp)
425+
426+ mf = ManiPose2Point2 (MvNormal ([0. , 1 ], [0.01 ,0.01 ]))
427+ f = addFactor! (fg, [:x0 , :x1a , :x1b ], mf; multihypo= [1 ,0.5 ,0.5 ])
428+
429+ solveTree! (fg)
430+
431+ # pnts = getPoints(fg, :x0)
432+ # c = getCoordinates.(SpecialEuclidean2, pnts)
433+ # @cast p[i,j] := c[i][j]
434+ # scatter(p[:,1], p[:,2])
435+
436+ # FIXME
437+ @test 10 < sum (isapprox .(Ref (SpecialEuclidean (2 )), pnts, Ref (ProductRepr ([- 1.0 ,0.0 ], [1.0 0 ; 0 1 ])), atol= 0.5 ))
438+ @test 10 < sum (isapprox .(Ref (SpecialEuclidean (2 )), pnts, Ref (ProductRepr ([1.0 ,0.0 ], [1.0 0 ; 0 1 ])), atol= 0.5 ))
439+
440+
441+ end
442+
443+ @testset " Test SpecialEuclidean(2) to SpecialEuclidean(2) multihypo" begin
444+ # #
445+ fg = initfg ()
446+ # fg.solverParams.attemptGradients=false
447+
448+ v0 = addVariable! (fg, :x0 , SpecialEuclidean2)
449+
450+ mp = ManifoldPrior (SpecialEuclidean (2 ), ProductRepr (@MVector ([0.0 ,0.0 ]), @MMatrix ([1.0 0.0 ; 0.0 1.0 ])), MvNormal ([0.01 , 0.01 , 0.01 ]))
451+ p = addFactor! (fg, [:x0 ], mp)
452+
453+ # #
454+ addVariable! (fg, :x1a , SpecialEuclidean2)
455+ addVariable! (fg, :x1b , SpecialEuclidean2)
456+ mf = ManifoldFactor (SpecialEuclidean (2 ), MvNormal ([1 ,2 ,pi / 4 ], [0.01 ,0.01 ,0.01 ]))
457+ f = addFactor! (fg, [:x0 , :x1a , :x1b ], mf; multihypo= [1 ,0.5 ,0.5 ])
458+
459+ solveTree! (fg)
460+
461+ vnd = getVariableSolverData (fg, :x0 )
462+ @test isapprox (SpecialEuclidean (2 ), mean (SpecialEuclidean (2 ), vnd. val), ProductRepr ([0.0 ,0.0 ], [1.0 0 ; 0 1 ]), atol= 0.1 )
463+
464+ # FIXME I would expect close to 50% of particles to land on the correct place
465+ pnt = getPoints (fg, :x1a )
466+ @test sum (isapprox .(Ref (SpecialEuclidean (2 )), pnt, Ref (ProductRepr ([1.0 ,2.0 ], [0.7071 - 0.7071 ; 0.7071 0.7071 ])), atol= 0.1 )) > 25
467+
468+ # FIXME I would expect close to 50% of particles to land on the correct place
469+ pnt = getPoints (fg, :x1b )
470+ @test sum (isapprox .(Ref (SpecialEuclidean (2 )), pnt, Ref (ProductRepr ([1.0 ,2.0 ], [0.7071 - 0.7071 ; 0.7071 0.7071 ])), atol= 0.1 )) > 25
471+
472+ end
379473#
0 commit comments