Skip to content

Commit 3e91117

Browse files
committed
Explore Packed[Variable/Factor] as a DFGType
1 parent 73c7f8a commit 3e91117

File tree

6 files changed

+57
-6
lines changed

6 files changed

+57
-6
lines changed

src/DataBlobs/services/HelpersDataWrapEntryBlob.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ addData!(
156156
kwargs...
157157
)
158158

159+
#FIXME id used wrong
159160
function addData!(
160161
dfg::AbstractDFG,
161162
blobstore::AbstractBlobStore,

src/entities/DFGFactor.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ FunctionNodeData(args...; kw...) = FunctionNodeData{typeof(args[4])}(args...; kw
8383
# | DFGFactor | X | X | X | X | X |
8484

8585
# Packed Factor
86-
Base.@kwdef struct PackedFactor
86+
Base.@kwdef struct PackedFactor <: AbstractDFGFactor
8787
id::Union{UUID, Nothing} = nothing
8888
label::Symbol
8989
tags::Vector{Symbol}
@@ -280,8 +280,8 @@ StructTypes.omitempties(::Type{SkeletonDFGFactor}) = (:id,)
280280
##==============================================================================
281281
## Define factor levels
282282
##==============================================================================
283-
const FactorDataLevel0 = Union{DFGFactor, DFGFactorSummary, SkeletonDFGFactor}
284-
const FactorDataLevel1 = Union{DFGFactor, DFGFactorSummary}
283+
const FactorDataLevel0 = Union{DFGFactor, DFGFactorSummary, PackedFactor, SkeletonDFGFactor}
284+
const FactorDataLevel1 = Union{DFGFactor, DFGFactorSummary, PackedFactor}
285285
const FactorDataLevel2 = Union{DFGFactor}
286286

287287
##==============================================================================

src/entities/DFGVariable.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ getEstimateFields(::MeanMaxPPE) = [:suggested, :max, :mean]
178178
##==============================================================================
179179

180180
# Packed Variable
181-
Base.@kwdef struct PackedVariable
181+
Base.@kwdef struct PackedVariable <: AbstractDFGVariable
182182
id::Union{UUID, Nothing} = nothing
183183
label::Symbol
184184
tags::Vector{Symbol} = Symbol[]
@@ -397,8 +397,8 @@ StructTypes.omitempties(::Type{SkeletonDFGVariable}) = (:id,)
397397
##==============================================================================
398398
# Define variable levels
399399
##==============================================================================
400-
const VariableDataLevel0 = Union{DFGVariable, DFGVariableSummary, SkeletonDFGVariable}
401-
const VariableDataLevel1 = Union{DFGVariable, DFGVariableSummary}
400+
const VariableDataLevel0 = Union{DFGVariable, DFGVariableSummary, PackedVariable, SkeletonDFGVariable}
401+
const VariableDataLevel1 = Union{DFGVariable, DFGVariableSummary, PackedVariable}
402402
const VariableDataLevel2 = Union{DFGVariable}
403403

404404
##==============================================================================

src/services/DFGFactor.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ setTimestamp(f::DFGFactor, ts::ZonedDateTime) = DFGFactor(f.label, ts, f.nstime,
8686
setTimestamp(f::DFGFactorSummary, ts::ZonedDateTime) = DFGFactorSummary(f.id, f.label, f.tags, f._variableOrderSymbols, ts)
8787
setTimestamp(f::DFGFactorSummary, ts::DateTime) = DFGFactorSummary(f, ZonedDateTime(ts, localzone()))
8888

89+
function setTimestamp(v::PackedFactor, timestamp::ZonedDateTime)
90+
return PackedFactor(;(key => getproperty(v, key) for key in fieldnames(PackedFactor))..., timestamp)
91+
end
8992

9093
##------------------------------------------------------------------------------
9194
## solvable

src/services/DFGVariable.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ function setTimestamp(v::DFGVariableSummary, ts::ZonedDateTime; verbose::Bool=tr
344344
return DFGVariableSummary(v.id, v.label, ts, v.tags, v.ppeDict, v.variableTypeName, v.dataDict)
345345
end
346346

347+
function setTimestamp(v::PackedVariable, timestamp::ZonedDateTime; verbose::Bool=true)
348+
return PackedVariable(;(key => getproperty(v, key) for key in fieldnames(PackedVariable))..., timestamp)
349+
end
347350

348351
##------------------------------------------------------------------------------
349352
## solvable

test/GraphsDFGSummaryTypes.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,50 @@ union!(v1.tags, [:VARIABLE, :POSE])
2424
union!(v2.tags, [:VARIABLE, :LANDMARK])
2525
union!(f1.tags, [:FACTOR])
2626

27+
if false
28+
#TODO add to tests
29+
VARTYPE = PackedVariable
30+
FACTYPE = PackedFactor
31+
dfg = GraphsDFG{NoSolverParams, PackedVariable, PackedFactor}()
32+
v1 = PackedVariable(;label=:a, variableType="Pose2", tags=[:VARIABLE, :POSE])
33+
v2 = PackedVariable(;label=:b, variableType="Pose2", tags=[:VARIABLE, :LANDMARK])
34+
v3 = PackedVariable(;label=:c, variableType="Pose2")
35+
orphan = PackedVariable(;label=:orphan, variableType="Pose2")
36+
f0 = PackedFactor(;
37+
label=:af1,
38+
tags = [:FACTOR],
39+
_variableOrderSymbols=[:a],
40+
timestamp=DFG.Dates.now(DFG.tz"Z"),
41+
nstime=0,
42+
fnctype="PriorPose2",
43+
solvable=1,
44+
data = "",
45+
metadata = "",
46+
)
47+
f1 = PackedFactor(;
48+
label=:abf1,
49+
tags = [:FACTOR],
50+
_variableOrderSymbols=[:a, :b],
51+
timestamp=DFG.Dates.now(DFG.tz"Z"),
52+
nstime=0,
53+
fnctype="Pose2Pose2",
54+
solvable=1,
55+
data = "",
56+
metadata = "",
57+
)
58+
f2 = PackedFactor(;
59+
label=:bcf1,
60+
tags = [:FACTOR],
61+
_variableOrderSymbols=[:b, :c],
62+
timestamp=DFG.Dates.now(DFG.tz"Z"),
63+
nstime=0,
64+
fnctype="Pose2Pose2",
65+
solvable=1,
66+
data = "",
67+
metadata = "",
68+
)
69+
end
70+
2771

2872
@testset "Variables and Factors CRUD and SET" begin
2973
VariablesandFactorsCRUD_SET!(dfg,v1,v2,v3,f0,f1,f2)

0 commit comments

Comments
 (0)