Skip to content

Commit 78db1a5

Browse files
committed
Merge branch 'feature/IIFTests' into jt/develop
2 parents 5353d3a + 3bb2354 commit 78db1a5

File tree

6 files changed

+439
-12
lines changed

6 files changed

+439
-12
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ julia = "0.7, 1"
3030
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3131
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
3232
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
33+
IncrementalInference = "904591bb-b899-562f-9e6f-b8df64c7d480"
3334

3435
[targets]
35-
test = ["Test", "GraphPlot", "Neo4j"]
36+
test = ["Test", "GraphPlot", "Neo4j", "IncrementalInference"]

src/services/AbstractDFG.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,22 @@ Notes:
472472
- used by both factor graph variable and Bayes tree clique logic.
473473
"""
474474
function isInitialized(var::DFGVariable; key::Symbol=:default)::Bool
475-
solverData(var, key) != nothing && return solverData(var, key).initialized
476-
return false
475+
data = solverData(var, key)
476+
if data == nothing
477+
@error "Variable does not have solver data $(key)"
478+
return false
479+
else
480+
return solverData(var, key).initialized
481+
end
477482
end
478483
function isInitialized(fct::DFGFactor; key::Symbol=:default)::Bool
479-
solverData(var, key) != nothing && return solverData(fct, key).initialized
480-
return false
484+
data = solverData(var, key)
485+
if data == nothing
486+
@error "Factor does not have solver data $(key)"
487+
return false
488+
else
489+
return solverData(fct, key).initialized
490+
end
481491
end
482492
function isInitialized(dfg::G, label::Symbol; key::Symbol=:default)::Bool where G <: AbstractDFG
483493
return isInitialized(getVariable(dfg, label), key=key)

test/IIF4DoorsTests.jl

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using GraphPlot
2+
using Neo4j
3+
using DistributedFactorGraphs
4+
using IncrementalInference
5+
6+
@testset "test fourdoor early example" begin
7+
8+
DistributedFactorGraphs.CloudGraphsDFG{SolverParams}() = CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",
9+
"testUser", "testRobot", "testSession",
10+
nothing,
11+
nothing,
12+
IncrementalInference.decodePackedType,
13+
IncrementalInference.rebuildFactorMetadata!,
14+
solverParams=SolverParams())
15+
16+
N=100
17+
# fg = initfg(CloudGraphsDFG{SolverParams}())
18+
fg = initfg(GraphsDFG{SolverParams})
19+
20+
doors = reshape(Float64[-100.0;0.0;100.0;300.0],1,4)
21+
pd = kde!(doors,[3.0])
22+
pd = resample(pd,N);
23+
bws = getBW(pd)[:,1]
24+
doors2 = getPoints(pd);
25+
26+
27+
addVariable!(fg,:x0,ContinuousScalar,N=N)
28+
addFactor!(fg,[:x0], Prior( pd ) )
29+
30+
# tem = 2.0*randn(1,N)+getVal(v1)+50.0
31+
addVariable!(fg,:x2, ContinuousScalar, N=N)
32+
addFactor!(fg, [:x0; :x2], LinearConditional(Normal(50.0,2.0)) )
33+
# addFactor!(fg, [v1;v2], Odo(50.0*ones(1,1),[2.0]',[1.0]))
34+
35+
36+
# monocular sighting would look something like
37+
#addFactor!(fg, Mono, [:x3,:l1], [14.0], [1.0], [1.0])
38+
#addFactor!(fg, Mono, [:x4,:l1], [11.0], [1.0], [1.0])
39+
40+
addVariable!(fg,:x3,ContinuousScalar, N=N)
41+
addFactor!(fg,[:x2;:x3], LinearConditional( Normal(50.0,4.0)) )
42+
addFactor!(fg,[:x3], Prior( pd ))
43+
44+
addVariable!(fg,:x4,ContinuousScalar, N=N)
45+
addFactor!(fg,[:x3;:x4], LinearConditional( Normal(50.0,2.0)) )
46+
47+
48+
addVariable!(fg, :l1, ContinuousScalar, N=N)
49+
addFactor!(fg, [:x3,:l1], Ranged([64.0],[0.5],[1.0]))
50+
addFactor!(fg, [:x4,:l1], Ranged([16.0],[0.5],[1.0]))
51+
52+
53+
54+
addVariable!(fg,:x5,ContinuousScalar, N=N)
55+
addFactor!(fg,[:x4;:x5], LinearConditional( Normal(50.0,2.0)) )
56+
57+
58+
addVariable!(fg,:x6,ContinuousScalar, N=N)
59+
addFactor!(fg,[:x5;:x6], LinearConditional( Normal(40.0,1.20)) )
60+
61+
62+
addVariable!(fg,:x7,ContinuousScalar, N=N)
63+
addFactor!(fg,[:x6;:x7], LinearConditional( Normal(60.0,2.0)) )
64+
65+
# ensureAllInitialized!(fg)
66+
67+
mlc = MixturePrior(Normal.(doors[1,:], bws[1]), 0.25*ones(4))
68+
69+
# getSample(mlc)
70+
71+
addFactor!(fg,[:x7], mlc )
72+
73+
74+
dfgplot(fg)
75+
76+
tree, smt, hist = solveTree!(fg)
77+
78+
79+
end
80+
81+
#

0 commit comments

Comments
 (0)