@@ -13,10 +13,15 @@ $(TYPEDEF)
13
13
Data container for solver-specific data.
14
14
15
15
---
16
+ T: Variable type, such as Position1, or RoME.Pose2, etc.
17
+ P: Variable point type, the type of the manifold point.
18
+ N: Manifold dimension.
16
19
Fields:
17
20
$(TYPEDFIELDS)
18
21
"""
19
- Base. @kwdef mutable struct VariableNodeData{T<: InferenceVariable , P}
22
+ Base. @kwdef mutable struct VariableNodeData{T<: InferenceVariable , P, N}
23
+ " DEPRECATED remove in DFG v0.22"
24
+ variableType:: T = T () # tricky deprecation, also change covar to using N and not variableType
20
25
"""
21
26
Globally unique identifier.
22
27
"""
@@ -26,37 +31,35 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
26
31
"""
27
32
val:: Vector{P} = Vector {P} ()
28
33
"""
29
- Common kernel bandwith parameter used with ManifoldKernelDensity, and as legacy also stores covariance until a dedicated field is created for parametric case .
34
+ Common kernel bandwith parameter used with ManifoldKernelDensity, see field `covar` for the parametric covariance .
30
35
"""
31
36
bw:: Matrix{Float64} = zeros (0 ,0 )
37
+ " Parametric (Gaussian) covariance."
38
+ covar:: Vector{SMatrix{N, N, Float64}} = SMatrix{getDimension (variableType), getDimension (variableType), Float64}[]
32
39
BayesNetOutVertIDs:: Vector{Symbol} = Symbol[]
33
40
dimIDs:: Vector{Int} = Int[] # TODO Likely deprecate
34
41
35
- dims:: Int = 0
42
+ dims:: Int = getDimension (variableType) # TODO should we deprecate in favor of N
36
43
"""
37
- Flag used by junction (Bayes) tree construction algorith to know whether this variable has yet been included in the tree construction.
44
+ Flag used by junction (Bayes) tree construction algorithm to know whether this variable has yet been included in the tree construction.
38
45
"""
39
46
eliminated:: Bool = false
40
47
BayesNetVertID:: Symbol = :NOTHING # Union{Nothing, }
41
48
separator:: Vector{Symbol} = Symbol[]
42
49
"""
43
- Variables each have a type, such as Position1, or RoME.Pose2, etc.
44
- """
45
- variableType:: T = T ()
46
- """
47
50
False if initial numerical values are not yet available or stored values are not ready for further processing yet.
48
51
"""
49
52
initialized:: Bool = false
50
53
"""
51
54
Stores the amount information (per measurement dimension) captured in each coordinate dimension.
52
55
"""
53
- infoPerCoord:: Vector{Float64} = Float64[ 0.0 ;]
56
+ infoPerCoord:: Vector{Float64} = zeros ( getDimension (variableType))
54
57
"""
55
58
Should this variable solveKey be treated as marginalized in inference computations.
56
59
"""
57
60
ismargin:: Bool = false
58
61
"""
59
- Shoudl this variable solveKey always be kept fluid and not be automatically marginalized.
62
+ Should this variable solveKey always be kept fluid and not be automatically marginalized.
60
63
"""
61
64
dontmargin:: Bool = false
62
65
"""
@@ -68,7 +71,7 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
68
71
"""
69
72
solvedCount:: Int = 0
70
73
"""
71
- solveKey identifier associated with thsi VariableNodeData object.
74
+ solveKey identifier associated with this VariableNodeData object.
72
75
"""
73
76
solveKey:: Symbol = :default
74
77
"""
81
84
82
85
# #------------------------------------------------------------------------------
83
86
# # Constructors
84
- VariableNodeData {T} (; kwargs... ) where T <: InferenceVariable = VariableNodeData {T,getPointType(T)} (; kwargs... )
85
- VariableNodeData (variableType:: InferenceVariable ; kwargs... ) = VariableNodeData {typeof(variableType)} (; kwargs... )
87
+ VariableNodeData {T} (; kwargs... ) where T <: InferenceVariable = VariableNodeData {T,getPointType(T),getDimension(T) } (; kwargs... )
88
+ VariableNodeData (variableType:: InferenceVariable ; kwargs... ) = VariableNodeData {typeof(variableType)} (;kwargs... )
86
89
87
90
88
91
# #==============================================================================
@@ -117,6 +120,7 @@ Base.@kwdef mutable struct PackedVariableNodeData
117
120
solveInProgress:: Int
118
121
solvedCount:: Int
119
122
solveKey:: Symbol
123
+ covar:: Vector{Float64}
120
124
_version:: String = string (_getDFGVersion ())
121
125
end
122
126
@@ -243,35 +247,35 @@ Complete variable structure for a DistributedFactorGraph variable.
243
247
Fields:
244
248
$(TYPEDFIELDS)
245
249
"""
246
- Base. @kwdef struct DFGVariable{T<: InferenceVariable } <: AbstractDFGVariable
250
+ Base. @kwdef struct DFGVariable{T<: InferenceVariable , P, N } <: AbstractDFGVariable
247
251
""" The ID for the variable"""
248
- id:: Union{UUID, Nothing}
252
+ id:: Union{UUID, Nothing} = nothing
249
253
""" Variable label, e.g. :x1.
250
254
Accessor: [`getLabel`](@ref)"""
251
255
label:: Symbol
252
256
""" Variable timestamp.
253
257
Accessors: [`getTimestamp`](@ref), [`setTimestamp`](@ref)"""
254
- timestamp:: ZonedDateTime
258
+ timestamp:: ZonedDateTime = now ( localzone ())
255
259
""" Nano second time, for more resolution on timestamp (only subsecond information)"""
256
- nstime:: Nanosecond
260
+ nstime:: Nanosecond = Nanosecond ( 0 )
257
261
""" Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
258
262
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
259
- tags:: Set{Symbol}
263
+ tags:: Set{Symbol} = Set {Symbol} ()
260
264
""" Dictionary of parametric point estimates keyed by solverDataDict keys
261
265
Accessors: [`addPPE!`](@ref), [`updatePPE!`](@ref), and [`deletePPE!`](@ref)"""
262
- ppeDict:: Dict{Symbol, <: AbstractPointParametricEst}
266
+ ppeDict:: Dict{Symbol, AbstractPointParametricEst} = Dict {Symbol, AbstractPointParametricEst}()
263
267
""" Dictionary of solver data. May be a subset of all solutions if a solver key was specified in the get call.
264
268
Accessors: [`addVariableSolverData!`](@ref), [`updateVariableSolverData!`](@ref), and [`deleteVariableSolverData!`](@ref)"""
265
- solverDataDict:: Dict{Symbol, <: VariableNodeData{T}}
269
+ solverDataDict:: Dict{Symbol, VariableNodeData{T,P,N}} = Dict {Symbol, VariableNodeData{T,P,N}} ()
266
270
""" Dictionary of small data associated with this variable.
267
271
Accessors: [`getSmallData`](@ref), [`setSmallData!`](@ref)"""
268
- smallData:: Dict{Symbol, SmallDataTypes}
272
+ smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} ()
269
273
""" Dictionary of large data associated with this variable.
270
274
Accessors: [`addBlobEntry!`](@ref), [`getBlobEntry`](@ref), [`updateBlobEntry!`](@ref), and [`deleteBlobEntry!`](@ref)"""
271
- dataDict:: Dict{Symbol, BlobEntry}
275
+ dataDict:: Dict{Symbol, BlobEntry} = Dict {Symbol, BlobEntry} ()
272
276
""" Solvable flag for the variable.
273
277
Accessors: [`getSolvable`](@ref), [`setSolvable!`](@ref)"""
274
- solvable:: Base.RefValue{Int}
278
+ solvable:: Base.RefValue{Int} = Ref ( 1 )
275
279
end
276
280
277
281
# #------------------------------------------------------------------------------
@@ -281,43 +285,34 @@ end
281
285
$SIGNATURES
282
286
The default DFGVariable constructor.
283
287
"""
284
- function DFGVariable (label:: Symbol , variableType:: Type{T} ;
285
- id:: Union{UUID,Nothing} = nothing ,
286
- timestamp:: ZonedDateTime = now (localzone ()),
287
- nstime:: Nanosecond = Nanosecond (0 ),
288
- tags:: Set{Symbol} = Set {Symbol} (),
289
- estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
290
- solverDataDict:: Dict{Symbol, VariableNodeData{T,P}} = Dict {Symbol, VariableNodeData{T,getPointType(T)}} (),
291
- smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
292
- dataDict:: Dict{Symbol, BlobEntry} = Dict {Symbol,BlobEntry} (),
293
- solvable:: Int = 1 ) where {T <: InferenceVariable , P}
294
- #
295
- DFGVariable {T} (id, label, timestamp, nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref (solvable))
296
- end
288
+ function DFGVariable (
289
+ label:: Symbol ,
290
+ T:: Type{<:InferenceVariable} ;
291
+ estimateDict= nothing ,
292
+ timestamp= now (localzone ()),
293
+ solvable:: Union{Int, Base.RefValue{Int}} = Ref (1 ),
294
+ kwargs...
295
+ )
296
+ # TODO deprecated, remove in v0.21 should have already been deprecated
297
+ if ! isnothing (estimateDict)
298
+ error (" Keyword argument `estimateDict` is deprecated use `ppeDict`" )
299
+ end
300
+ if ! isa (timestamp, ZonedDateTime)
301
+ @warn " timestamp<:DateTime is deprecated, timestamp must be a ZonedDateTime, using local zone."
302
+ timestamp = ZonedDateTime (timestamp,localzone ())
303
+ end
297
304
298
- DFGVariable (label:: Symbol ,
299
- variableType:: T ;
300
- solverDataDict:: Dict{Symbol, VariableNodeData{T,P}} = Dict {Symbol, VariableNodeData{T,getPointType(T)}} (),
301
- kw... ) where {T <: InferenceVariable , P} = DFGVariable (label, T; solverDataDict= solverDataDict, kw... )
302
- #
303
- # @deprecate DFGVariable(label::Symbol, T_::Type{<:InferenceVariable},w...; timestamp::DateTime=now(),kw...) DFGVariable(label, T_, w...; timestamp=ZonedDateTime(timestamp), kw...)
304
- #
305
-
306
-
307
- function DFGVariable (label:: Symbol ,
308
- solverData:: VariableNodeData{T} ;
309
- id:: Union{UUID, Nothing} = nothing ,
310
- timestamp:: ZonedDateTime = now (localzone ()),
311
- nstime:: Nanosecond = Nanosecond (0 ),
312
- tags:: Set{Symbol} = Set {Symbol} (),
313
- estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
314
- smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
315
- dataDict:: Dict{Symbol, <: BlobEntry} = Dict {Symbol,BlobEntry} (),
316
- solvable:: Int = 1 ) where {T <: InferenceVariable }
317
- #
318
- DFGVariable {T} (id, label, timestamp, nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T, getPointType(T)}} (:default => solverData), smallData, dataDict, Ref (solvable))
305
+ solvable isa Int && (solvable = Ref (solvable))
306
+
307
+ N = getDimension (T)
308
+ P = getPointType (T)
309
+ DFGVariable {T,P,N} (;label, timestamp, solvable, kwargs... )
319
310
end
320
311
312
+ DFGVariable (label:: Symbol , variableType:: InferenceVariable ; kwargs... ) = DFGVariable (label, typeof (variableType); kwargs... )
313
+
314
+ DFGVariable (label:: Symbol , solverData:: VariableNodeData ; kwargs... ) = DFGVariable (;label, solverDataDict= Dict (:default => solverData), kwargs... )
315
+
321
316
Base. getproperty (x:: DFGVariable ,f:: Symbol ) = begin
322
317
if f == :solvable
323
318
getfield (x,f)[]
@@ -335,14 +330,6 @@ Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
335
330
end
336
331
337
332
338
- # #------------------------------------------------------------------------------
339
- # TODO : can't see the reason to overwrite copy, leaving it here for now
340
- # function Base.copy(o::DFGVariable)::DFGVariable
341
- # return DFGVariable(o.label, getVariableType(o)(), tags=copy(o.tags), estimateDict=copy(o.estimateDict),
342
- # solverDataDict=copy(o.solverDataDict), smallData=copy(o.smallData),
343
- # dataDict=copy(o.dataDict), solvable=getSolvable(o))
344
- # end
345
-
346
333
# #------------------------------------------------------------------------------
347
334
# # DFGVariableSummary lv1
348
335
# #------------------------------------------------------------------------------
0 commit comments