Skip to content

Commit 704169a

Browse files
committed
TBD consolidation of solveFactorParametric
1 parent 9b5369a commit 704169a

File tree

3 files changed

+76
-74
lines changed

3 files changed

+76
-74
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# functions relating to parametric solutions of a single factor that is likely in need of consolidation
2+
3+
4+
5+
"""
6+
$SIGNATURES
7+
8+
Helper function to propagate a parametric estimate along a factor chain.
9+
This function takes and returns variable values as coordinates.
10+
11+
Notes
12+
- Not used during MM-iSAM inference.
13+
- Expected uses are for user analysis of factors and estimates.
14+
- real-time dead reckoning chain prediction.
15+
- Parametric binary factor utility function, used by DRT
16+
17+
DevNotes
18+
- TODO ensure type stability, likely returning types `Any` at this time.
19+
- TODO MeanMaxPPE currently stored as coordinates, complicating fast calculation.
20+
21+
Related:
22+
23+
[`getMeasurementParametric`](@ref), [`approxConv`](@ref), [`MutablePose2Pose2Gaussian`](@ref)
24+
"""
25+
function solveFactorParameteric(dfg::AbstractDFG,
26+
fct::DFGFactor,
27+
# currval::P1,
28+
srcsym_vals::AbstractVector{Pair{Symbol, P}},
29+
trgsym::Symbol,
30+
solveKey::Symbol=:default;
31+
evaltmpkw... ) where P
32+
#
33+
34+
varLbls = getVariableOrder(fct)
35+
varTypes = tuple((getVariableType.(dfg, varLbls))...)
36+
sfidx = findfirst( varLbls .== trgsym )
37+
38+
# get the measurement point
39+
fctTyp = getFactorType(fct)
40+
# this is definitely in coordinates, see JuliaRobotics/RoME.jl#465
41+
mea, _ = getMeasurementParametric(fctTyp)
42+
# must change measT to be a tangent vector
43+
M = getManifold(fctTyp)
44+
e0 = identity_element(M)
45+
mea_ = hat(M, e0, mea)
46+
measT = (mea_,)
47+
48+
# get variable points
49+
function _getParametric(vari::DFGVariable, key=:default)
50+
# hasp = haskey(getPPEDict(vari), key)
51+
# FIXME use PPE via Manifold points currently in coordinates
52+
# hasp ? getPPE(vari, key).suggested : calcMean(getBelief(vari, key))
53+
pt = calcMean(getBelief(vari, key))
54+
55+
getCoordinates(getVariableType(vari),pt)
56+
end
57+
58+
# overwrite specific src values from user
59+
coordVals = _getParametric.(getVariable.(dfg, varLbls), solveKey)
60+
for (srcsym, currval) in srcsym_vals
61+
coordVals[findfirst(varLbls .== srcsym)] = currval
62+
end
63+
crds = tuple(coordVals...)
64+
65+
pts = tuple(map(t->getPoint(t...), zip(varTypes,crds))...)
66+
67+
# do the calculation to find solvefor index using the factor, as manifold point
68+
pt = _evalFactorTemporary!( fctTyp, varTypes, sfidx, measT, pts; solveKey=solveKey, evaltmpkw... )[1]
69+
70+
return getCoordinates(getVariableType(dfg, trgsym), pt)
71+
end
72+
73+

src/IncrementalInference.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export *,
132132
# state machine methods
133133
StateMachine,
134134
exitStateMachine,
135-
printSummary,
136135
print,
137136
getGraphFromHistory,
138137
getCliqSubgraphFromHistory,
@@ -463,14 +462,12 @@ include("Factors/PartialPrior.jl")
463462
include("Factors/PartialPriorPassThrough.jl")
464463
include("DefaultNodeTypes.jl") # older file
465464

466-
467465
# Refactoring in progress
468466
include("services/CalcFactor.jl")
469467
# gradient tools
470468
include("services/FactorGradients.jl")
471469
include("services/CliqueTypes.jl")
472470

473-
474471
# solving graphs
475472
include("SolverUtilities.jl")
476473
include("NumericalCalculations.jl")
@@ -479,6 +476,9 @@ include("ExplicitDiscreteMarginalizations.jl")
479476
include("InferDimensionUtils.jl")
480477
include("services/EvalFactor.jl")
481478
include("services/ApproxConv.jl")
479+
480+
include("ConsolidateParametricRelative.jl") # FIXME CONSOLIDATE
481+
482482
include("GraphProductOperations.jl")
483483
include("SolveTree.jl")
484484
include("TetherUtils.jl")

src/services/ApproxConv.jl

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -241,77 +241,6 @@ end
241241

242242

243243

244-
"""
245-
$SIGNATURES
246-
247-
Helper function to propagate a parametric estimate along a factor chain.
248-
This function takes and returns variable values as coordinates.
249-
250-
Notes
251-
- Not used during MM-iSAM inference.
252-
- Expected uses are for user analysis of factors and estimates.
253-
- real-time dead reckoning chain prediction.
254-
- Parametric binary factor utility function, used by DRT
255-
256-
DevNotes
257-
- TODO ensure type stability, likely returning types `Any` at this time.
258-
- TODO MeanMaxPPE currently stored as coordinates, complicating fast calculation.
259-
260-
Related:
261-
262-
[`getMeasurementParametric`](@ref), [`approxConv`](@ref), [`MutablePose2Pose2Gaussian`](@ref)
263-
"""
264-
function solveFactorParameteric(dfg::AbstractDFG,
265-
fct::DFGFactor,
266-
# currval::P1,
267-
srcsym_vals::AbstractVector{Pair{Symbol, P}},
268-
trgsym::Symbol,
269-
solveKey::Symbol=:default;
270-
evaltmpkw... ) where P
271-
#
272-
273-
varLbls = getVariableOrder(fct)
274-
varTypes = tuple((getVariableType.(dfg, varLbls))...)
275-
sfidx = findfirst( varLbls .== trgsym )
276-
277-
# get the measurement point
278-
fctTyp = getFactorType(fct)
279-
# this is definitely in coordinates, see JuliaRobotics/RoME.jl#465
280-
mea, _ = getMeasurementParametric(fctTyp)
281-
# must change measT to be a tangent vector
282-
M = getManifold(fctTyp)
283-
e0 = identity_element(M)
284-
mea_ = hat(M, e0, mea)
285-
measT = (mea_,)
286-
287-
# get variable points
288-
function _getParametric(vari::DFGVariable, key=:default)
289-
# hasp = haskey(getPPEDict(vari), key)
290-
# FIXME use PPE via Manifold points currently in coordinates
291-
# hasp ? getPPE(vari, key).suggested : calcMean(getBelief(vari, key))
292-
pt = calcMean(getBelief(vari, key))
293-
294-
getCoordinates(getVariableType(vari),pt)
295-
end
296-
297-
# overwrite specific src values from user
298-
coordVals = _getParametric.(getVariable.(dfg, varLbls), solveKey)
299-
for (srcsym, currval) in srcsym_vals
300-
coordVals[findfirst(varLbls .== srcsym)] = currval
301-
end
302-
crds = tuple(coordVals...)
303-
304-
pts = tuple(map(t->getPoint(t...), zip(varTypes,crds))...)
305-
306-
# do the calculation to find solvefor index using the factor, as manifold point
307-
pt = _evalFactorTemporary!( fctTyp, varTypes, sfidx, measT, pts; solveKey=solveKey, evaltmpkw... )[1]
308-
309-
return getCoordinates(getVariableType(dfg, trgsym), pt)
310-
end
311-
312-
313-
314-
315244

316245

317246
#

0 commit comments

Comments
 (0)