Skip to content

Commit c85ac3b

Browse files
committed
Merge branch 'feature/4Q19/issue147' into jt/develop
2 parents 5b37484 + b0a7699 commit c85ac3b

File tree

6 files changed

+58
-14
lines changed

6 files changed

+58
-14
lines changed

src/Common.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function getfnctype(data::GenericFunctionNodeData)
129129
return data.fnc.usrfnc!
130130
end
131131
function getfnctype(fact::DFGFactor; solveKey::Symbol=:default)
132-
data = getData(fact) # TODO , solveKey=solveKey)
132+
data = solverData(fact) # TODO , solveKey=solveKey)
133133
return getfnctype(data)
134134
end
135135
function getfnctype(dfg::T, lbl::Symbol; solveKey::Symbol=:default) where T <: AbstractDFG
@@ -145,7 +145,7 @@ Notes
145145
- Replaces older `getfnctype`.
146146
"""
147147
getFactorType(data::GenericFunctionNodeData) = data.fnc.usrfnc!
148-
getFactorType(fct::DFGFactor) = getFactorType(getData(fct))
148+
getFactorType(fct::DFGFactor) = getFactorType(solverData(fct))
149149
function getFactorType(dfg::G, lbl::Symbol) where G <: AbstractDFG
150150
getFactorType(getFactor(dfg, lbl))
151151
end
@@ -190,7 +190,7 @@ function getSofttype(vnd::VariableNodeData)
190190
return vnd.softtype
191191
end
192192
function getSofttype(v::DFGVariable; solveKey::Symbol=:default)
193-
return getSofttype(getData(v, solveKey=solveKey))
193+
return getSofttype(solverData(v, solveKey))
194194
end
195195

196196
"""

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export AbstractParams, NoSolverParams
2121
export DFGNode, DFGVariable, DFGFactor
2222
export InferenceType, PackedInferenceType, FunctorInferenceType, InferenceVariable, ConvolutionObject
2323
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
24-
export label, timestamp, tags, estimates, estimate, data, solverData, getData, solverDataDict, setSolverData, internalId, smallData, bigData
24+
export label, timestamp, tags, estimates, estimate, data, softtype, solverData, getData, solverDataDict, setSolverData, internalId, smallData, bigData
2525
export DFGVariableSummary, DFGFactorSummary, AbstractDFGSummary
2626

2727
# Services/AbstractDFG Exports

src/entities/DFGVariable.jl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mutable struct VariableNodeData{T<:Any}
1010
eliminated::Bool
1111
BayesNetVertID::Symbol # Union{Nothing, }
1212
separator::Array{Symbol,1}
13-
softtype::T
13+
softtype::T # Perhaps this should move up to DFGVariable level
1414
initialized::Bool
1515
inferdim::Float64
1616
ismargin::Bool
@@ -59,9 +59,20 @@ mutable struct PackedVariableNodeData
5959
x15::Bool ) = new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15)
6060
end
6161

62+
"""
63+
$TYPEDEF
64+
65+
Data container to store Parameteric Point Estimate (PPE) from a variety of types.
66+
67+
Notes
68+
- `ppeType` is something like `:max/:mean/:modefit` etc.
69+
- `solveKey` is from super-solve concept, starting with `:default`,
70+
- `estimate` is the actual numerical estimate value,
71+
- Additional information such as how the data is represented (ie softtype) is stored alongside this data container in the `DFGVariableSummary` container.
72+
"""
6273
struct VariableEstimate
6374
solverKey::Symbol
64-
type::Symbol
75+
ppeType::Symbol
6576
estimate::Vector{Float64}
6677
lastUpdatedTimestamp::DateTime
6778
end
@@ -101,6 +112,14 @@ timestamp(v::DFGVariable) = v.timestamp
101112
tags(v::DFGVariable) = v.tags
102113
estimates(v::DFGVariable) = v.estimateDict
103114
estimate(v::DFGVariable, key::Symbol=:default) = haskey(v.estimateDict, key) ? v.estimateDict[key] : nothing
115+
116+
"""
117+
$SIGNATURES
118+
119+
Retrieve the soft type name symbol for a DFGVariable or DFGVariableSummary. ie :Point2, Pose2, etc.
120+
"""
121+
softtype(v::DFGVariable)::Symbol = Symbol(typeof(getSofttype(v)))
122+
104123
"""
105124
$SIGNATURES
106125
@@ -142,11 +161,13 @@ mutable struct DFGVariableSummary <: AbstractDFGVariable
142161
timestamp::DateTime
143162
tags::Vector{Symbol}
144163
estimateDict::Dict{Symbol, Dict{Symbol, VariableEstimate}}
164+
softtypename::Symbol
145165
_internalId::Int64
146166
end
147167
label(v::DFGVariableSummary) = v.label
148168
timestamp(v::DFGVariableSummary) = v.timestamp
149169
tags(v::DFGVariableSummary) = v.tags
150170
estimates(v::DFGVariableSummary) = v.estimateDict
151171
estimate(v::DFGVariableSummary, key::Symbol=:default) = haskey(v.estimateDict, key) ? v.estimateDict[key] : nothing
172+
softtype(v::DFGVariableSummary)::Symbol = v.softtypename
152173
internalId(v::DFGVariableSummary) = v._internalId

src/services/DFGVariable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ function ==(a::VariableNodeData,b::VariableNodeData, nt::Symbol=:var)
6666
end
6767

6868
function convert(::Type{DFGVariableSummary}, v::DFGVariable)
69-
return DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.estimateDict), v._internalId)
69+
return DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.estimateDict), Symbol(typeof(getSofttype(v))), v._internalId)
7070
end

test/LightDFGSummaryTypes.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dfg = LightDFG{NoSolverParams, DFGVariableSummary, DFGFactorSummary}()
22

3-
DistributedFactorGraphs.DFGVariableSummary(label::Symbol) = DFGVariableSummary(label, DistributedFactorGraphs.now(), Symbol[], Dict{Symbol, VariableEstimate}(), 0)
3+
DistributedFactorGraphs.DFGVariableSummary(label::Symbol) = DFGVariableSummary(label, DistributedFactorGraphs.now(), Symbol[], Dict{Symbol, VariableEstimate}(), :NA, 0)
44

55
DistributedFactorGraphs.DFGFactorSummary(label::Symbol) = DFGFactorSummary(label, Symbol[], 0, Symbol[])
66

@@ -13,6 +13,9 @@ append!(v1.tags, [:VARIABLE, :POSE])
1313
append!(v2.tags, [:VARIABLE, :LANDMARK])
1414
append!(f1.tags, [:FACTOR])
1515

16+
#Force softtypename
17+
v1.softtypename = :Pose2
18+
1619
# @testset "Creating Graphs" begin
1720
global dfg,v1,v2,f1
1821
addVariable!(dfg, v1)
@@ -95,6 +98,7 @@ end
9598
@test timestamp(v1) == v1.timestamp
9699
@test estimates(v1) == v1.estimateDict
97100
@test estimate(v1, :notfound) == nothing
101+
@test softtype(v1) == :Pose2
98102
# @test solverData(v1) === v1.solverDataDict[:default]
99103
# @test getData(v1) === v1.solverDataDict[:default]
100104
# @test solverData(v1, :default) === v1.solverDataDict[:default]
@@ -123,13 +127,13 @@ end
123127
estimates(newvar)[:default] = Dict{Symbol, VariableEstimate}(
124128
:max => VariableEstimate(:default, :max, [100.0]),
125129
:mean => VariableEstimate(:default, :mean, [50.0]),
126-
:ppe => VariableEstimate(:default, :ppe, [75.0]))
130+
:modefit => VariableEstimate(:default, :modefit, [75.0]))
127131
#update
128132
updateVariableSolverData!(dfg, newvar)
129133
#TODO maybe implement ==; @test newvar==var
130134
Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin
131135
varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false
132-
varest1.type == varest2.type || return false
136+
varest1.ppeType == varest2.ppeType || return false
133137
varest1.solverKey == varest2.solverKey || return false
134138
varest1.estimate == varest2.estimate || return false
135139
return true

test/interfaceTests.jl

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ append!(v1.tags, [:VARIABLE, :POSE])
88
append!(v2.tags, [:VARIABLE, :LANDMARK])
99
append!(f1.tags, [:FACTOR])
1010

11+
#add types for softtypes
12+
st1 = (a=1,b=2)
13+
st2 = (a=1.0,b=2.0)
14+
v1.solverDataDict[:default].softtype = deepcopy(st1)
15+
v2.solverDataDict[:default].softtype = deepcopy(st2)
16+
1117
# @testset "Creating Graphs" begin
1218
global dfg,v1,v2,f1
1319
addVariable!(dfg, v1)
@@ -96,6 +102,10 @@ end
96102
@test solverDataDict(v1) == v1.solverDataDict
97103
@test internalId(v1) == v1._internalId
98104

105+
@test softtype(v1) == Symbol(typeof(st1))
106+
@test softtype(v2) == Symbol(typeof(st2))
107+
@test getSofttype(v1) == st1
108+
99109
@test label(f1) == f1.label
100110
@test tags(f1) == f1.tags
101111
@test solverData(f1) == f1.data
@@ -169,13 +179,13 @@ end
169179
estimates(newvar)[:default] = Dict{Symbol, VariableEstimate}(
170180
:max => VariableEstimate(:default, :max, [100.0]),
171181
:mean => VariableEstimate(:default, :mean, [50.0]),
172-
:ppe => VariableEstimate(:default, :ppe, [75.0]))
182+
:modefit => VariableEstimate(:default, :modefit, [75.0]))
173183
#update
174184
updateVariableSolverData!(dfg, newvar)
175185
#TODO maybe implement ==; @test newvar==var
176186
Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin
177187
varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false
178-
varest1.type == varest2.type || return false
188+
varest1.ppeType == varest2.ppeType || return false
179189
varest1.solverKey == varest2.solverKey || return false
180190
varest1.estimate == varest2.estimate || return false
181191
return true
@@ -189,7 +199,7 @@ end
189199
estimates(newvar)[:second] = Dict{Symbol, VariableEstimate}(
190200
:max => VariableEstimate(:default, :max, [10.0]),
191201
:mean => VariableEstimate(:default, :mean, [5.0]),
192-
:ppe => VariableEstimate(:default, :ppe, [7.0]))
202+
:modefit => VariableEstimate(:default, :modefit, [7.0]))
193203

194204
# Persist to the original variable.
195205
updateVariableSolverData!(dfg, newvar)
@@ -252,6 +262,11 @@ verts = map(n -> DFGVariable(Symbol("x$n")), 1:numNodes)
252262
#change ready and backendset for x7,x8 for improved tests on x7x8f1
253263
verts[7].ready = 1
254264
verts[8].backendset = 1
265+
266+
#force softytypes to first 2 vertices.
267+
verts[1].solverDataDict[:default].softtype = deepcopy(st1)
268+
verts[2].solverDataDict[:default].softtype = deepcopy(st2)
269+
255270
map(v -> addVariable!(dfg, v), verts)
256271
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor{Int, :Symbol}(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
257272

@@ -325,7 +340,11 @@ end
325340
# Check all fields are equal for all variables
326341
for v in ls(summaryGraph)
327342
for field in variableFields
328-
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
343+
if field != :softtypename
344+
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
345+
else
346+
@test softtype(getVariable(dfg, v)) == softtype(getVariable(summaryGraph, v))
347+
end
329348
end
330349
end
331350
for f in lsf(summaryGraph)

0 commit comments

Comments
 (0)