Skip to content

Commit 4bce517

Browse files
committed
Merge branch '4Q19/poc/v0_6' of https://github.com/JuliaRobotics/DistributedFactorGraphs.jl into 4Q19/poc/v0_6
2 parents f3485f9 + 7fcebaf commit 4bce517

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

src/Common.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,30 @@ function addTags!(dfg::InMemoryDFGTypes, sym::Symbol, tags::Vector{Symbol})
410410
union!(getTags(getFactor(fg, sym)), tags)
411411
end
412412

413+
414+
"""
415+
$SIGNATURES
416+
417+
Add tag to a variable or factor
418+
"""
419+
addTag!(f::DataLevel0, tag::Symbol) = union!(f.tags,[tag])
420+
421+
422+
"""
423+
$SIGNATURES
424+
425+
Merge tags to the node's tags (variable/factor).
426+
"""
427+
mergeTags!(f::DataLevel0, tags::Vector{Symbol}) = union!(f.tags, tags)
428+
429+
"""
430+
$SIGNATURES
431+
432+
Remove the tags from the node
433+
"""
434+
deleteTags!(f::DataLevel0, tags::Vector{Symbol}) = setdiff!(f.tags, tags)
435+
436+
413437
"""
414438
$SIGNATURES
415439

src/CommonAccessors.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ getTags(v::DataLevel0) = v.tags
2020
"""
2121
$SIGNATURES
2222
23-
Set the tags for a factor.
23+
Set the tags for a node.
2424
"""
2525
function setTags!(f::DataLevel0, tags::Vector{Symbol})
26-
resize!(f.tags, length(tags))
27-
f.tags .= tags
26+
empty!(f.tags)
27+
union!(f.tags, tags)
2828
end
2929

3030
"""

src/entities/DFGFactor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ Construct a DFG factor given a label.
7070
"""
7171
#TODO _internalId?
7272
DFGFactor{T, S}(label::Symbol, internalId::Int64=0, timestamp::DateTime=now()) where {T, S} =
73-
DFGFactor(label, timestamp, Symbol[], GenericFunctionNodeData{T, S}(), 0, DFGNodeParams(0, internalId), Symbol[])
73+
DFGFactor(label, timestamp, Set{Symbol}(), GenericFunctionNodeData{T, S}(), 0, DFGNodeParams(0, internalId), Symbol[])
7474

7575
DFGFactor(label::Symbol;
7676
timestamp::DateTime=now(),
77-
tags::Vector{Symbol}=Symbol[],
77+
tags::Set{Symbol}=Set{Symbol}(),
7878
data::GenericFunctionNodeData{T, S}=GenericFunctionNodeData{T, S}(),
7979
solvable::Int=0,
8080
_internalId::Int64=0,

src/entities/DFGVariable.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct DFGVariable{T<:InferenceVariable} <: AbstractDFGVariable
2020
timestamp::DateTime
2121
"""Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
2222
Accessors: `getTags`, `addTags!`, and `deleteTags!`"""
23-
tags::Vector{Symbol}
23+
tags::Set{Symbol}
2424
"""Dictionary of estimates keyed by solverDataDict keys
2525
Accessors: `addEstimate!`, `updateEstimate!`, and `deleteEstimate!`"""
2626
ppeDict::Dict{Symbol, <: AbstractPointParametricEst}
@@ -43,7 +43,7 @@ end
4343
The default DFGVariable constructor.
4444
"""
4545
DFGVariable(label::Symbol, softtype::T;
46-
tags::Vector{Symbol}=Symbol[],
46+
tags::Set{Symbol}=Set{Symbol}(),
4747
estimateDict::Dict{Symbol, <: AbstractPointParametricEst}=Dict{Symbol, MeanMaxPPE}(),
4848
solverDataDict::Dict{Symbol, VariableNodeData{T}}=Dict{Symbol, VariableNodeData{T}}(:default => VariableNodeData{T}()),
4949
smallData::Dict{String, String}=Dict{String, String}(),

test/interfaceTests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ v2 = DFGVariable(:b, TestInferenceVariable2())
1212
f1 = DFGFactor{Int, :Symbol}(:f1)
1313

1414
#add tags for filters
15-
append!(v1.tags, [:VARIABLE, :POSE])
16-
append!(v2.tags, [:VARIABLE, :LANDMARK])
17-
append!(f1.tags, [:FACTOR])
15+
union!(v1.tags, [:VARIABLE, :POSE])
16+
union!(v2.tags, [:VARIABLE, :LANDMARK])
17+
union!(f1.tags, [:FACTOR])
1818

1919
st1 = TestInferenceVariable1()
2020
st2 = TestInferenceVariable2()
@@ -142,8 +142,8 @@ end
142142
@test getLabel(v1) == v1.label
143143
@test getTags(v1) == v1.tags
144144
testTags = [:ha, :ha23]
145-
@test setTags!(v1, testTags) == testTags
146-
@test getTags(v1) == testTags
145+
@test setTags!(v1, testTags) == Set(testTags)
146+
@test getTags(v1) == Set(testTags)
147147

148148
@test getTimestamp(v1) == v1.timestamp
149149
testTimestamp = now()

0 commit comments

Comments
 (0)