Skip to content

Commit 9c1ecf5

Browse files
authored
Remove PPEs - use calcMeanMaxSuggested (#1885)
1 parent d4a8f70 commit 9c1ecf5

33 files changed

Lines changed: 198 additions & 412 deletions

IncrementalInference/src/CliqueStateMachine/services/CliqueStateMachine.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,11 +928,9 @@ Notes
928928
function updateFromSubgraph_StateMachine(csmc::CliqStateMachineContainer)
929929
isParametricSolve = csmc.algorithm == :parametric
930930

931-
# set PPE and solved for all frontals
931+
# set solved for all frontals
932932
if !isParametricSolve
933933
for sym in getCliqFrontalVarIds(csmc.cliq)
934-
# set PPE in cliqSubFg
935-
setVariablePosteriorEstimates!(csmc.cliqSubFg, sym)
936934
# set solved flag
937935
vari = getVariable(csmc.cliqSubFg, sym, csmc.solveKey)
938936
setSolvedCount!(vari, getSolvedCount(vari, csmc.solveKey) + 1, csmc.solveKey)
@@ -951,7 +949,6 @@ function updateFromSubgraph_StateMachine(csmc::CliqStateMachineContainer)
951949
frsyms,
952950
csmc.logger;
953951
solveKey = csmc.solveKey,
954-
updatePPE = !isParametricSolve,
955952
)
956953

957954
#solve finished change color

IncrementalInference/src/Deprecated.jl

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,81 @@ function sampleTangent(x::ManifoldKernelDensity, p = mean(x))
155155
error("sampleTangent(x::ManifoldKernelDensity, p) should be replaced by sampleTangent(M<:AbstractManifold, x::ManifoldKernelDensity, p)")
156156
end
157157

158-
## ================================================================================================
159-
## ================================================================================================
158+
export setPPE!, setVariablePosteriorEstimates!
159+
setPPE!(args...; kw...) = error("PPEs are obsolete (use `calcMeanMaxSuggested` provisionally), see DFG #1133")
160+
setVariablePosteriorEstimates!(args...; kw...) = error("PPEs are obsolete (use `calcMeanMaxSuggested` provisionally), see DFG #1133")
161+
162+
@deprecate calcPPE(
163+
var::VariableCompute,
164+
varType::StateType = getVariableType(var);
165+
solveKey::Symbol = :default,
166+
kwargs...,
167+
) calcMeanMaxSuggested(var, solveKey)
168+
169+
@deprecate calcPPE(
170+
dfg::AbstractDFG,
171+
label::Symbol;
172+
solveKey::Symbol = :default,
173+
kwargs...,
174+
) calcMeanMaxSuggested(dfg, label, solveKey)
175+
176+
export calcVariablePPE
177+
const calcVariablePPE = calcPPE
178+
179+
#FIXME The next functions use PPEs and should be updated or deprecated
180+
# getPPESuggestedAll no external use
181+
# findVariablesNear used in 1 rome example
182+
"""
183+
$SIGNATURES
184+
185+
Return `::Tuple` with matching variable ID symbols and `Suggested` PPE values.
186+
187+
Related
160188
161-
# TODO maybe upstream to DFG
162-
DFG.MeanMaxPPE(solveKey::Symbol, suggested::StaticArray, max::StaticArray, mean::StaticArray) =
163-
DFG.MeanMaxPPE(solveKey, Vector(suggested), Vector(max), Vector(mean))
189+
getVariablePPE
190+
"""
191+
function getPPESuggestedAll(dfg::AbstractDFG, regexFilter::Union{Nothing, Regex} = nothing)
192+
#
193+
# get values
194+
vsyms = listVariables(dfg, regexFilter) |> sortDFG
195+
slamPPE = map(x -> getVariablePPE(dfg, x).suggested, vsyms)
196+
# sizes to convert to matrix
197+
rumax = zeros(Int, 2)
198+
for ppe in slamPPE
199+
rumax[2] = length(ppe)
200+
rumax[1] = maximum(rumax)
201+
end
202+
203+
# populate with values
204+
XYT = zeros(length(slamPPE), rumax[1])
205+
for i = 1:length(slamPPE)
206+
XYT[i, 1:length(slamPPE[i])] = slamPPE[i]
207+
end
208+
return (vsyms, XYT)
209+
end
210+
211+
"""
212+
$SIGNATURES
213+
214+
Find and return a `::Tuple` of variables and distances to `loc::Vector{<:Real}`.
215+
216+
Related
217+
218+
findVariablesNearTimestamp
219+
"""
220+
function findVariablesNear(
221+
dfg::AbstractDFG,
222+
loc::Vector{<:Real},
223+
regexFilter::Union{Nothing, Regex} = nothing;
224+
number::Int = 3,
225+
)
226+
#
227+
228+
xy = getPPESuggestedAll(dfg, regexFilter)
229+
dist = sum((xy[2][:, 1:length(loc)] .- loc') .^ 2; dims = 2) |> vec
230+
prm = (dist |> sortperm)[1:number]
231+
return (xy[1][prm], sqrt.(dist[prm]))
232+
end
164233

165234

166235
## ================================================================================================

IncrementalInference/src/ExportAPI.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ export CSMHistory,
9393
getLabel,
9494
getVariables,
9595
getVariableOrder,
96-
getPPE,
97-
getPPEDict,
98-
getVariablePPE,
9996
isVariable,
10097
isFactor,
10198
getFactorType,
@@ -292,12 +289,7 @@ export CSMHistory,
292289
reshapeVec2Mat
293290

294291
export incrSuffix
295-
296-
export calcPPE, calcVariablePPE
297-
export setPPE!, setVariablePosteriorEstimates!
298-
export getPPEDict
299-
export getPPESuggested, getPPEMean, getPPEMax
300-
export getPPESuggestedAll
292+
export calcMeanMaxSuggested
301293
export loadDFG
302294
export findVariablesNear, defaultFixedLagOnTree!
303295
export fetchDataJSON

IncrementalInference/src/IncrementalInference.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ import DistributedFactorGraphs: addVariable!, addFactor!, ls, lsf, isInitialized
109109
import DistributedFactorGraphs: compare
110110
import DistributedFactorGraphs: rebuildFactorCache!
111111
import DistributedFactorGraphs: getDimension, getManifold, getPointType, getPointIdentity
112-
import DistributedFactorGraphs: getPPE, getPPEDict
113112
import DistributedFactorGraphs: getPoint, getCoordinates
114113
import DistributedFactorGraphs: getVariableType
115114
import DistributedFactorGraphs: AbstractPointParametricEst, loadDFG

IncrementalInference/src/parametric/services/ConsolidateParametricRelatives.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Notes
1414
1515
DevNotes
1616
- TODO ensure type stability, likely returning types `Any` at this time.
17-
- TODO MeanMaxPPE currently stored as coordinates, complicating fast calculation.
17+
- TODO parametric estimates currently stored as coordinates, complicating fast calculation.
1818
1919
Related: [`getMeasurementParametric`](@ref), [`approxConvBelief`](@ref), [`MutablePose2Pose2Gaussian`](@ref)
2020
"""
@@ -45,9 +45,6 @@ function solveFactorParametric(
4545

4646
# get variable points
4747
function _getParametric(vari::VariableCompute, key = :default)
48-
# hasp = haskey(getPPEDict(vari), key)
49-
# FIXME use PPE via Manifold points currently in coordinates
50-
# hasp ? getPPE(vari, key).suggested : calcMean(getBelief(vari, key))
5148
pt = calcMean(getBelief(vari, key))
5249

5350
return collect(getCoordinates(getVariableType(vari), pt))

IncrementalInference/src/parametric/services/ParametricManopt.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,6 @@ function autoinitParametric!(
575575
vnd.initialized = true
576576
#fill in ppe as mean
577577
Xc::Vector{Float64} = collect(getCoordinates(getVariableType(xi), val))
578-
ppe = DFG.MeanMaxPPE(solveKey, Xc, Xc, Xc)
579-
getPPEDict(xi)[solveKey] = ppe
580578

581579
result = true
582580

IncrementalInference/src/parametric/services/ParametricUtils.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -923,17 +923,13 @@ end
923923

924924
"""
925925
$SIGNATURES
926-
Update the fg from solution in vardict and add MeanMaxPPE (all just mean). Usefull for plotting
926+
Update the fg from solution in vardict. Usefull for plotting
927927
"""
928928
function updateParametricSolution!(sfg, vardict::AbstractDict; solveKey::Symbol = :parametric)
929929
for (v, val) in vardict
930930
vnd = getState(getVariable(sfg, v), solveKey)
931931
# Update the variable node data value and covariance
932932
updateSolverDataParametric!(vnd, val.val, val.cov)
933-
#fill in ppe as mean
934-
Xc = collect(getCoordinates(getVariableType(sfg, v), val.val))
935-
ppe = DFG.MeanMaxPPE(solveKey, Xc, Xc, Xc)
936-
getPPEDict(getVariable(sfg, v))[solveKey] = ppe
937933
end
938934
end
939935

@@ -948,10 +944,6 @@ function updateParametricSolution!(fg, M, labels::AbstractArray{Symbol}, vals,
948944
covar = isnothing(Σ) ? vnd.bw : covars[i]
949945
# Update the variable node data value and covariance
950946
updateSolverDataParametric!(vnd, val, covar)#FIXME add cov
951-
#fill in ppe as mean
952-
Xc = collect(getCoordinates(getVariableType(fg, v), val))
953-
ppe = DFG.MeanMaxPPE(solveKey, Xc, Xc, Xc)
954-
getPPEDict(getVariable(fg, v))[solveKey] = ppe
955947
end
956948

957949
end
@@ -973,7 +965,7 @@ function createMvNormal(v::VariableCompute, key = :parametric)
973965
dims = vnd.dims
974966
return createMvNormal(vnd.val[1:dims, 1], vnd.bw[1:dims, 1:dims])
975967
else
976-
@warn "Trying MvNormal Fit, replace with PPE fits in future"
968+
@warn "Trying MvNormal Fit"
977969
return fit(MvNormal, getState(v, key).val)
978970
end
979971
end
@@ -1035,10 +1027,6 @@ function autoinitParametricOptim!(
10351027
updateSolverDataParametric!(vnd, val, cov)
10361028

10371029
vnd.initialized = true
1038-
#fill in ppe as mean
1039-
Xc = collect(getCoordinates(getVariableType(xi), val))
1040-
ppe = DFG.MeanMaxPPE(:parametric, Xc, Xc, Xc)
1041-
getPPEDict(xi)[:parametric] = ppe
10421030

10431031
# updateVariableSolverData!(dfg, xi, solveKey, true; warn_if_absent=false)
10441032
# updateVariableSolverData!(dfg, xi.label, getState(xi, solveKey), :graphinit, true, Symbol[]; warn_if_absent=false)

IncrementalInference/src/services/ApproxConv.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,12 @@ Notes
6060
- Fresh starting point will be used if first element in `fctLabels` is a unary `<:AbstractPriorObservation`.
6161
- This function will not change any values in `dfg`, and might have slightly less speed performance to meet this requirement.
6262
- pass in `tfg` to get a recoverable result of all convolutions in the chain.
63-
- `setPPE` and `setPPEmethod` can be used to store PPE information in temporary `tfg`
6463
6564
DevNotes
6665
- TODO strong requirement that this function is super efficient on single factor/variable case!
6766
- FIXME must consolidate with `accumulateFactorMeans`
6867
- TODO `solveKey` not fully wired up everywhere yet
6968
- tfg gets all the solveKeys inside the source `dfg` variables
70-
- TODO add a approxConv on PPE option
7169
- Consolidate with [`accumulateFactorMeans`](@ref), `approxConvBinary`
7270
7371
Related
@@ -82,8 +80,6 @@ function approxConvBelief(
8280
solveKey::Symbol = :default,
8381
N::Int = length(measurement),
8482
tfg::AbstractDFG = LocalDFG(;solverParams=getSolverParams(dfg)),
85-
setPPEmethod::Union{Nothing, Type{<:AbstractPointParametricEst}} = nothing,
86-
setPPE::Bool = setPPEmethod !== nothing,
8783
path::AbstractVector{Symbol} = Symbol[],
8884
skipSolve::Bool = false,
8985
nullSurplus::Real = 0,
@@ -149,9 +145,6 @@ function approxConvBelief(
149145
end
150146
# didn't return early so shift focus to using `tfg` more intensely
151147
initVariable!(tfg, varLbls[1], pts)
152-
# use in combination with setPPE and setPPEmethod keyword arguments
153-
ppemethod = setPPEmethod === nothing ? DFG.MeanMaxPPE : setPPEmethod
154-
!setPPE ? nothing : setPPE!(tfg, varLbls[1], solveKey, ppemethod)
155148

156149
# do chain of convolutions
157150
for idx = idxS:length(path)
@@ -161,7 +154,6 @@ function approxConvBelief(
161154
addFactor!(tfg, fct)
162155
ptsBel = approxConvBelief(tfg, fct, path[idx + 1]; solveKey, N, skipSolve, keepCalcFactor)
163156
initVariable!(tfg, path[idx + 1], ptsBel)
164-
!setPPE ? nothing : setPPE!(tfg, path[idx + 1], solveKey, ppemethod)
165157
end
166158
end
167159

0 commit comments

Comments
 (0)