@@ -11,7 +11,7 @@ using SparseArrays
1111
1212
1313
14- function CalcFactorManopt (fct:: DFGFactor , varIntLabel)
14+ function CalcFactorManopt (fg, fct:: DFGFactor , varIntLabel)
1515 fac_func = getFactorType (fct)
1616 varOrder = getVariableOrder (fct)
1717
@@ -20,42 +20,28 @@ function CalcFactorManopt(fct::DFGFactor, varIntLabel)
2020 M = getManifold (getFactorType (fct))
2121
2222 dims = manifold_dimension (M)
23- ϵ = getPointIdentity (M)
24-
25- _meas, _iΣ = getMeasurementParametric (fct)
26- if fac_func isa ManifoldPrior
27- meas = _meas # already a point on M
28- elseif fac_func isa AbstractPrior
29- X = get_vector (M, ϵ, _meas, DefaultOrthonormalBasis ())
30- meas = exp (M, ϵ, X) # convert to point on M
31- else
32- # its a relative factor so should be a tangent vector
33- meas = convert (typeof (ϵ), get_vector (M, ϵ, _meas, DefaultOrthonormalBasis ()))
34- end
3523
36- # make sure its an SMatrix
37- iΣ = convert (SMatrix{dims, dims}, _iΣ)
24+ meas, iΣ = getFactorMeasurementParametric (fct)
3825
3926 sqrt_iΣ = convert (SMatrix{dims, dims}, sqrt (iΣ))
40- # cache = preambleCache(fg, getVariable.(fg, varOrder), getFactorType(fct))
27+ cache = preambleCache (fg, getVariable .(fg, varOrder), getFactorType (fct))
4128
42- calcf = CalcFactor (
29+ return CalcFactorManopt (
30+ fct. label,
4331 getFactorMechanics (fac_func),
44- 0 ,
45- nothing ,
46- true ,
47- nothing ,# cache,
48- (), # DFGVariable[],
49- 0 ,
50- getManifold (fac_func),
32+ cache,
33+ varOrder,
34+ varOrderIdxs,
35+ meas,
36+ iΣ,
37+ sqrt_iΣ,
5138 )
52- return CalcFactorManopt (fct. label, calcf, varOrder, varOrderIdxs, meas, iΣ, sqrt_iΣ)
5339end
5440
5541function (cfm:: CalcFactorManopt )(p)
5642 meas = cfm. meas
5743 idx = cfm. varOrderIdxs
58- return cfm. sqrt_iΣ * cfm. calcfactor! (meas, p[idx]. .. )
44+ return cfm. sqrt_iΣ * cfm (meas, p[idx]. .. )
5945end
6046
6147# cost function f: M->ℝᵈ for Riemannian Levenberg-Marquardt
@@ -83,7 +69,8 @@ struct JacF_RLM!{CF, T}
8369 res:: Vector{Float64}
8470end
8571
86- function JacF_RLM! (M, costF!; basis_domain:: AbstractBasis = DefaultOrthonormalBasis ())
72+ # function JacF_RLM!(M, costF!; basis_domain::AbstractBasis = DefaultOrthonormalBasis())
73+ function JacF_RLM! (M, costF!; basis_domain:: AbstractBasis = DefaultOrthogonalBasis ())
8774
8875 p = costF!. points
8976
@@ -108,7 +95,8 @@ function (jacF!::JacF_RLM!)(
10895 M:: AbstractManifold ,
10996 J,
11097 p;
111- basis_domain:: AbstractBasis = DefaultOrthonormalBasis (),
98+ # basis_domain::AbstractBasis = DefaultOrthonormalBasis(),
99+ basis_domain:: AbstractBasis = DefaultOrthogonalBasis (),
112100)
113101
114102 X0 = jacF!. X0
@@ -196,7 +184,7 @@ function solve_RLM(
196184 # varIntLabel_frontals = filter(p->first(p) in frontals, varIntLabel)
197185 # varIntLabel_separators = filter(p->first(p) in separators, varIntLabel)
198186
199- calcfacs = map (f-> CalcFactorManopt (f, varIntLabel), facs)
187+ calcfacs = map (f-> CalcFactorManopt (fg, f, varIntLabel), facs)
200188
201189 # get the manifold and variable types
202190 frontal_vars = getVariable .(fg, frontals)
@@ -262,7 +250,7 @@ function solve_RLM_sparse(fg; kwargs...)
262250
263251 varIntLabel = OrderedDict (zip (varlabels, collect (1 : length (varlabels))))
264252
265- calcfacs = CalcFactorManopt .(facs, Ref (varIntLabel))
253+ calcfacs = CalcFactorManopt .(fg, facs, Ref (varIntLabel))
266254
267255 # get the manifold and variable types
268256 vars = getVariable .(fg, varlabels)
0 commit comments