Skip to content

Commit a0224a9

Browse files
committed
Merge branch 'master' into maint/20Q2/gfnd#274part2
2 parents b5d92df + 6f83a4b commit a0224a9

16 files changed

+127
-396
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
- julia: 1.4
2929
env:
3030
- IIF_TEST=true
31-
- SKIP_CGDFG_TESTS=true
3231
if: NOT branch =~ ^release.*$
3332
- arch: arm64
3433
env: SKIP_CGDFG_TESTS=true

README.md

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# DistributedFactorGraphs.jl
22

3-
Release v0.7 | Dev | Coverage | Docs
4-
---------|-----|----------|------
5-
[![Build Status](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl.svg?branch=release/v0.7)](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl) | [![Build Status](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl.svg?branch=master)](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl) | [![Codecov Status](https://codecov.io/gh/JuliaRobotics/DistributedFactorGraphs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaRobotics/DistributedFactorGraphs.jl) | [![docs](https://img.shields.io/badge/docs-latest-blue.svg)](http://juliarobotics.github.io/DistributedFactorGraphs.jl/latest/)
3+
Release v0.7 | Dev | Coverage | DFG Docs | Caesar Docs |
4+
---------|-----|----------|------|------------
5+
[![Build Status](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl.svg?branch=release/v0.7)](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl) | [![Build Status](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl.svg?branch=master)](https://travis-ci.org/JuliaRobotics/DistributedFactorGraphs.jl) | [![Codecov Status](https://codecov.io/gh/JuliaRobotics/DistributedFactorGraphs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaRobotics/DistributedFactorGraphs.jl) | [![docs](https://img.shields.io/badge/docs-latest-blue.svg)](http://juliarobotics.github.io/DistributedFactorGraphs.jl/latest/) | [![docs](https://img.shields.io/badge/docs-latest-blue.svg)](http://juliarobotics.github.io/Caesar.jl/latest/)
66

77
DistributedFactorGraphs.jl provides a flexible factor graph API for use in the [Caesar.jl](https://github.com/JuliaRobotics/Caesar.jl) ecosystem. The package supplies:
88
* A standardized API for interacting with factor graphs
@@ -21,54 +21,20 @@ add DistributedFactorGraphs
2121
```
2222

2323
# Usage
24-
DistributedFactorGraphs (DFG) currently supports two implementations:
25-
* An in-memory factor graphs based on Graphs.jl and LightGraphs.jl
26-
* A Neo4j-based factor graph based on Neo4j.jl
2724

28-
The in-memory implementation is the default. The Neo4j driver can be enabled by importing Neo4j before DFG:
25+
The in-memory implementation is the default, using LightGraphs.jl.
2926

3027
```julia
31-
# To enable the Neo4j driver, import Neo4j.jl first
32-
using Neo4j
3328
using DistributedFactorGraphs
3429
```
3530

3631
Both drivers support the same functions, so choose which you want to use when creating your initial DFG. For example:
3732

3833
```julia
3934
# In-memory DFG
40-
dfg = GraphsDFG{NoSolverParams}()
35+
dfg = LightDFG{NoSolverParams}()
4136
addVariable!(dfg, DFGVariable(:a))
4237
addVariable!(dfg, DFGVariable(:b))
4338
addFactor!(dfg, [v1, v2], DFGFactor{Int, :Symbol}(:f1)) # Rather use a RoME-type factor here (e.g. Pose2Pose2) rather than an Int, this is just for demonstrative purposes.
4439
```
4540

46-
```julia
47-
# Neo4j-based DFG
48-
dfg = CloudGraphsDFG{NoSolverParams}("localhost", 7474, "neo4j", "test",
49-
"testUser", "testRobot", "testSession",
50-
nothing,
51-
nothing,
52-
IncrementalInference.decodePackedType)
53-
addVariable!(dfg, DFGVariable(:a))
54-
addVariable!(dfg, DFGVariable(:b))
55-
addFactor!(dfg, [v1, v2], DFGFactor{Int, :Symbol}(:f1)) # Rather use a RoME-type factor here (e.g. Pose2Pose2) rather than an Int, this is just for demonstrative purposes.
56-
```
57-
58-
Please see the documentation for more information on interacting with the factor graph.
59-
60-
## Setting up a Quick Neo4j Database
61-
The simplest way to set up a test database is with Docker. The Neo4j driver currenly doesn't work with Neo4j 4.0, version 3.5 can be used as in this example.
62-
63-
To pull the Neo4j image:
64-
```bash
65-
docker pull neo4j:3.5
66-
```
67-
68-
To run the image with user `neo4j` and password `test`:
69-
70-
```bash
71-
docker run -d --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=neo4j/test neo4j:3.5
72-
```
73-
74-
> **Note** If you just installed docker and having permission issues, please see [this ask Ubuntu forum](https://askubuntu.com/questions/941816/permission-denied-when-running-docker-after-installing-it-as-a-snap).

src/Deprecated.jl

Lines changed: 23 additions & 259 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,19 @@
44

55

66
##==============================================================================
7-
## Remove in 0.8
7+
## Remove in 0.9
88
##==============================================================================
99

10-
#TODO alias or deprecate
11-
@deprecate getVariableIds(dfg::AbstractDFG, regexFilter::Union{Nothing, Regex}=nothing; tags::Vector{Symbol}=Symbol[], solvable::Int=0) listVariables(dfg, regexFilter, tags=tags, solvable=solvable)
12-
13-
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
14-
15-
@deprecate listPPE(args...) listPPEs(args...)
16-
17-
export getLabelDict
18-
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")
19-
20-
export getAdjacencyMatrix
21-
"""
22-
$(SIGNATURES)
23-
Get a matrix indicating relationships between variables and factors. Rows are
24-
all factors, columns are all variables, and each cell contains either nothing or
25-
the symbol of the relating factor. The first row and first column are factor and
26-
variable headings respectively.
27-
"""
28-
function getAdjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::Matrix{Union{Nothing, Symbol}}
29-
error("Deprecated function, please use getBiadjacencyMatrix")
30-
end
31-
32-
@deprecate getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0) getBiadjacencyMatrix(dfg, solvable=solvable)
33-
10+
@deprecate buildSubgraphFromLabels!(dfg::AbstractDFG, varList::Vector{Symbol}) buildSubgraph(dfg, varList, 1)
3411

3512
Base.getproperty(x::DFGFactor,f::Symbol) = begin
36-
if f == :solvable
37-
getfield(x,:_dfgNodeParams).solvable
38-
elseif f == :_internalId
39-
getfield(x,:_dfgNodeParams)._internalId
40-
elseif f == :data
41-
Base.depwarn("DFGFactor get: data field is deprecated, use getSolverData", :getproperty)
42-
getfield(x, :solverData)
43-
else
44-
getfield(x,f)
45-
end
13+
if f == :solvable
14+
getfield(x,:_dfgNodeParams).solvable
15+
elseif f == :_internalId
16+
getfield(x,:_dfgNodeParams)._internalId
17+
else
18+
getfield(x,f)
19+
end
4620
end
4721

4822
Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
@@ -51,237 +25,27 @@ Base.setproperty!(x::DFGFactor,f::Symbol, val) = begin
5125
getfield(x,:_dfgNodeParams).solvable = val
5226
elseif f == :_internalId
5327
getfield(x,:_dfgNodeParams)._internalId = val
54-
elseif f == :data
55-
Base.depwarn("DFGFactor set: data field is deprecated, use getSolverData", :getproperty)
56-
setfield!(x,:solverData, val)
5728
else
5829
setfield!(x,f,val)
5930
end
60-
end
61-
62-
Base.getproperty(x::DFGVariable,f::Symbol) = begin
63-
# if f == :estimateDict
64-
# @warn "estimateDict is deprecated, use ppeDict instead"
65-
# getfield(x, :ppeDict)
66-
if f == :solvable
67-
getfield(x,:_dfgNodeParams).solvable
68-
elseif f == :_internalId
69-
getfield(x,:_dfgNodeParams)._internalId
70-
else
71-
getfield(x,f)
72-
end
73-
end
74-
75-
Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
76-
# if f == :estimateDict
77-
# error("estimateDict is deprecated, use ppeDict instead")
78-
if f == :solvable
79-
getfield(x,:_dfgNodeParams).solvable = val
80-
elseif f == :_internalId
81-
getfield(x,:_dfgNodeParams)._internalId = val
82-
else
83-
setfield!(x,f,val)
84-
end
85-
end
86-
87-
88-
#NOTE deprecate in favor of constructors because its not lossless: https://docs.julialang.org/en/v1/manual/conversion-and-promotion/#Conversion-vs.-Construction-1
89-
function Base.convert(::Type{DFGVariableSummary}, v::DFGVariable)
90-
Base.depwarn("convert to type DFGVariableSummary is deprecated use the constructor", :convert)
91-
return DFGVariableSummary(v)
92-
end
93-
94-
function Base.convert(::Type{SkeletonDFGVariable}, v::VariableDataLevel1)
95-
Base.depwarn("convert to type SkeletonDFGVariable is deprecated use the constructor", :convert)
96-
return SkeletonDFGVariable(v)
9731
end
9832

99-
function Base.convert(::Type{DFGFactorSummary}, f::DFGFactor)
100-
Base.depwarn("convert to type DFGFactorSummary is deprecated use the constructor", :convert)
101-
return DFGFactorSummary(f)
102-
end
103-
104-
function Base.convert(::Type{SkeletonDFGFactor}, f::FactorDataLevel1)
105-
Base.depwarn("convert to type SkeletonDFGFactor is deprecated use the constructor", :convert)
106-
return SkeletonDFGFactor(f)
107-
end
108-
109-
110-
@deprecate hasOrphans(dfg) !isConnected(dfg)
111-
@deprecate isFullyConnected(dfg) isConnected(dfg)
112-
113-
##==============================================================================
114-
## WIP on consolidated subgraph functions, aim to remove in 0.8
115-
##==============================================================================
116-
# Deprecate in favor of buildSubgraph, mergeGraph
117-
export getSubgraph, getSubgraphAroundNode
118-
export buildSubgraphFromLabels!
119-
120-
"""
121-
$(SIGNATURES)
122-
Common function for copying nodes from one graph into another graph.
123-
This is overridden in specialized implementations for performance.
124-
NOTE: copyGraphMetadata not supported yet.
125-
"""
126-
function _copyIntoGraph!(sourceDFG::G, destDFG::H, variableFactorLabels::Vector{Symbol}, includeOrphanFactors::Bool=false; copyGraphMetadata::Bool=false)::Nothing where {G <: AbstractDFG, H <: AbstractDFG}
127-
# Split into variables and factors
128-
Base.depwarn("_copyIntoGraph! is deprecated use copyGraph/deepcopyGraph[!]", :_copyIntoGraph!)
129-
130-
includeOrphanFactors && (@error "Adding orphaned factors is not supported")
131-
132-
sourceVariables = map(vId->getVariable(sourceDFG, vId), intersect(listVariables(sourceDFG), variableFactorLabels))
133-
sourceFactors = map(fId->getFactor(sourceDFG, fId), intersect(listFactors(sourceDFG), variableFactorLabels))
134-
if length(sourceVariables) + length(sourceFactors) != length(variableFactorLabels)
135-
rem = symdiff(map(v->v.label, sourceVariables), variableFactorLabels)
136-
rem = symdiff(map(f->f.label, sourceFactors), variableFactorLabels)
137-
error("Cannot copy because cannot find the following nodes in the source graph: $rem")
138-
end
139-
140-
# Now we have to add all variables first,
141-
for variable in sourceVariables
142-
if !exists(destDFG, variable)
143-
addVariable!(destDFG, deepcopy(variable))
144-
end
145-
end
146-
# And then all factors to the destDFG.
147-
for factor in sourceFactors
148-
# Get the original factor variables (we need them to create it)
149-
sourceFactorVariableIds = getNeighbors(sourceDFG, factor)
150-
# Find the labels and associated variables in our new subgraph
151-
factVariableIds = Symbol[]
152-
for variable in sourceFactorVariableIds
153-
if exists(destDFG, variable)
154-
push!(factVariableIds, variable)
155-
end
156-
end
157-
# Only if we have all of them should we add it (otherwise strange things may happen on evaluation)
158-
if includeOrphanFactors || length(factVariableIds) == length(sourceFactorVariableIds)
159-
if !exists(destDFG, factor)
160-
addFactor!(destDFG, deepcopy(factor))
161-
end
162-
end
163-
end
164-
165-
if copyGraphMetadata
166-
setUserData(destDFG, getUserData(sourceDFG))
167-
setRobotData(destDFG, getRobotData(sourceDFG))
168-
setSessionData(destDFG, getSessionData(sourceDFG))
169-
end
170-
return nothing
171-
end
172-
173-
"""
174-
$(SIGNATURES)
175-
Retrieve a deep subgraph copy around a given variable or factor.
176-
Optionally provide a distance to specify the number of edges should be followed.
177-
Optionally provide an existing subgraph addToDFG, the extracted nodes will be copied into this graph. By default a new subgraph will be created.
178-
Note: By default orphaned factors (where the subgraph does not contain all the related variables) are not returned. Set includeOrphanFactors to return the orphans irrespective of whether the subgraph contains all the variables.
179-
Note: Always returns the node at the center, but filters around it if solvable is set.
180-
"""
181-
function getSubgraphAroundNode(dfg::AbstractDFG, node::DFGNode, distance::Int=1, includeOrphanFactors::Bool=false, addToDFG::AbstractDFG=_getDuplicatedEmptyDFG(dfg); solvable::Int=0)::AbstractDFG
182-
183-
Base.depwarn("getSubgraphAroundNode is deprecated use buildSubgraph", :getSubgraphAroundNode)
184-
185-
if !exists(dfg, node.label)
186-
error("Variable/factor with label '$(node.label)' does not exist in the factor graph")
187-
end
188-
189-
neighbors = getNeighborhood(dfg, node.label, distance)
190-
191-
# for some reason: always returns the node at the center with || (nlbl == node.label)
192-
solvable != 0 && filter!(nlbl -> (getSolvable(dfg, nlbl) >= solvable) || (nlbl == node.label), neighbors)
193-
194-
# Copy the section of graph we want
195-
_copyIntoGraph!(dfg, addToDFG, neighbors, includeOrphanFactors)
196-
return addToDFG
197-
end
198-
199-
"""
200-
$(SIGNATURES)
201-
Get a deep subgraph copy from the DFG given a list of variables and factors.
202-
Optionally provide an existing subgraph addToDFG, the extracted nodes will be copied into this graph. By default a new subgraph will be created.
203-
Note: By default orphaned factors (where the subgraph does not contain all the related variables) are not returned. Set includeOrphanFactors to return the orphans irrespective of whether the subgraph contains all the variables.
204-
"""
205-
function getSubgraph(dfg::G,
206-
variableFactorLabels::Vector{Symbol},
207-
includeOrphanFactors::Bool=false,
208-
addToDFG::H=_getDuplicatedEmptyDFG(dfg))::H where {G <: AbstractDFG, H <: AbstractDFG}
209-
210-
Base.depwarn("getSubgraph is deprecated use buildSubgraph", :getSubgraph)
211-
212-
for label in variableFactorLabels
213-
if !exists(dfg, label)
214-
error("Variable/factor with label '$(label)' does not exist in the factor graph")
215-
end
33+
Base.getproperty(x::DFGVariable,f::Symbol) = begin
34+
if f == :solvable
35+
getfield(x,:_dfgNodeParams).solvable
36+
elseif f == :_internalId
37+
getfield(x,:_dfgNodeParams)._internalId
38+
else
39+
getfield(x,f)
21640
end
217-
218-
_copyIntoGraph!(dfg, addToDFG, variableFactorLabels, includeOrphanFactors)
219-
return addToDFG
22041
end
22142

222-
223-
# TODO needsahome: home should be in IIF, calling just deepcopyGraph, or copyGraph
224-
# Into, Labels, Subgraph are all implied from the parameters.
225-
# can alies names but like Sam suggested only on copy is needed.
226-
227-
228-
"""
229-
$SIGNATURES
230-
Construct a new factor graph object as a subgraph of `dfg <: AbstractDFG` based on the
231-
variable labels `syms::Vector{Symbols}`.
232-
233-
SamC: Can we not just use _copyIntoGraph! for this? Looks like a small refactor to make it work.
234-
Will paste in as-is for now and we can figure it out as we go.
235-
DF: Absolutely agree that subgraph functions should use `DFG._copyIntoGraph!` as a single dependency in the code base. There have been a repeated new rewrites of IIF.buildSubGraphFromLabels (basic wrapper is fine) but nominal should be to NOT duplicate DFG functionality in IIF -- rather use/improve the existing features in DFG. FYI, I have repeatedly refactored this function over and over to use DFG properly but somehow this (add/delete/Variable/Factor) version keeps coming back without using `_copyIntoGraph`!!??? See latest effort commented out below `buildSubgraphFromLabels!_SPECIAL`...
236-
237-
Notes
238-
- Slighly messy internals, but gets the job done -- some room for performance improvement.
239-
- Defaults to GraphDFG, but likely to change to LightDFG in future.
240-
- since DFG v0.6 LightDFG is the default.
241-
242-
DevNotes
243-
- TODO: still needs to be consolidated with `DFG._copyIntoGraph`
244-
245-
Related
246-
247-
listVariables, _copyIntoGraph!
248-
"""
249-
function buildSubgraphFromLabels!(dfg::G,
250-
syms::Vector{Symbol};
251-
subfg::AbstractDFG=(G <: InMemoryDFGTypes ? G : GraphsDFG)(params=getSolverParams(dfg)),
252-
solvable::Int=0,
253-
allowedFactors::Union{Nothing, Vector{Symbol}}=nothing )::AbstractDFG where G <: AbstractDFG
254-
#
255-
Base.depwarn("buildSubgraphFromLabels! is deprecated use copyGraph, buildSubgraph or buildCliqueSubgraph!(IIF)", :buildSubgraphFromLabels!)
256-
# add a little too many variables (since we need the factors)
257-
for sym in syms
258-
if solvable <= getSolvable(dfg, sym)
259-
getSubgraphAroundNode(dfg, getVariable(dfg, sym), 2, false, subfg, solvable=solvable)
260-
end
261-
end
262-
263-
# remove excessive variables that were copied by neighbors distance 2
264-
currVars = listVariables(subfg)
265-
toDelVars = setdiff(currVars, syms)
266-
for dv in toDelVars
267-
# delete any neighboring factors first
268-
for fc in lsf(subfg, dv)
269-
deleteFactor!(subfg, fc)
270-
end
271-
272-
# and the variable itself
273-
deleteVariable!(subfg, dv)
274-
end
275-
276-
# delete any factors not in the allowed list
277-
if allowedFactors != nothing
278-
delFcts = setdiff(lsf(subfg), allowedFactors)
279-
for dfct in delFcts
280-
deleteFactor!(subfg, dfct)
43+
Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
44+
if f == :solvable
45+
getfield(x,:_dfgNodeParams).solvable = val
46+
elseif f == :_internalId
47+
getfield(x,:_dfgNodeParams)._internalId = val
48+
else
49+
setfield!(x,f,val)
28150
end
282-
end
283-
284-
# orphaned variables are allowed, but not orphaned factors
285-
286-
return subfg
28751
end

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export
233233

234234
## Deprecated exports should be listed in Deprecated.jl if possible, otherwise here
235235
#TODO remove export in DFG v0.8.0
236-
export ConvolutionObject
236+
# export ConvolutionObject
237237

238238
## needsahome.jl
239239
import Base: print

0 commit comments

Comments
 (0)