8
8
global dfg,v1,v2,f1
9
9
10
10
if typeof (dfg) <: CloudGraphsDFG
11
- @warn " TEST: Nuking all data for robot $(dfg. robotId) !"
11
+ @warn " TEST: Nuking all data for user ' $(dfg . userId) ', robot ' $(dfg. robotId) ' !"
12
12
clearRobot!! (dfg)
13
13
end
14
14
52
52
dfg2 = T ()
53
53
end
54
54
55
+ # Build a new in-memory IIF graph to transfer into the new graph.
55
56
iiffg = initfg ()
56
57
v1 = deepcopy (addVariable! (iiffg, :a , ContinuousScalar))
57
58
v2 = deepcopy (addVariable! (iiffg, :b , ContinuousScalar))
58
59
v3 = deepcopy (addVariable! (iiffg, :c , ContinuousScalar))
59
60
f1 = deepcopy (addFactor! (iiffg, [:a ; :b ], LinearConditional (Normal (50.0 ,2.0 )) ))
60
61
f2 = deepcopy (addFactor! (iiffg, [:b ; :c ], LinearConditional (Normal (10.0 ,1.0 )) ))
61
62
62
- # @testset "Creating Graphs" begin
63
+ # Add it to the new graph.
63
64
@test addVariable! (dfg2, v1)
64
65
@test addVariable! (dfg2, v2)
65
66
@test_throws ErrorException updateVariable! (dfg2, v3)
123
124
# Gets
124
125
@testset " Gets, Sets, and Accessors" begin
125
126
global dfg,v1,v2,f1
126
- # TODO write compare for variable and factor it looks to be the same
127
127
@test getVariable (dfg, v1. label) == v1
128
128
@test getFactor (dfg, f1. label) == f1
129
129
@test_throws Exception getVariable (dfg, :nope )
134
134
# Sets
135
135
v1Prime = deepcopy (v1)
136
136
@test updateVariable! (dfg, v1Prime) != v1
137
+ @test updateVariable! (dfg, v1Prime) == getVariable (dfg, v1. label)
137
138
f1Prime = deepcopy (f1)
138
139
@test updateFactor! (dfg, f1Prime) != f1
140
+ # @test updateFactor!(dfg, f1Prime) == getFactor(dfg, f1.label)
139
141
140
142
# Accessors
141
143
@test label (v1) == v1. label
228
230
@test getBigDataKeys (v1) == Symbol[]
229
231
end
230
232
231
- @testset " Updating Nodes" begin
233
+ @testset " Updating Nodes and Estimates " begin
232
234
global dfg
233
235
# get the variable
234
236
var = getVariable (dfg, :a )
@@ -240,40 +242,43 @@ end
240
242
:modefit => VariableEstimate (:default , :modefit , [75.0 ]))
241
243
# update
242
244
updateVariableSolverData! (dfg, newvar)
243
- # TODO maybe implement ==; @test newvar==var
244
- Base.:(== )(varest1:: VariableEstimate , varest2:: VariableEstimate ) = begin
245
- varest1. lastUpdatedTimestamp == varest2. lastUpdatedTimestamp || return false
246
- varest1. ppeType == varest2. ppeType || return false
247
- varest1. solverKey == varest2. solverKey || return false
248
- varest1. estimate == varest2. estimate || return false
249
- return true
250
- end
245
+
251
246
# For now spot check
252
247
@test_skip solverDataDict (newvar) == solverDataDict (var)
248
+ var = getVariable (dfg, :a )
253
249
@test estimates (newvar) == estimates (var)
254
250
255
- # Delete :default and replace to see if new ones can be added
256
- delete! (estimates (newvar), :default )
251
+ # Add a new estimate.
257
252
estimates (newvar)[:second ] = Dict {Symbol, VariableEstimate} (
258
253
:max => VariableEstimate (:default , :max , [10.0 ]),
259
254
:mean => VariableEstimate (:default , :mean , [5.0 ]),
260
255
:modefit => VariableEstimate (:default , :modefit , [7.0 ]))
261
256
262
- # Persist to the original variable.
257
+ # Confirm they're different
258
+ @test estimates (newvar) != estimates (var)
259
+ # Persist it.
263
260
updateVariableSolverData! (dfg, newvar)
261
+ # Get the latest
262
+ var = getVariable (dfg, :a )
264
263
# At this point newvar will have only :second, and var should have both (it is the reference)
265
264
@test symdiff (collect (keys (estimates (var))), [:default , :second ]) == Symbol[]
265
+ # Delete :default and replace to see if new ones can be added
266
+ delete! (estimates (newvar), :default )
266
267
@test symdiff (collect (keys (estimates (newvar))), [:second ]) == Symbol[]
267
- # Get the source too.
268
- @test symdiff (collect (keys (estimates (getVariable (dfg, :a )))), [:default , :second ]) == Symbol[]
268
+ # Persist it.
269
+ updateVariableSolverData! (dfg, newvar)
270
+ # Get the latest and confirm they're the same, :second
271
+ var = getVariable (dfg, :a )
272
+ @test estimates (newvar) == estimates (var)
273
+ @test collect (keys (estimates (var))) == [:second ]
269
274
end
270
275
271
276
# Connectivity test
272
277
@testset " Connectivity Test" begin
273
278
global dfg,v1,v2,f1
274
279
@test isFullyConnected (dfg) == true
275
280
@test hasOrphans (dfg) == false
276
- addVariable! (dfg, DFGVariable ( :orphan ) )
281
+ addVariable! (dfg, :orphan , ContinuousScalar, labels = [ :POSE ] )
277
282
@test isFullyConnected (dfg) == false
278
283
@test hasOrphans (dfg) == true
279
284
end
0 commit comments