Skip to content

Commit bd4a525

Browse files
committed
decodePackedType with solverParams type, part of #425
1 parent 5d62dc7 commit bd4a525

File tree

6 files changed

+41
-20
lines changed

6 files changed

+41
-20
lines changed

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG
1111
robotId::String
1212
sessionId::String
1313
description::String
14-
encodePackedTypeFunc
15-
getPackedTypeFunc
16-
decodePackedTypeFunc
14+
encodePackedTypeFunc #TODO Is this planed to be used or deprecated?
15+
getPackedTypeFunc #TODO Is this planed to be used or deprecated?
16+
decodePackedTypeFunc #TODO Is this planed to be used or deprecated?
1717
rebuildFactorMetadata!
1818
addHistory::Vector{Symbol}
1919
solverParams::T # Solver parameters

src/services/AbstractDFG.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ getAddHistory(dfg::AbstractDFG) = dfg.addHistory
5252
"""
5353
getSolverParams(dfg::AbstractDFG) = dfg.solverParams
5454

55+
"""
56+
$(SIGNATURES)
57+
"""
58+
getFactorOperationalMemoryType(par::AbstractParams) = par.factorOperationalMemoryType
59+
60+
getFactorOperationalMemoryType(dfg::AbstractDFG) = getFactorOperationalMemoryType(getSolverParams(dfg))
61+
5562
##------------------------------------------------------------------------------
5663
## Setters
5764
##------------------------------------------------------------------------------

src/services/Serialization.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ function packFactor(dfg::G, f::DFGFactor)::Dict{String, Any} where G <: Abstract
118118
return props
119119
end
120120

121+
122+
function decodePackedType(::Type{T}, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where {T<:FactorOperationalMemory, PT}
123+
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
124+
# Also look at parentmodule
125+
usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
126+
fulltype = DFG.FunctionNodeData{T{usrtyp}}
127+
factordata = convert(fulltype, packeddata)
128+
return factordata
129+
end
130+
131+
121132
function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G <: AbstractDFG
122133
label = packedProps["label"]
123134
timestamp = DateTime(packedProps["timestamp"])
@@ -129,10 +140,11 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
129140
packtype = getTypeFromSerializationModule(dfg, Symbol("Packed"*datatype))
130141

131142
packed = nothing
132-
fullFactor = nothing
143+
fullFactorData = nothing
133144
try
134145
packed = JSON2.read(data, GenericFunctionNodeData{packtype,String})
135-
fullFactor = getSerializationModule(dfg).decodePackedType(dfg, packed)
146+
decodeType = getFactorOperationalMemoryType(dfg)
147+
fullFactorData = decodePackedType(decodeType, packed)
136148
catch ex
137149
io = IOBuffer()
138150
showerror(io, ex, catch_backtrace())
@@ -147,11 +159,11 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
147159

148160
# Rebuild DFGFactor
149161
#TODO use constuctor to create factor
150-
factor = DFGFactor{typeof(fullFactor.fnc), Symbol}(Symbol(label), 0, timestamp)
162+
factor = DFGFactor{typeof(fullFactorData.fnc), Symbol}(Symbol(label), 0, timestamp)
151163

152164
union!(factor.tags, tags)
153-
# factor.data = fullFactor #TODO
154-
setSolverData!(factor, fullFactor)
165+
# factor.data = fullFactorData #TODO
166+
setSolverData!(factor, fullFactorData)
155167
factor._variableOrderSymbols = _variableOrderSymbols
156168
setSolvable!(factor, solvable)
157169

test/consolInterfaceDev.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function DFG.CloudGraphsDFG(; hostname="localhost",
3636
description,
3737
nothing,
3838
nothing,
39-
(dfg,f)->f,#IncrementalInference.decodePackedType,
39+
nothing,#IncrementalInference.CommonConvWrapper,
4040
(dfg,f)->f,#ncrementalInference.rebuildFactorMetadata!,
4141
solverParams=params)
4242

@@ -71,7 +71,7 @@ function DFG.CloudGraphsDFG(description::String,
7171
description,
7272
nothing,
7373
nothing,
74-
(dfg,f)->f,#IncrementalInference.decodePackedType,
74+
nothing,#IncrementalInference.CommonConvWrapper,
7575
(dfg,f)->f,#IncrementalInference.rebuildFactorMetadata!,
7676
solverParams=solverParams)
7777

test/runtests.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ end
4242

4343
if get(ENV, "SKIP_CGDFG_TESTS", "") != "true"
4444
@testset "Consolidation WIP Testing Driver: CloudGraphsDFG" begin
45-
global decodePackedType
46-
function decodePackedType(dfg::AbstractDFG, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where PT
47-
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
48-
# Also look at parentmodule
49-
usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
50-
fulltype = DFG.FunctionNodeData{TestCCW{usrtyp}}
51-
factordata = convert(fulltype, packeddata)
52-
return factordata
53-
end
45+
# global decodePackedType
46+
# function decodePackedType(dfg::AbstractDFG, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where PT
47+
# # usrtyp = convert(FunctorInferenceType, packeddata.fnc)
48+
# # Also look at parentmodule
49+
# usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
50+
# fulltype = DFG.FunctionNodeData{TestCCW{usrtyp}}
51+
# factordata = convert(fulltype, packeddata)
52+
# return factordata
53+
# end
5454
@info "Testing Driver: CloudGraphsDFG"
5555
global testDFGAPI = CloudGraphsDFG
5656
include("consolInterfaceDev.jl")
@@ -85,7 +85,8 @@ end
8585
if get(ENV, "IIF_TEST", "") == "true"
8686

8787
# Switch to our upstream test branch.
88-
Pkg.add(PackageSpec(name="IncrementalInference", rev="upstream/dfg_integration_test"))
88+
# Pkg.add(PackageSpec(name="IncrementalInference", rev="upstream/dfg_integration_test"))
89+
Pkg.add(PackageSpec(name="IncrementalInference", rev="develop"))
8990
@info "------------------------------------------------------------------------"
9091
@info "These tests are using IncrementalInference to do additional driver tests"
9192
@info "------------------------------------------------------------------------"

test/testBlocks.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct TestCCW{T} <: FactorOperationalMemory where {T<:FunctorInferenceType}
6161
end
6262
Base.:(==)(a::TestCCW, b::TestCCW) = a.usrfnc! == b.usrfnc!
6363

64+
DFG.getFactorOperationalMemoryType(par::NoSolverParams) = TestCCW
6465

6566
function Base.convert(::Type{DFG.FunctionNodeData{TestCCW{F}}},
6667
d::DFG.PackedFunctionNodeData{<:PackedInferenceType}) where F<:FunctorInferenceType

0 commit comments

Comments
 (0)