11using DistributedFactorGraphs
22using Test
33using Dates
4- using Manifolds
4+ using LieGroups
5+ using LieGroups: TranslationGroup
6+ # using Manifolds
57
68using DistributedFactorGraphs:
79 LabelExistsError,
@@ -13,61 +15,32 @@ using DistributedFactorGraphs:
1315import Base: convert
1416# import DistributedFactorGraphs: getData, addData!, updateData!, deleteData!
1517
16- Base. convert (:: Type{<:Tuple} , :: typeof (Euclidean (1 ))) = (:Euclid ,)
17- Base. convert (:: Type{<:Tuple} , :: typeof (Euclidean (2 ))) = (:Euclid , :Euclid )
18+ # Base.convert(::Type{<:Tuple}, ::typeof(TranslationGroup (1))) = (:Euclid,)
19+ # Base.convert(::Type{<:Tuple}, ::typeof(TranslationGroup (2))) = (:Euclid, :Euclid)
1820
19- @defVariable TestVariableType1 Euclidean (1 ) [0.0 ;]
20- DFG. @defStateTypeN TestVariableType{N} Euclidean (N) zeros (N)
21+ # define a few varaible to use
22+ @defVariable TestVariableType1 TranslationGroup (1 ) [0.0 ;]
23+ DFG. @defStateTypeN TestVariableType{N} TranslationGroup (N) zeros (N)
2124const TestVariableType2 = TestVariableType{2 }
2225
23- struct TestFunctorInferenceType1 <: AbstractRelative end
24- struct TestFunctorInferenceType2 <: AbstractRelative end
26+ # define a few factor types to use
27+ DFG. @defObservationType TestFunctorInferenceType1 RelativeObservation TranslationGroup (1 )
28+ DFG. @defObservationType TestFunctorInferenceType2 RelativeObservation TranslationGroup (1 )
29+ DFG. @defObservationType TestAbstractPrior PriorObservation TranslationGroup (1 )
2530
26- struct TestAbstractPrior <: PriorObservation end
27- # struct TestAbstractRelativeFactor <: AbstractRelativeRoots end
28- struct TestAbstractRelativeFactorMinimize <: RelativeObservation end
31+ TestFunctorInferenceType1 () = TestFunctorInferenceType1 ( nothing )
32+ TestFunctorInferenceType2 () = TestFunctorInferenceType2 ( nothing )
33+ TestAbstractPrior () = TestAbstractPrior ( nothing )
2934
30- Base. @kwdef struct PackedTestFunctorInferenceType1 <: AbstractPackedObservation
31- s:: String = " "
32- end
33- # PackedTestFunctorInferenceType1() = PackedTestFunctorInferenceType1("")
34-
35- function Base. convert (:: Type{PackedTestFunctorInferenceType1} , d:: TestFunctorInferenceType1 )
36- # @info "convert(::Type{PackedTestFunctorInferenceType1}, d::TestFunctorInferenceType1)"
37- return PackedTestFunctorInferenceType1 ()
38- end
39-
40- function DFG. reconstFactorData (
41- dfg:: AbstractDFG ,
42- vo:: AbstractVector ,
43- :: Type{TestFunctorInferenceType1} ,
44- d:: PackedTestFunctorInferenceType1 ,
45- :: String ,
46- )
47- error (" obsolete, TODO remove" )
48- return TestFunctorInferenceType1 ()
49- end
50-
51- # overly simplified test requires both reconstitute and convert
52- function Base. convert (:: Type{TestFunctorInferenceType1} , d:: PackedTestFunctorInferenceType1 )
53- # @info "convert(::Type{TestFunctorInferenceType1}, d::PackedTestFunctorInferenceType1)"
54- return TestFunctorInferenceType1 ()
55- end
56-
57- Base. @kwdef struct PackedTestAbstractPrior <: AbstractPackedObservation
58- s:: String = " "
59- end
60- # PackedTestAbstractPrior() = PackedTestAbstractPrior("")
61-
62- function Base. convert (:: Type{PackedTestAbstractPrior} , d:: TestAbstractPrior )
63- # @info "convert(::Type{PackedTestAbstractPrior}, d::TestAbstractPrior)"
64- return PackedTestAbstractPrior ()
35+ struct PackedNothingDistribution <: AbstractPackedBelief
36+ _type:: Symbol
37+ function PackedNothingDistribution (; _type:: String = " PackedNothingDistribution" )
38+ return new (Symbol (_type))
39+ end
6540end
6641
67- function Base. convert (:: Type{TestAbstractPrior} , d:: PackedTestAbstractPrior )
68- # @info "onvert(::Type{TestAbstractPrior}, d::PackedTestAbstractPrior)"
69- return TestAbstractPrior ()
70- end
42+ DFG. packDistribution (:: Nothing ) = PackedNothingDistribution ()
43+ DFG. unpackDistribution (:: PackedNothingDistribution ) = nothing
7144
7245struct TestCCW{T <: AbstractObservation } <: FactorCache
7346 usrfnc!:: T
@@ -77,46 +50,6 @@ TestCCW{T}() where {T} = TestCCW(T())
7750
7851Base.:(== )(a:: TestCCW , b:: TestCCW ) = a. usrfnc! == b. usrfnc!
7952
80- # DFG.rebuildFactorCache!(dfg::AbstractDFG{NoSolverParams}, fac::FactorCompute) = fac
81-
82- function DFG. reconstFactorData (
83- dfg:: AbstractDFG ,
84- vo:: AbstractVector ,
85- :: Type{<:DFG.FunctionNodeData{TestCCW{F}}} ,
86- d:: DFG.PackedFunctionNodeData{<:AbstractPackedObservation} ,
87- ) where {F <: DFG.AbstractObservation }
88- error (" obsolete, TODO remove" )
89- nF = convert (F, d. fnc)
90- return DFG. FunctionNodeData (
91- d. eliminated,
92- d. potentialused,
93- d. edgeIDs,
94- TestCCW (nF),
95- d. multihypo,
96- d. certainhypo,
97- d. nullhypo,
98- d. solveInProgress,
99- d. inflation,
100- )
101- end
102-
103- function Base. convert (
104- :: Type{DFG.PackedFunctionNodeData{P}} ,
105- d:: DFG.FunctionNodeData{<:FactorCache} ,
106- ) where {P <: AbstractPackedObservation }
107- return DFG. PackedFunctionNodeData (
108- d. eliminated,
109- d. potentialused,
110- d. edgeIDs,
111- convert (P, d. fnc. usrfnc!),
112- d. multihypo,
113- d. certainhypo,
114- d. nullhypo,
115- d. solveInProgress,
116- d. inflation,
117- )
118- end
119-
12053# #
12154# global testDFGAPI = GraphsDFG
12255# T = testDFGAPI
@@ -357,7 +290,7 @@ function DFGVariableSCA()
357290 # variableType functions
358291 testvar = TestVariableType1 ()
359292 @test getDimension (testvar) == 1
360- @test getManifold (testvar) == Euclidean (1 )
293+ @test getManifold (testvar) == TranslationGroup (1 )
361294
362295 # #TODO sort out
363296 # getPPEs
@@ -410,8 +343,8 @@ function DFGFactorSCA()
410343 @test setSolvable! (f1, 1 ) == 1
411344
412345 # TODO These 2 function are equivelent
413- @test typeof (getFactorType (f1)) == TestFunctorInferenceType1
414- @test typeof (getFactorFunction (f1)) == TestFunctorInferenceType1
346+ @test typeof (getFactorType (f1)) == TestFunctorInferenceType1{Nothing}
347+ @test typeof (getFactorFunction (f1)) == TestFunctorInferenceType1{Nothing}
415348
416349 # TODO here for now, don't recommend usage.
417350 testTags = [:tag1 , :tag2 ]
@@ -1148,12 +1081,15 @@ function testGroup!(fg, v1, v2, f0, f1)
11481081 @test isPrior (fg, :af1 ) # if f1 is prior
11491082 @test lsfPriors (fg) == [:af1 ]
11501083
1151- @test issetequal ([TestFunctorInferenceType1, TestAbstractPrior], DFG. lsfTypes (fg))
1084+ @test issetequal (
1085+ [TestFunctorInferenceType1{Nothing}, TestAbstractPrior{Nothing}],
1086+ DFG. lsfTypes (fg),
1087+ )
11521088
11531089 facTypesDict = DFG. lsfTypesDict (fg)
11541090 @test issetequal (collect (keys (facTypesDict)), DFG. lsfTypes (fg))
1155- @test issetequal (facTypesDict[TestFunctorInferenceType1], [:abf1 ])
1156- @test issetequal (facTypesDict[TestAbstractPrior], [:af1 ])
1091+ @test issetequal (facTypesDict[TestFunctorInferenceType1{Nothing} ], [:abf1 ])
1092+ @test issetequal (facTypesDict[TestAbstractPrior{Nothing} ], [:af1 ])
11571093
11581094 @test ls (fg, TestFunctorInferenceType1) == [:abf1 ]
11591095 @test lsf (fg, TestAbstractPrior) == [:af1 ]
@@ -1672,7 +1608,7 @@ function ProducingDotFiles(
16721608 @test DFG. toDot (dotdfg) ==
16731609 " graph graphname {\n 2 [\" label\" =\" b\" ,\" shape\" =\" ellipse\" ,\" fillcolor\" =\" red\" ,\" color\" =\" red\" ]\n 2 -- 3\n 3 [\" label\" =\" abf1\" ,\" shape\" =\" box\" ,\" fillcolor\" =\" blue\" ,\" color\" =\" blue\" ]\n 1 [\" label\" =\" a\" ,\" shape\" =\" ellipse\" ,\" fillcolor\" =\" red\" ,\" color\" =\" red\" ]\n 1 -- 3\n }\n "
16741610 end
1675- @test DFG. toDotFile (dotdfg, " something.dot" ) == nothing
1611+ @test DFG. toDotFile (dotdfg, " something.dot" ) === nothing
16761612 return Base. rm (" something.dot" )
16771613end
16781614
0 commit comments