2
2
3
3
In this section constructing DFG graphs will be discussed. To start, bring DistributedFactorGraphs into your workspace:
4
4
5
- ``` julia
5
+ ``` @example buildingGraphs; continued = true
6
6
using DistributedFactorGraphs
7
7
```
8
8
@@ -13,6 +13,8 @@ So for the following examples, IncrementalInference will be used to create the v
13
13
``` julia
14
14
using Pkg
15
15
Pkg. add (" IncrementalInference" )
16
+ ```
17
+ ``` @example buildingGraphs; continued = true
16
18
using IncrementalInference
17
19
```
18
20
@@ -28,16 +30,16 @@ To continue the example, run one of the following to create a DFG driver:
28
30
29
31
### Creating a LightDFG Graph
30
32
31
- ``` julia
33
+ ``` @example buildingGraphs; continued = true
32
34
# Create a DFG with default solver parameters using the LightGraphs.jl driver.
33
- dfg = LightDFG {SolverParams} (params = SolverParams ())
35
+ dfg = LightDFG{SolverParams}(solverParams =SolverParams())
34
36
```
35
37
36
38
### Creating a CloudGraphsDFG Graph
37
39
38
40
``` julia
39
41
# Create a DFG with no solver parameters (just to demonstrate the difference) using the CloudGraphs driver, and connect it to a local Neo4j instance.
40
- dfg = CloudGraphsDFG {NoSolverParams} (" localhost" , 7474 , " neo4j" , " test" ,
42
+ cfg = CloudGraphsDFG {NoSolverParams} (" localhost" , 7474 , " neo4j" , " test" ,
41
43
" testUser" , " testRobot" , " testSession" )
42
44
```
43
45
@@ -60,7 +62,7 @@ In addition, the following optional parameters are provided:
60
62
61
63
Three variables are added:
62
64
63
- ``` julia
65
+ ``` @example buildingGraphs; continued = true
64
66
v1 = addVariable!(dfg, :x0, ContinuousScalar, labels = [:POSE], solvable=1)
65
67
v2 = addVariable!(dfg, :x1, ContinuousScalar, labels = [:POSE], solvable=1)
66
68
v3 = addVariable!(dfg, :l0, ContinuousScalar, labels = [:LANDMARK], solvable=1)
@@ -79,7 +81,7 @@ Additionally, the solvable flag is also set to indicate that the factor can be u
79
81
80
82
Four factors are added: a prior, a linear conditional relationship with a normal distribution between x0 and x1, and a pair of linear conditional relationships between each pose and the landmark.
81
83
82
- ``` julia
84
+ ``` @example buildingGraphs; continued = true
83
85
prior = addFactor!(dfg, [:x0], Prior(Normal(0,1)))
84
86
f1 = addFactor!(dfg, [:x0; :x1], LinearConditional(Normal(50.0,2.0)), solvable=1)
85
87
f1 = addFactor!(dfg, [:l0; :x0], LinearConditional(Normal(40.0,5.0)), solvable=1)
@@ -99,13 +101,19 @@ Reading, updating, and deleting all use DFG functions (as opposed to adding,
99
101
where using the IncrementalInference functions are recommended).
100
102
101
103
Each variable and factor is uniquely identified by its label. The list of
102
- variable and factor labels can be retrieved with the ` ls ` /` listVariables ` and
103
- ` lsf ` /` listFactors ` functions:
104
+ variable and factor labels can be retrieved with the [ ` ls ` ] ( @ref ) /[ ` listVariables ` ] ( @ref ) and
105
+ [ ` lsf ` ] ( @ref ) /[ ` listFactors ` ] ( @ref ) functions:
106
+
107
+ For example listing the variables in the graph we created above:
108
+ ``` @example buildingGraphs
109
+ ls(dfg)
110
+ ```
111
+
112
+ Or listing the factors:
113
+ ``` @example buildingGraphs
114
+ lsf(dfg)
115
+ ```
104
116
105
- - [ ` listVariables ` ] ( @ref )
106
- - [ ` ls ` ] ( @ref )
107
- - [ ` listFactors ` ] ( @ref )
108
- - [ ` lsf ` ] ( @ref )
109
117
110
118
To list all variables or factors (instead of just their labels), use the
111
119
` getVariables ` and ` getFactors ` functions:
0 commit comments