Skip to content

Commit 0b0bd1f

Browse files
authored
Merge pull request #796 from JuliaRobotics/21Q3/ser/factorgrads
new features for deserializing factor gradients
2 parents e30ddde + fd4edce commit 0b0bd1f

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

src/FileDFG/services/FileDFG.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
152152
map(f->addFactor!(dfgLoadInto, f), factors)
153153

154154
# Finally, rebuild the CCW's for the factors to completely reinflate them
155+
# NOTE CREATES A NEW DFGFactor IF CCW TYPE CHANGES
155156
@info "Rebuilding CCW's for the factors..."
156157
for factor in factors
157158
rebuildFactorMetadata!(dfgLoadInto, factor)

src/LightDFG/services/LightDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ end
7979
# end
8080

8181

82-
function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, factor::F)::F where F <: AbstractDFGFactor
82+
function addFactor!(dfg::LightDFG{<:AbstractParams, <:AbstractDFGVariable, F}, factor::F) where F <: AbstractDFGFactor
8383
if haskey(dfg.g.factors, factor.label)
8484
error("Factor '$(factor.label)' already exists in the factor graph")
8585
end
8686
# TODO
8787
# @assert FactorGraphs.addFactor!(dfg.g, getVariableOrder(factor), factor)
88-
@assert FactorGraphs.addFactor!(dfg.g, factor._variableOrderSymbols, factor)
88+
@assert FactorGraphs.addFactor!(dfg.g, Symbol[factor._variableOrderSymbols...], factor)
8989
return factor
9090
end
9191

src/entities/DFGFactor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Designing (WIP)
3838
- in DFG.AbstractRelativeMinimize <: FunctorInferenceType
3939
- in Main.SomeFactor <: AbstractRelativeMinimize
4040
"""
41-
mutable struct GenericFunctionNodeData{T<:Union{PackedInferenceType, FunctorInferenceType, FactorOperationalMemory}}
41+
mutable struct GenericFunctionNodeData{T<:Union{<:PackedInferenceType, <:AbstractFactor, <:FactorOperationalMemory}}
4242
eliminated::Bool
4343
potentialused::Bool
4444
edgeIDs::Vector{Int}
@@ -80,7 +80,7 @@ end
8080
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T} where T <: AbstractPackedFactor
8181
PackedFunctionNodeData(args...) = PackedFunctionNodeData{typeof(args[4])}(args...)
8282

83-
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{AbstractFactor, FactorOperationalMemory}
83+
const FunctionNodeData{T} = GenericFunctionNodeData{T} where T <: Union{<:AbstractFactor, <:FactorOperationalMemory}
8484
FunctionNodeData(args...) = FunctionNodeData{typeof(args[4])}(args...)
8585

8686

src/services/AbstractDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ getFactorOperationalMemoryType(dfg::AbstractDFG) = getFactorOperationalMemoryTyp
7676
7777
Method must be overloaded by the user for Serialization to work.
7878
"""
79-
rebuildFactorMetadata!(dfg::AbstractDFG{<:AbstractParams}, factor::AbstractDFGFactor) = error("rebuildFactorMetadata! is not implemented for $(typeof(dfg))")
79+
rebuildFactorMetadata!(dfg::AbstractDFG{<:AbstractParams}, factor::AbstractDFGFactor, neighbors=[]) = error("rebuildFactorMetadata! is not implemented for $(typeof(dfg))")
8080

8181
##------------------------------------------------------------------------------
8282
## Setters

src/services/Serialization.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
373373

374374
# Rebuild DFGFactor
375375
#TODO use constuctor to create factor
376-
factor = DFGFactor(Symbol(label),
377-
timestamp,
378-
nstime,
379-
Set(tags),
380-
fullFactorData,
381-
solvable,
382-
Tuple(_variableOrderSymbols))
383-
376+
factor = DFGFactor( Symbol(label),
377+
timestamp,
378+
nstime,
379+
Set(tags),
380+
fullFactorData,
381+
solvable,
382+
Tuple(_variableOrderSymbols))
383+
#
384384

385385
# Note, once inserted, you still need to call rebuildFactorMetadata!
386386
return factor

0 commit comments

Comments
 (0)