Skip to content

Commit 439796a

Browse files
authored
Move some deprecated code and update some deprecated DFG functions: (#1881)
* Move some deprecated code and update some deprecated DFG functions: AbstractRelative, AbstractFactor, AbstractPrior, VariableNodeData, AbstractPackedFactor, VariableNodeData, @defVariable,
1 parent 05dd76a commit 439796a

52 files changed

Lines changed: 287 additions & 277 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

IncrementalInference/ext/IncrInfrDiffEqFactorExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function _solveFactorODE!(
158158
return sol
159159
end
160160

161-
# # # output for AbstractRelative is tangents (but currently we working in coordinates for integration with DiffEqs)
161+
# # # output for AbstractRelativeObservation is tangents (but currently we working in coordinates for integration with DiffEqs)
162162
# # # FIXME, how to consolidate DERelative with parametric solve which currently only goes through getMeasurementParametric
163163
# function getSample(cf::CalcFactor{<:DERelative})
164164
# #

IncrementalInference/ext/IncrInfrFluxFactorsExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Related
138138
Mixture, FluxModelsDistribution
139139
"""
140140
function MixtureFluxModels(
141-
F_::AbstractFactor,
141+
F_::AbstractObservation,
142142
nnModels::Vector{P},
143143
inDim::NTuple{ID, Int},
144144
data::D,
@@ -174,7 +174,7 @@ function MixtureFluxModels(
174174
return Mixture(F_, ntup, diversity)
175175
end
176176

177-
function MixtureFluxModels(::Type{F}, w...; kw...) where {F <: AbstractFactor}
177+
function MixtureFluxModels(::Type{F}, w...; kw...) where {F <: AbstractObservation}
178178
return MixtureFluxModels(F(LinearAlgebra.I), w...; kw...)
179179
end
180180

IncrementalInference/ext/IncrInfrInteractiveUtilsExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module IncrInfrInteractiveUtilsExt
44

55
using InteractiveUtils
66
using DocStringExtensions
7-
using IncrementalInference: StateType, AbstractPrior, RelativeObservation
7+
using IncrementalInference: StateType, AbstractPriorObservation, RelativeObservation
88
# using IncrementalInference: getCurrentWorkspaceFactors, getCurrentWorkspaceVariables, listTypeTree
99
import IncrementalInference: getCurrentWorkspaceFactors, getCurrentWorkspaceVariables, listTypeTree
1010

@@ -18,7 +18,7 @@ Return all factors currently registered in the workspace.
1818
"""
1919
function getCurrentWorkspaceFactors()
2020
return [
21-
InteractiveUtils.subtypes(AbstractPrior)...,
21+
InteractiveUtils.subtypes(AbstractPriorObservation)...,
2222
InteractiveUtils.subtypes(RelativeObservation)...,
2323
]
2424
end

IncrementalInference/src/Deprecated.jl

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,107 @@ function addBayesNetVerts!(dfg::AbstractDFG, elimOrder::Array{Symbol, 1})
5050
end
5151
end
5252

53+
## packing converters-----------------------------------------------------------
54+
# heavy use of multiple dispatch for converting between packed and original data types during DB usage
55+
56+
function convert(
57+
::Type{DFG.PackedFunctionNodeData{P}},
58+
d::DFG.FunctionNodeData{T},
59+
) where {P <: AbstractPackedObservation, T <: FactorCache}
60+
error("TODO remove. PackedFunctionNodeData is obsolete")
61+
return DFG.PackedFunctionNodeData(
62+
d.eliminated,
63+
d.potentialused,
64+
d.edgeIDs,
65+
convert(P, _getCCW(d).usrfnc!),
66+
d.multihypo,
67+
_getCCW(d).hyporecipe.certainhypo,
68+
d.nullhypo,
69+
d.solveInProgress,
70+
d.inflation,
71+
) # extract two values from ccw for storage -- ccw thrown away
72+
end
73+
74+
## unpack converters------------------------------------------------------------
75+
# see #1424
76+
#TODO Consolidate: this looks alot like `getDefaultFactorData`
77+
function DFG.reconstFactorData(
78+
dfg::AbstractDFG,
79+
varOrder::AbstractVector{Symbol},
80+
::Type{<:DFG.GenericFunctionNodeData{<:CommonConvWrapper{F}}},
81+
packed::DFG.GenericFunctionNodeData{<:AbstractPackedObservation},
82+
) where {F <: AbstractObservation}
83+
84+
error("TODO remove. Obsolete: use `DFG.rebuildFactorCache!` and getDefaultFactorData instead.")
85+
#
86+
# TODO store threadmodel=MutliThreaded,SingleThreaded in persistence layer
87+
usrfnc = convert(F, packed.fnc)
88+
multihypo, nullhypo = parseusermultihypo(packed.multihypo, packed.nullhypo)
89+
90+
# IIF #1424
91+
vars = map(f -> getVariable(dfg, f), varOrder)
92+
userCache = preambleCache(dfg, vars, usrfnc)
93+
94+
# TODO -- improve _createCCW for hypotheses and certainhypo field recovery when deserializing
95+
# reconstitute from stored data
96+
# FIXME, add threadmodel=threadmodel
97+
# FIXME https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/590#issuecomment-776838053
98+
# FIXME dont know what manifolds to use in ccw
99+
ccw = _createCCW(
100+
vars,
101+
usrfnc;
102+
multihypo,
103+
nullhypo,
104+
certainhypo = packed.certainhypo,
105+
inflation = packed.inflation,
106+
userCache,
107+
attemptGradients = getSolverParams(dfg).attemptGradients,
108+
# Block recursion if NoSolverParams or if set to not attempt gradients.
109+
_blockRecursion=
110+
getSolverParams(dfg) isa NoSolverParams ||
111+
!getSolverParams(dfg).attemptGradients,
112+
)
113+
#
114+
115+
# CommonConvWrapper{typeof(usrfnc)}
116+
ret = DFG.FunctionNodeData{typeof(ccw)}(
117+
packed.eliminated,
118+
packed.potentialused,
119+
packed.edgeIDs,
120+
ccw,
121+
packed.multihypo,
122+
packed.certainhypo,
123+
packed.nullhypo,
124+
packed.solveInProgress,
125+
packed.inflation,
126+
)
127+
#
128+
return ret
129+
end
130+
131+
function _getDimensionsPartial(data::DFG.GenericFunctionNodeData)
132+
Base.depwarn(
133+
"_getDimensionsPartial(data::GenericFunctionNodeData) is deprecated, use solvercache <: FactorCache instead",
134+
:_getDimensionsPartial,
135+
)
136+
return _getCCW(data) |> _getDimensionsPartial
137+
end
138+
139+
"""
140+
$SIGNATURES
141+
Get the CommonConvWrapper for this factor.
142+
"""
143+
function _getCCW(gfnd::DFG.GenericFunctionNodeData)
144+
error("_getCCW(gfnd::DFG.GenericFunctionNodeData) is deprecated, use DFG.getCache instead.")
145+
end
146+
147+
_getZDim(fcd::DFG.GenericFunctionNodeData) = _getCCW(fcd) |> _getZDim
148+
DFG.getDimension(fct::DFG.GenericFunctionNodeData) = _getZDim(fct)
149+
150+
function resetData!(vdata::DFG.FunctionNodeData)
151+
error("resetData!(vdata::FunctionNodeData) is deprecated, use resetData!(state::FactorState) instead")
152+
end
153+
53154
## ================================================================================================
54155
## ================================================================================================
55156

IncrementalInference/src/ExportAPI.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export AbstractDFG,
3636
# listDataBlobs # ERROR: LightDFG{} doesn't override 'listDataBlobs'.
3737

3838
# Inference types
39-
export AbstractPackedFactor, AbstractFactor
40-
export AbstractPrior, AbstractRelative
39+
export AbstractPackedObservation, AbstractObservation
40+
export AbstractPriorObservation, AbstractRelativeObservation
4141
export AbstractRelativeMinimize, AbstractManifoldMinimize
4242

4343
# not sure if this is necessary
@@ -116,8 +116,6 @@ export CSMHistory,
116116
getTags,
117117

118118
# using either dictionary or cloudgraphs
119-
FunctionNodeData,
120-
PackedFunctionNodeData, # moved to DFG
121119
normalfromstring,
122120
categoricalfromstring,
123121
# extractdistribution,

IncrementalInference/src/Factors/EuclidDistance.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ getDimension(::InstanceType{<:EuclidDistance}) = 1
2828
$(TYPEDEF)
2929
Serialization type for `EuclidDistance` binary factor.
3030
"""
31-
Base.@kwdef mutable struct PackedEuclidDistance <: AbstractPackedFactor
31+
Base.@kwdef mutable struct PackedEuclidDistance <: AbstractPackedObservation
3232
_type::String
3333
Z::PackedBelief
3434
end

IncrementalInference/src/Factors/GenericFunctions.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export ManifoldPrior, PackedManifoldPrior
153153
# `p` is a point on manifold `M`
154154
# `Z` is a measurement at the tangent space of `p` on manifold `M`
155155
struct ManifoldPrior{M <: AbstractManifold, T <: SamplableBelief, P, B <: AbstractBasis} <:
156-
AbstractPrior
156+
AbstractPriorObservation
157157
M::M
158158
p::P #NOTE This is a fixed point from where the measurement `Z` is made in coordinates on tangent TpM
159159
Z::T
@@ -226,14 +226,14 @@ function mahalanobus_distance2(M, X, inv_Σ)
226226
return Xc' * inv_Σ * Xc
227227
end
228228

229-
Base.@kwdef mutable struct PackedManifoldPrior <: AbstractPackedFactor
229+
Base.@kwdef mutable struct PackedManifoldPrior <: AbstractPackedObservation
230230
varType::String
231231
p::Vector{Float64} #NOTE This is a fixed point from where the measurement `Z` likely stored as a coordinate
232232
Z::PackedBelief
233233
end
234234

235235
function convert(
236-
::Union{Type{<:AbstractPackedFactor}, Type{<:PackedManifoldPrior}},
236+
::Union{Type{<:AbstractPackedObservation}, Type{<:PackedManifoldPrior}},
237237
obj::ManifoldPrior,
238238
)
239239
#
@@ -249,7 +249,7 @@ function convert(
249249
end
250250

251251
function convert(
252-
::Union{Type{<:AbstractFactor}, Type{<:ManifoldPrior}},
252+
::Union{Type{<:AbstractObservation}, Type{<:ManifoldPrior}},
253253
obj::PackedManifoldPrior,
254254
)
255255
#
@@ -286,7 +286,7 @@ function samplePointPartial(
286286
end
287287

288288
struct ManifoldPriorPartial{M <: AbstractManifold, T <: SamplableBelief, P <: Tuple} <:
289-
AbstractPrior
289+
AbstractPriorObservation
290290
M::M
291291
Z::T
292292
partial::P

IncrementalInference/src/Factors/GenericMarginal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ getManifold(::GenericMarginal) = LieGroups.TranslationGroup(1)
1515

1616
getSample(::CalcFactor{<:GenericMarginal}) = [0]
1717

18-
Base.@kwdef mutable struct PackedGenericMarginal <: AbstractPackedFactor
18+
Base.@kwdef mutable struct PackedGenericMarginal <: AbstractPackedObservation
1919
Zij::Array{Float64, 1}
2020
Cov::Array{Float64, 1}
2121
W::Array{Float64, 1}

IncrementalInference/src/Factors/LinearRelative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ end
5959
$(TYPEDEF)
6060
Serialization type for `LinearRelative` binary factor.
6161
"""
62-
Base.@kwdef mutable struct PackedLinearRelative <: AbstractPackedFactor
62+
Base.@kwdef mutable struct PackedLinearRelative <: AbstractPackedObservation
6363
Z::PackedBelief
6464
end
6565
function convert(::Type{PackedLinearRelative}, d::LinearRelative)

IncrementalInference/src/Factors/MetaPrior.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Meta prior brings additional information not necessarily numerical prior
22

3-
Base.@kwdef struct MetaPrior{T} <: AbstractPrior
3+
Base.@kwdef struct MetaPrior{T} <: AbstractPriorObservation
44
data::T
55
partial::Vector{Int} = Int[]
66
end

0 commit comments

Comments
 (0)