|
1 | 1 | global dfg,v1,v2,f1
|
2 | 2 |
|
3 | 3 | if typeof(dfg) <: CloudGraphsDFG
|
4 |
| - @warn "TEST: Nuking all data for robot $(dfg.robotId)!" |
| 4 | + @warn "TEST: Nuking all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!" |
5 | 5 | clearRobot!!(dfg)
|
6 | 6 | end
|
7 | 7 |
|
@@ -248,104 +248,104 @@ end
|
248 | 248 | end
|
249 | 249 |
|
250 | 250 |
|
251 |
| -# Now make a complex graph for connectivity tests |
252 |
| -numNodes = 10 |
253 |
| -#the deletions in last test should have cleared out the fg |
254 |
| -# dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg) |
255 |
| -# if typeof(dfg) <: CloudGraphsDFG |
256 |
| -# clearSession!!(dfg) |
| 251 | +# # Now make a complex graph for connectivity tests |
| 252 | +# numNodes = 10 |
| 253 | +# #the deletions in last test should have cleared out the fg |
| 254 | +# # dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg) |
| 255 | +# # if typeof(dfg) <: CloudGraphsDFG |
| 256 | +# # clearSession!!(dfg) |
| 257 | +# # end |
| 258 | +# |
| 259 | +# #change ready and backendset for x7,x8 for improved tests on x7x8f1 |
| 260 | +# verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes) |
| 261 | +# #TODO fix this to use accessors |
| 262 | +# verts[7].ready = 1 |
| 263 | +# # verts[7].backendset = 0 |
| 264 | +# verts[8].ready = 0 |
| 265 | +# verts[8].backendset = 1 |
| 266 | +# #call update to set it on cloud |
| 267 | +# updateVariable!(dfg, verts[7]) |
| 268 | +# updateVariable!(dfg, verts[8]) |
| 269 | +# |
| 270 | +# facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1)) |
| 271 | +# |
| 272 | +# @testset "Getting Neighbors" begin |
| 273 | +# global dfg,verts |
| 274 | +# # Trivial test to validate that intersect([], []) returns order of first parameter |
| 275 | +# @test intersect([:x3, :x2, :x1], [:x1, :x2]) == [:x2, :x1] |
| 276 | +# # Get neighbors tests |
| 277 | +# @test getNeighbors(dfg, verts[1]) == [:x1x2f1] |
| 278 | +# neighbors = getNeighbors(dfg, getFactor(dfg, :x1x2f1)) |
| 279 | +# @test neighbors == [:x1, :x2] |
| 280 | +# # Testing aliases |
| 281 | +# @test getNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1)) |
| 282 | +# @test getNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1) |
| 283 | +# |
| 284 | +# # ready and backendset |
| 285 | +# @test getNeighbors(dfg, :x5, ready=1) == Symbol[] |
| 286 | +# #TODO Confirm: test failed on GraphsDFG, don't know if the order is important for isa variable. |
| 287 | +# @test symdiff(getNeighbors(dfg, :x5, ready=0), [:x4x5f1,:x5x6f1]) == [] |
| 288 | +# @test getNeighbors(dfg, :x5, backendset=1) == Symbol[] |
| 289 | +# @test symdiff(getNeighbors(dfg, :x5, backendset=0),[:x4x5f1,:x5x6f1]) == [] |
| 290 | +# @test getNeighbors(dfg, :x7x8f1, ready=0) == [:x8] |
| 291 | +# @test getNeighbors(dfg, :x7x8f1, backendset=0) == [:x7] |
| 292 | +# @test getNeighbors(dfg, :x7x8f1, ready=1) == [:x7] |
| 293 | +# @test getNeighbors(dfg, :x7x8f1, backendset=1) == [:x8] |
| 294 | +# @test getNeighbors(dfg, verts[1], ready=0) == [:x1x2f1] |
| 295 | +# @test getNeighbors(dfg, verts[1], ready=1) == Symbol[] |
| 296 | +# @test getNeighbors(dfg, verts[1], backendset=0) == [:x1x2f1] |
| 297 | +# @test getNeighbors(dfg, verts[1], backendset=1) == Symbol[] |
| 298 | +# |
| 299 | +# end |
| 300 | +# |
| 301 | +# @testset "Getting Subgraphs" begin |
| 302 | +# # Subgraphs |
| 303 | +# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2) |
| 304 | +# # Only returns x1 and x2 |
| 305 | +# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
| 306 | +# # Test include orphan factorsVoid |
| 307 | +# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 1, true) |
| 308 | +# @test symdiff([:x1, :x1x2f1], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
| 309 | +# # Test adding to the dfg |
| 310 | +# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2, true, dfgSubgraph) |
| 311 | +# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
| 312 | +# # |
| 313 | +# dfgSubgraph = getSubgraph(dfg,[:x1, :x2, :x1x2f1]) |
| 314 | +# # Only returns x1 and x2 |
| 315 | +# @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
| 316 | +# |
| 317 | +# # DFG issue #95 - confirming that getSubgraphAroundNode retains order |
| 318 | +# # REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95 |
| 319 | +# for fId in getVariableIds(dfg) |
| 320 | +# # Get a subgraph of this and it's related factors+variables |
| 321 | +# dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2) |
| 322 | +# # For each factor check that the order the copied graph == original |
| 323 | +# for fact in getFactors(dfgSubgraph) |
| 324 | +# @test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols |
| 325 | +# end |
| 326 | +# end |
| 327 | +# end |
| 328 | +# |
| 329 | +# @testset "Summaries and Summary Graphs" begin |
| 330 | +# factorFields = fieldnames(DFGFactorSummary) |
| 331 | +# variableFields = fieldnames(DFGVariableSummary) |
| 332 | +# |
| 333 | +# summary = getSummary(dfg) |
| 334 | +# @test symdiff(collect(keys(summary.variables)), ls(dfg)) == Symbol[] |
| 335 | +# @test symdiff(collect(keys(summary.factors)), lsf(dfg)) == Symbol[] |
| 336 | +# |
| 337 | +# summaryGraph = getSummaryGraph(dfg) |
| 338 | +# @test symdiff(ls(summaryGraph), ls(dfg)) == Symbol[] |
| 339 | +# @test symdiff(lsf(summaryGraph), lsf(dfg)) == Symbol[] |
| 340 | +# # Check all fields are equal for all variables |
| 341 | +# for v in ls(summaryGraph) |
| 342 | +# for field in variableFields |
| 343 | +# @test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field) |
| 344 | +# end |
| 345 | +# end |
| 346 | +# for f in lsf(summaryGraph) |
| 347 | +# for field in factorFields |
| 348 | +# @test getfield(getFactor(dfg, f), field) == getfield(getFactor(summaryGraph, f), field) |
| 349 | +# end |
| 350 | +# end |
257 | 351 | # end
|
258 |
| - |
259 |
| -#change ready and backendset for x7,x8 for improved tests on x7x8f1 |
260 |
| -verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes) |
261 |
| -#TODO fix this to use accessors |
262 |
| -verts[7].ready = 1 |
263 |
| -# verts[7].backendset = 0 |
264 |
| -verts[8].ready = 0 |
265 |
| -verts[8].backendset = 1 |
266 |
| -#call update to set it on cloud |
267 |
| -updateVariable!(dfg, verts[7]) |
268 |
| -updateVariable!(dfg, verts[8]) |
269 |
| - |
270 |
| -facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1)) |
271 |
| - |
272 |
| -@testset "Getting Neighbors" begin |
273 |
| - global dfg,verts |
274 |
| - # Trivial test to validate that intersect([], []) returns order of first parameter |
275 |
| - @test intersect([:x3, :x2, :x1], [:x1, :x2]) == [:x2, :x1] |
276 |
| - # Get neighbors tests |
277 |
| - @test getNeighbors(dfg, verts[1]) == [:x1x2f1] |
278 |
| - neighbors = getNeighbors(dfg, getFactor(dfg, :x1x2f1)) |
279 |
| - @test neighbors == [:x1, :x2] |
280 |
| - # Testing aliases |
281 |
| - @test getNeighbors(dfg, getFactor(dfg, :x1x2f1)) == ls(dfg, getFactor(dfg, :x1x2f1)) |
282 |
| - @test getNeighbors(dfg, :x1x2f1) == ls(dfg, :x1x2f1) |
283 |
| - |
284 |
| - # ready and backendset |
285 |
| - @test getNeighbors(dfg, :x5, ready=1) == Symbol[] |
286 |
| - #TODO Confirm: test failed on GraphsDFG, don't know if the order is important for isa variable. |
287 |
| - @test symdiff(getNeighbors(dfg, :x5, ready=0), [:x4x5f1,:x5x6f1]) == [] |
288 |
| - @test getNeighbors(dfg, :x5, backendset=1) == Symbol[] |
289 |
| - @test symdiff(getNeighbors(dfg, :x5, backendset=0),[:x4x5f1,:x5x6f1]) == [] |
290 |
| - @test getNeighbors(dfg, :x7x8f1, ready=0) == [:x8] |
291 |
| - @test getNeighbors(dfg, :x7x8f1, backendset=0) == [:x7] |
292 |
| - @test getNeighbors(dfg, :x7x8f1, ready=1) == [:x7] |
293 |
| - @test getNeighbors(dfg, :x7x8f1, backendset=1) == [:x8] |
294 |
| - @test getNeighbors(dfg, verts[1], ready=0) == [:x1x2f1] |
295 |
| - @test getNeighbors(dfg, verts[1], ready=1) == Symbol[] |
296 |
| - @test getNeighbors(dfg, verts[1], backendset=0) == [:x1x2f1] |
297 |
| - @test getNeighbors(dfg, verts[1], backendset=1) == Symbol[] |
298 |
| - |
299 |
| -end |
300 |
| - |
301 |
| -@testset "Getting Subgraphs" begin |
302 |
| - # Subgraphs |
303 |
| - dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2) |
304 |
| - # Only returns x1 and x2 |
305 |
| - @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
306 |
| - # Test include orphan factorsVoid |
307 |
| - dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 1, true) |
308 |
| - @test symdiff([:x1, :x1x2f1], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
309 |
| - # Test adding to the dfg |
310 |
| - dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2, true, dfgSubgraph) |
311 |
| - @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
312 |
| - # |
313 |
| - dfgSubgraph = getSubgraph(dfg,[:x1, :x2, :x1x2f1]) |
314 |
| - # Only returns x1 and x2 |
315 |
| - @test symdiff([:x1, :x1x2f1, :x2], [ls(dfgSubgraph)..., lsf(dfgSubgraph)...]) == [] |
316 |
| - |
317 |
| - # DFG issue #95 - confirming that getSubgraphAroundNode retains order |
318 |
| - # REF: https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/95 |
319 |
| - for fId in getVariableIds(dfg) |
320 |
| - # Get a subgraph of this and it's related factors+variables |
321 |
| - dfgSubgraph = getSubgraphAroundNode(dfg, verts[1], 2) |
322 |
| - # For each factor check that the order the copied graph == original |
323 |
| - for fact in getFactors(dfgSubgraph) |
324 |
| - @test fact._variableOrderSymbols == getFactor(dfg, fact.label)._variableOrderSymbols |
325 |
| - end |
326 |
| - end |
327 |
| -end |
328 |
| - |
329 |
| -@testset "Summaries and Summary Graphs" begin |
330 |
| - factorFields = fieldnames(DFGFactorSummary) |
331 |
| - variableFields = fieldnames(DFGVariableSummary) |
332 |
| - |
333 |
| - summary = getSummary(dfg) |
334 |
| - @test symdiff(collect(keys(summary.variables)), ls(dfg)) == Symbol[] |
335 |
| - @test symdiff(collect(keys(summary.factors)), lsf(dfg)) == Symbol[] |
336 |
| - |
337 |
| - summaryGraph = getSummaryGraph(dfg) |
338 |
| - @test symdiff(ls(summaryGraph), ls(dfg)) == Symbol[] |
339 |
| - @test symdiff(lsf(summaryGraph), lsf(dfg)) == Symbol[] |
340 |
| - # Check all fields are equal for all variables |
341 |
| - for v in ls(summaryGraph) |
342 |
| - for field in variableFields |
343 |
| - @test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field) |
344 |
| - end |
345 |
| - end |
346 |
| - for f in lsf(summaryGraph) |
347 |
| - for field in factorFields |
348 |
| - @test getfield(getFactor(dfg, f), field) == getfield(getFactor(summaryGraph, f), field) |
349 |
| - end |
350 |
| - end |
351 |
| -end |
0 commit comments