You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DistributedFactorGraphs.jl provides a flexible factor graph API for use in the [Caesar.jl](https://github.com/JuliaRobotics/Caesar.jl) ecosystem. The package supplies:
8
8
* A standardized API for interacting with factor graphs
@@ -21,54 +21,20 @@ add DistributedFactorGraphs
21
21
```
22
22
23
23
# 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
27
24
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.
29
26
30
27
```julia
31
-
# To enable the Neo4j driver, import Neo4j.jl first
32
-
using Neo4j
33
28
using DistributedFactorGraphs
34
29
```
35
30
36
31
Both drivers support the same functions, so choose which you want to use when creating your initial DFG. For example:
37
32
38
33
```julia
39
34
# In-memory DFG
40
-
dfg =GraphsDFG{NoSolverParams}()
35
+
dfg =LightDFG{NoSolverParams}()
41
36
addVariable!(dfg, DFGVariable(:a))
42
37
addVariable!(dfg, DFGVariable(:b))
43
38
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.
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).
# 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
-
returnDFGVariableSummary(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
-
returnSkeletonDFGVariable(v)
97
31
end
98
32
99
-
function Base.convert(::Type{DFGFactorSummary}, f::DFGFactor)
100
-
Base.depwarn("convert to type DFGFactorSummary is deprecated use the constructor", :convert)
101
-
returnDFGFactorSummary(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)
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.
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
-
functiongetSubgraph(dfg::G,
206
-
variableFactorLabels::Vector{Symbol},
207
-
includeOrphanFactors::Bool=false,
208
-
addToDFG::H=_getDuplicatedEmptyDFG(dfg))::Hwhere {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")
#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
-
functionbuildSubgraphFromLabels!(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 )::AbstractDFGwhere 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)
0 commit comments