Skip to content

Commit 8f5013c

Browse files
committed
Expanding the test
1 parent f25ad52 commit 8f5013c

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

test/CGStructureTests.jl

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ using DistributedFactorGraphs
22
using IncrementalInference
33
using Test
44

5-
blank() = return nothing
65
dfg = CloudGraphsDFG{NoSolverParams}("localhost", 7474, "neo4j", "test",
76
"Bob", "testRobot", "testSession",
87
nothing,
98
nothing,
10-
blank,
11-
blank,
9+
IncrementalInference.decodePackedType,
10+
IncrementalInference.rebuildFactorMetadata!,
1211
solverParams=NoSolverParams())
12+
1313
# Nuke the user
1414
clearUser!!(dfg)
15+
@test listSessions(dfg) == []
1516

1617
# User, robot, and session
18+
# TODO: Make easier ways to initialize these.
19+
# NOTE: Wouldn't try the data parameter yet, maybe just leave blank..
1720
user = User(:Bob, "Bob Zack", "Description", Dict{String, String}())
1821
robot = Robot(:testRobot, user.id, "Test robot", "Description", Dict{String, String}())
1922
session = Session(:testSession, robot.id, user.id, "Test Session", "Description", Dict{String, String}())
@@ -30,6 +33,34 @@ v1 = addVariable!(dfg, :a, ContinuousScalar, labels = [:POSE])
3033
v2 = addVariable!(dfg, :b, ContinuousScalar, labels = [:POSE])
3134
v3 = addVariable!(dfg, :c, ContinuousScalar, labels = [:LANDMARK])
3235
f1 = addFactor!(dfg, [:a; :b], LinearConditional(Normal(50.0,2.0)) )
33-
f1 = addFactor!(dfg, [:a; :b; :c], LinearConditional(Normal(50.0,2.0)) )
36+
f2 = addFactor!(dfg, [:b; :c], LinearConditional(Normal(50.0,2.0)) )
37+
38+
sessions = listSessions(dfg)
39+
@test map(s -> s.id, sessions) == [session.id]
40+
41+
# Pull and solve this graph
42+
dfgLocal = GraphsDFG{SolverParams}(params=SolverParams())
43+
DistributedFactorGraphs.getSubgraph(dfg, union(ls(dfg), lsf(dfg)), true, dfgLocal)
44+
45+
# Confirm that with sentinels we still have the same graph (doesn't pull in the sentinels)
46+
@test symdiff(ls(dfgLocal), ls(dfg)) == []
47+
@test symdiff(lsf(dfgLocal), lsf(dfg)) == []
3448

35-
listSessions(dfg)
49+
# Solve it
50+
tree, smtasks = solveTree!(dfgLocal)
51+
52+
53+
# Make sure we can copy and solve normal orphaned sessions.
54+
dfgOrphaned = deepcopy(dfg)
55+
dfgOrphaned.sessionId = "doesntexist"
56+
# Don't create a session
57+
# Add some nodes.
58+
v1 = addVariable!(dfgOrphaned, :a, ContinuousScalar, labels = [:POSE])
59+
v2 = addVariable!(dfgOrphaned, :b, ContinuousScalar, labels = [:POSE])
60+
v3 = addVariable!(dfgOrphaned, :c, ContinuousScalar, labels = [:LANDMARK])
61+
f1 = addFactor!(dfgOrphaned, [:a; :b], LinearConditional(Normal(50.0,2.0)) )
62+
f2 = addFactor!(dfgOrphaned, [:b; :c], LinearConditional(Normal(50.0,2.0)) )
63+
# Solve it
64+
dfgLocal = GraphsDFG{SolverParams}(params=SolverParams())
65+
DistributedFactorGraphs.getSubgraph(dfgOrphaned, union(ls(dfgOrphaned), lsf(dfgOrphaned)), true, dfgLocal)
66+
tree, smtasks = solveTree!(dfgLocal)

0 commit comments

Comments
 (0)