Skip to content

Commit cafa740

Browse files
committed
Merge branch 'master' of https://github.com/JuliaRobotics/DistributedFactorGraphs.jl into 4Q19/poc/v0_6
2 parents 5cd7792 + 7af0dd7 commit cafa740

File tree

7 files changed

+66
-7
lines changed

7 files changed

+66
-7
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export DFGNodeParams
3535
export SkeletonDFGVariable, SkeletonDFGFactor
3636
export timestamp # DEPRECATED
3737
export label, getTimestamp, setTimestamp!, tags, setTags!, data, softtype, solverData, getData, solverDataDict, setSolverData, setSolverData!, internalId, smallData, setSmallData!, bigData
38+
export getSolvedCount, isSolved, setSolvedCount!
3839
export DFGVariableSummary, DFGFactorSummary, AbstractDFGSummary
3940
export getNeighborhood, getSubgraph, getSubgraphAroundNode
4041

src/entities/DFGVariable.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
include("DFGVariable/PackedVariableNodeData.jl")
32
include("DFGVariable/PointParametricEst.jl")
43
include("DFGVariable/VariableNodeData.jl")

src/entities/DFGVariable/PackedVariableNodeData.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mutable struct PackedVariableNodeData
2323
ismargin::Bool
2424
dontmargin::Bool
2525
solveInProgress::Int
26+
solvedCount::Int
2627
PackedVariableNodeData() = new()
2728
PackedVariableNodeData(x1::Vector{Float64},
2829
x2::Int,
@@ -39,5 +40,6 @@ mutable struct PackedVariableNodeData
3940
x13::Float64,
4041
x14::Bool,
4142
x15::Bool,
42-
x16::Int) = new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16)
43+
x16::Int,
44+
solvedCount::Int) = new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16, solvedCount)
4345
end

src/entities/DFGVariable/VariableNodeData.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mutable struct VariableNodeData{T<:InferenceVariable}
2121
ismargin::Bool
2222
dontmargin::Bool
2323
solveInProgress::Int
24+
solvedCount::Int
2425
VariableNodeData{T}() where {T <:InferenceVariable} =
2526
new{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], T(), false, 0.0, false, false, 0)
2627
VariableNodeData{T}(val::Array{Float64,2},
@@ -35,11 +36,12 @@ mutable struct VariableNodeData{T<:InferenceVariable}
3536
inferdim::Float64,
3637
ismargin::Bool,
3738
dontmargin::Bool,
38-
solveInProgress::Int=0) where T <: InferenceVariable =
39+
solveInProgress::Int=0,
40+
solvedCount::Int=0) where T <: InferenceVariable =
3941
new{T}(val,bw,BayesNetOutVertIDs,dimIDs,dims,
4042
eliminated,BayesNetVertID,separator,
4143
softtype::T,initialized,inferdim,ismargin,
42-
dontmargin, solveInProgress)
44+
dontmargin, solveInProgress, solvedCount)
4345
end
4446

4547
VariableNodeData(val::Array{Float64,2},
@@ -54,11 +56,12 @@ VariableNodeData(val::Array{Float64,2},
5456
inferdim::Float64,
5557
ismargin::Bool,
5658
dontmargin::Bool,
57-
solveInProgress::Int=0) where T <: InferenceVariable =
59+
solveInProgress::Int=0,
60+
solvedCount::Int=0) where T <: InferenceVariable =
5861
VariableNodeData{T}(val,bw,BayesNetOutVertIDs,dimIDs,dims,
5962
eliminated,BayesNetVertID,separator,
6063
softtype::T,initialized,inferdim,ismargin,
61-
dontmargin, solveInProgress)
64+
dontmargin, solveInProgress, solvedCount)
6265
#
6366
VariableNodeData(softtype::T) where T <: InferenceVariable =
64-
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false, 0)
67+
VariableNodeData{T}(zeros(1,1), zeros(1,1), Symbol[], Int[], 0, false, :NOTHING, Symbol[], softtype, false, 0.0, false, false, 0, 0)

src/services/DFGVariable.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,43 @@ Get the variable ordering for this factor.
381381
Should be equivalent to getNeighbors unless something was deleted in the graph.
382382
"""
383383
getVariableOrder(fct::DFGFactor)::Vector{Symbol} = fct._variableOrderSymbols
384+
385+
"""
386+
$SIGNATURES
387+
388+
Get the number of times a variable has been inferred -- i.e. `solvedCount`.
389+
390+
Related
391+
392+
isSolved, setSolvedCount!
393+
"""
394+
getSolvedCount(v::VariableNodeData) = v.solvedCount
395+
getSolvedCount(v::VariableDataLevel2, solveKey::Symbol=:default) = getSolverData(v, solveKey) |> getSolvedCount
396+
getSolvedCount(dfg::AbstractDFG, sym::Symbol, solveKey::Symbol=:default) = getSolvedCount(getVariable(dfg, sym), solveKey)
397+
398+
"""
399+
$SIGNATURES
400+
401+
Boolean on whether the variable has been solved.
402+
403+
Related
404+
405+
getSolved, setSolved!
406+
"""
407+
isSolved(v::VariableNodeData) = 0 < v.solvedCount
408+
isSolved(v::VariableDataLevel2, solveKey::Symbol=:default) = getSolverData(v, solveKey) |> isSolved
409+
isSolved(dfg::AbstractDFG, sym::Symbol, solveKey::Symbol=:default) = isSolved(getVariable(dfg, sym), solveKey)
410+
411+
412+
"""
413+
$SIGNATURES
414+
415+
Update/set the `solveCount` value.
416+
417+
Related
418+
419+
getSolved, isSolved
420+
"""
421+
setSolvedCount!(v::VariableNodeData, val::Int) = v.solvedCount = val
422+
setSolvedCount!(v::VariableDataLevel2, val::Int, solveKey::Symbol=:default) = setSolvedCount!(solverData(v, solveKey), val)
423+
setSolvedCount!(dfg::AbstractDFG, sym::Symbol, val::Int, solveKey::Symbol=:default) = setSolvedCount!(getVariable(dfg, sym), val, solveKey)

test/fileDFGTests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using DistributedFactorGraphs
2+
using IncrementalInference
3+
dfg = LightDFG{NoSolverParams}()
4+
15
@testset "FileDFG Tests" begin
26

37
if typeof(dfg) <: CloudGraphsDFG
@@ -14,6 +18,7 @@
1418
verts[7].solvable = 1
1519
verts[8].solvable = 0
1620
getSolverData(verts[8]).solveInProgress = 1
21+
setSolvedCount!(verts[1], 5)
1722
#call update to set it on cloud
1823
updateVariable!(dfg, verts[7])
1924
updateVariable!(dfg, verts[8])

test/interfaceTests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ end
255255
@test !isVariable(dfg, :doesntexist)
256256
@test !isFactor(dfg, :doesntexist)
257257

258+
# test solveCount for variable
259+
@test !isSolved(v1)
260+
@test getSolvedCount(v1) == 0
261+
setSolvedCount!(v1, 1)
262+
@test getSolvedCount(v1) == 1
263+
@test isSolved(v1)
264+
setSolvedCount!(dfg, getLabel(v1), 2)
265+
@test getSolvedCount(dfg, getLabel(v1)) == 2
266+
258267
# Session, robot, and user small data tests
259268
smallUserData = Dict{Symbol, String}(:a => "42", :b => "Hello")
260269
smallRobotData = Dict{Symbol, String}(:a => "43", :b => "Hello")

0 commit comments

Comments
 (0)