Skip to content

Commit 9adc57a

Browse files
authored
Merge pull request #442 from JuliaRobotics/maint/2Q20/buildsfg
convenience buildSubgraph, fix #441
2 parents d2f47c6 + 06c5602 commit 9adc57a

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

src/Deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Remove in 0.9
88
##==============================================================================
99

10+
@deprecate buildSubgraphFromLabels!(dfg::AbstractDFG, varList::Vector{Symbol}) buildSubgraph(dfg, varList, 1)
1011

1112
Base.getproperty(x::DFGFactor,f::Symbol) = begin
1213
if f == :solvable

src/FileDFG/services/FileDFG.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE], solvable=0)
1717
saveDFG(dfg, "/tmp/saveDFG.tar.gz")
1818
```
1919
"""
20-
function saveDFG(dfg::AbstractDFG, folder::String; compress::Symbol=:null)
21-
22-
if compress != :null
23-
@warn "saveDFG keyword args are deprecated, and folders will be tarred as standard in current and future versions."
24-
end
20+
function saveDFG( dfg::AbstractDFG, folder::String )
2521

2622
# TODO: Deprecate the folder functionality in v0.6.1
2723

src/services/AbstractDFG.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ getSolverParams(dfg::AbstractDFG) = dfg.solverParams
5454

5555
"""
5656
$(SIGNATURES)
57+
58+
Method must be overloaded by the user for Serialization to work. E.g. IncrementalInference uses `CommonConvWrapper <: FactorOperationalMemory`.
5759
"""
58-
getFactorOperationalMemoryType(par::AbstractParams) = par.factorOperationalMemoryType
60+
getFactorOperationalMemoryType(dummy) = error("Please define this function getFactorOperationalMemoryType for your usecase, e.g. = `IIF.CommonConvWrapper <: FactorOperationalMemory`")
5961

60-
getFactorOperationalMemoryType(dfg::AbstractDFG) = getFactorOperationalMemoryType(getSolverParams(dfg))
6162

6263
##------------------------------------------------------------------------------
6364
## Setters
@@ -971,6 +972,14 @@ function buildSubgraph(::Type{G},
971972
return destDFG
972973
end
973974

975+
# Perhaps IIF.InMemDFGType should perhaps be incorporated as a DFG value, but this has been much debated in the past and hence just left as breadcrum.
976+
buildSubgraph(dfg::AbstractDFG,
977+
variableFactorLabels::Vector{Symbol},
978+
distance::Int=1;
979+
solvable::Int=0,
980+
sessionId::String = "",
981+
kwargs...) = buildSubgraph(typeof(LightDFG(params=getSolverParams(dfg))), dfg, variableFactorLabels, distance, solvable=solvable, sessionId=sessionId, kwargs...)
982+
974983
"""
975984
$(SIGNATURES)
976985
Merger sourceDFG to destDFG given an optional list of variables and factors and distance.

src/services/CompareUtils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ Compare and return if two factor graph objects are the same, by comparing simila
366366
Notes:
367367
- Default items to skip with `skipsamples`, `skipcompute`.
368368
- User defined fields to skip can be specified with `skip::Vector{Symbol}`.
369+
- To enable debug messages for viewing which fields are not the same:
370+
- https://stackoverflow.com/questions/53548681/how-to-enable-debugging-messages-in-juno-julia-editor
369371
370372
Related:
371373

test/consolInterfaceDev.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ using Dates
77
using UUIDs
88
# using IncrementalInference
99

10+
## must overload the function
11+
import DistributedFactorGraphs: getFactorOperationalMemoryType
12+
# DF, dropping DFG. so that Main context is used and can be overridden by IIF.getFac...Type
13+
getFactorOperationalMemoryType(::CloudGraphsDFG) = TestCCW
14+
15+
1016
include("testBlocks.jl")
1117

1218
##

test/testBlocks.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ 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
64+
65+
## must overload the function
66+
import DistributedFactorGraphs: getFactorOperationalMemoryType
67+
68+
# DF, dropping DFG. so that Main context is used and can be overridden by IIF.getFac...Type
69+
getFactorOperationalMemoryType(par::NoSolverParams) = TestCCW
6570

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

0 commit comments

Comments
 (0)