@@ -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.21"
24
+ variableType:: T = T () # tricky deprecation, also change covar to using N and not variableType
20
25
"""
21
26
Globally unique identifier.
22
27
"""
@@ -29,6 +34,8 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
29
34
Common kernel bandwith parameter used with ManifoldKernelDensity, and as legacy also stores covariance until a dedicated field is created for parametric case.
30
35
"""
31
36
bw:: Matrix{Float64} = zeros (0 ,0 )
37
+ " Parametric (Gaussian) covariance."
38
+ const 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
@@ -40,10 +47,6 @@ Base.@kwdef mutable struct VariableNodeData{T<:InferenceVariable, P}
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
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
# #==============================================================================
@@ -209,35 +212,35 @@ Complete variable structure for a DistributedFactorGraph variable.
209
212
Fields:
210
213
$(TYPEDFIELDS)
211
214
"""
212
- Base. @kwdef struct DFGVariable{T<: InferenceVariable , P} <: AbstractDFGVariable
215
+ Base. @kwdef struct DFGVariable{T<: InferenceVariable , P, N } <: AbstractDFGVariable
213
216
""" The ID for the variable"""
214
- id:: Union{UUID, Nothing}
217
+ id:: Union{UUID, Nothing} = nothing
215
218
""" Variable label, e.g. :x1.
216
219
Accessor: [`getLabel`](@ref)"""
217
220
label:: Symbol
218
221
""" Variable timestamp.
219
222
Accessors: [`getTimestamp`](@ref), [`setTimestamp`](@ref)"""
220
- timestamp:: ZonedDateTime
223
+ timestamp:: ZonedDateTime = now ( localzone ())
221
224
""" Nano second time, for more resolution on timestamp (only subsecond information)"""
222
- nstime:: Nanosecond
225
+ nstime:: Nanosecond = Nanosecond ( 0 )
223
226
""" Variable tags, e.g [:POSE, :VARIABLE, and :LANDMARK].
224
227
Accessors: [`getTags`](@ref), [`mergeTags!`](@ref), and [`removeTags!`](@ref)"""
225
- tags:: Set{Symbol}
228
+ tags:: Set{Symbol} = Set {Symbol} ()
226
229
""" Dictionary of parametric point estimates keyed by solverDataDict keys
227
230
Accessors: [`addPPE!`](@ref), [`updatePPE!`](@ref), and [`deletePPE!`](@ref)"""
228
- ppeDict:: Dict{Symbol, <: AbstractPointParametricEst}
231
+ ppeDict:: Dict{Symbol, AbstractPointParametricEst} = Dict {Symbol, AbstractPointParametricEst}()
229
232
""" Dictionary of solver data. May be a subset of all solutions if a solver key was specified in the get call.
230
233
Accessors: [`addVariableSolverData!`](@ref), [`updateVariableSolverData!`](@ref), and [`deleteVariableSolverData!`](@ref)"""
231
- solverDataDict:: Dict{Symbol, VariableNodeData{T,P}}
234
+ solverDataDict:: Dict{Symbol, VariableNodeData{T,P,N}} = Dict {Symbol, VariableNodeData{T,P,N}} ()
232
235
""" Dictionary of small data associated with this variable.
233
236
Accessors: [`getSmallData`](@ref), [`setSmallData!`](@ref)"""
234
- smallData:: Dict{Symbol, SmallDataTypes}
237
+ smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} ()
235
238
""" Dictionary of large data associated with this variable.
236
- Accessors: [`addDataEntry !`](@ref), [`getBlobEntry`](@ref), [`updateDataEntry !`](@ref), and [`deleteDataEntry !`](@ref)"""
237
- dataDict:: Dict{Symbol, BlobEntry}
239
+ Accessors: [`addBlobEntry !`](@ref), [`getBlobEntry`](@ref), [`updateBlobEntry !`](@ref), and [`deleteBlobEntry !`](@ref)"""
240
+ dataDict:: Dict{Symbol, BlobEntry} = Dict {Symbol, BlobEntry} ()
238
241
""" Solvable flag for the variable.
239
242
Accessors: [`getSolvable`](@ref), [`setSolvable!`](@ref)"""
240
- solvable:: Base.RefValue{Int}
243
+ solvable:: Base.RefValue{Int} = Ref ( 1 )
241
244
end
242
245
243
246
# #------------------------------------------------------------------------------
@@ -247,43 +250,34 @@ end
247
250
$SIGNATURES
248
251
The default DFGVariable constructor.
249
252
"""
250
- function DFGVariable (label:: Symbol , variableType:: Type{T} ;
251
- id:: Union{UUID,Nothing} = nothing ,
252
- timestamp:: ZonedDateTime = now (localzone ()),
253
- nstime:: Nanosecond = Nanosecond (0 ),
254
- tags:: Set{Symbol} = Set {Symbol} (),
255
- estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
256
- solverDataDict:: Dict{Symbol, VariableNodeData{T,P}} = Dict {Symbol, VariableNodeData{T,getPointType(T)}} (),
257
- smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
258
- dataDict:: Dict{Symbol, BlobEntry} = Dict {Symbol,BlobEntry} (),
259
- solvable:: Int = 1 ) where {T <: InferenceVariable , P}
260
- #
261
- DFGVariable {T,P} (id, label, timestamp, nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref (solvable))
262
- end
253
+ function DFGVariable (
254
+ label:: Symbol ,
255
+ T:: Type{<:InferenceVariable} ;
256
+ estimateDict= nothing ,
257
+ timestamp= now (localzone ()),
258
+ solvable:: Union{Int, Base.RefValue{Int}} = Ref (1 ),
259
+ kwargs...
260
+ )
261
+ # TODO deprecated, remove in v0.21 should have already been deprecated
262
+ if ! isnothing (estimateDict)
263
+ error (" Keyword argument `estimateDict` is deprecated use `ppeDict`" )
264
+ end
265
+ if ! isa (timestamp, ZonedDateTime)
266
+ @warn " timestamp<:DateTime is deprecated, timestamp must be a ZonedDateTime, using local zone."
267
+ timestamp = ZonedDateTime (timestamp,localzone ())
268
+ end
263
269
264
- DFGVariable (label:: Symbol ,
265
- variableType:: T ;
266
- solverDataDict:: Dict{Symbol, VariableNodeData{T,P}} = Dict {Symbol, VariableNodeData{T,getPointType(T)}} (),
267
- kw... ) where {T <: InferenceVariable , P} = DFGVariable (label, T; solverDataDict= solverDataDict, kw... )
268
- #
269
- @deprecate DFGVariable (label:: Symbol , T_:: Type{<:InferenceVariable} ,w... ; timestamp:: DateTime = now (),kw... ) DFGVariable (label, T_, w... ; timestamp= ZonedDateTime (timestamp), kw... )
270
- #
271
-
272
-
273
- function DFGVariable (label:: Symbol ,
274
- solverData:: VariableNodeData{T} ;
275
- id:: Union{UUID, Nothing} = nothing ,
276
- timestamp:: ZonedDateTime = now (localzone ()),
277
- nstime:: Nanosecond = Nanosecond (0 ),
278
- tags:: Set{Symbol} = Set {Symbol} (),
279
- estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
280
- smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
281
- dataDict:: Dict{Symbol, <: BlobEntry} = Dict {Symbol,BlobEntry} (),
282
- solvable:: Int = 1 ) where {T <: InferenceVariable }
283
- #
284
- DFGVariable {T} (id, label, timestamp, nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T, getPointType(T)}} (:default => solverData), smallData, dataDict, Ref (solvable))
270
+ solvable isa Int && (solvable = Ref (solvable))
271
+
272
+ N = getDimension (T)
273
+ P = getPointType (T)
274
+ DFGVariable {T,P,N} (;label, timestamp, solvable, kwargs... )
285
275
end
286
276
277
+ DFGVariable (label:: Symbol , variableType:: InferenceVariable ; kwargs... ) = DFGVariable (label, typeof (variableType); kwargs... )
278
+
279
+ DFGVariable (label:: Symbol , solverData:: VariableNodeData ; kwargs... ) = DFGVariable (;label, solverDataDict= Dict (:default => solverData), kwargs... )
280
+
287
281
Base. getproperty (x:: DFGVariable ,f:: Symbol ) = begin
288
282
if f == :solvable
289
283
getfield (x,f)[]
@@ -301,14 +295,6 @@ Base.setproperty!(x::DFGVariable,f::Symbol, val) = begin
301
295
end
302
296
303
297
304
- # #------------------------------------------------------------------------------
305
- # TODO : can't see the reason to overwrite copy, leaving it here for now
306
- # function Base.copy(o::DFGVariable)::DFGVariable
307
- # return DFGVariable(o.label, getVariableType(o)(), tags=copy(o.tags), estimateDict=copy(o.estimateDict),
308
- # solverDataDict=copy(o.solverDataDict), smallData=copy(o.smallData),
309
- # dataDict=copy(o.dataDict), solvable=getSolvable(o))
310
- # end
311
-
312
298
# #------------------------------------------------------------------------------
313
299
# # DFGVariableSummary lv1
314
300
# #------------------------------------------------------------------------------
0 commit comments