Skip to content

Commit 6898700

Browse files
committed
wip general adjoint factor
1 parent 7ce21d8 commit 6898700

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/Factors/GenericFunctions.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,59 @@ function (cf::CalcFactor{<:ManifoldFactor})(X, p, q)
9999
return distanceTangent2Point(cf.factor.M, X, p, q)
100100
end
101101

102+
103+
## ======================================================================================
104+
## adjoint factor - adjoint action applied to the measurement
105+
## ======================================================================================
106+
107+
108+
# Adjoints defined in ApproxManifoldProducts
109+
struct AdFactor{F <: AbstractManifoldMinimize} <: AbstractManifoldMinimize
110+
factor::F
111+
end
112+
113+
function (cf::CalcFactor{<:AdFactor})(Xϵ, p, q)
114+
# M = getManifold(cf.factor)
115+
# p,q ∈ M
116+
# Xϵ ∈ TϵM
117+
# ϵ = identity_element(M)
118+
# transform measurement from TϵM to TpM (global to local coordinates)
119+
# Adₚ⁻¹ = AdjointMatrix(M, p)⁻¹ = AdjointMatrix(M, p⁻¹)
120+
# Xp = Adₚ⁻¹ * Xϵᵛ
121+
# ad = Ad(M, inv(M, p))
122+
# Xp = Ad(M, inv(M, p), Xϵ)
123+
# Xp = adjoint_action(M, inv(M, p), Xϵ)
124+
#TODO is vector transport supposed to be the same?
125+
# Xp = vector_transport_to(M, ϵ, Xϵ, p)
126+
127+
# Transform measurement covariance
128+
# ᵉΣₚ = Adₚ ᵖΣₚ Adₚᵀ
129+
#TODO test if transforming sqrt_iΣ is the same as Σ
130+
# Σ = ad * inv(cf.sqrt_iΣ^2) * ad'
131+
# sqrt_iΣ = convert(typeof(cf.sqrt_iΣ), sqrt(inv(Σ)))
132+
# sqrt_iΣ = convert(typeof(cf.sqrt_iΣ), ad * cf.sqrt_iΣ * ad')
133+
Xp =
134+
135+
child_cf = CalcFactorResidual(
136+
cf.faclbl,
137+
cf.factor.factor,
138+
cf.varOrder,
139+
cf.varOrderIdxs,
140+
cf.meas,
141+
cf.sqrt_iΣ,
142+
cf.cache,
143+
)
144+
return child_cf(Xp, p, q)
145+
end
146+
147+
getMeasurementParametric(f::AdFactor) = getMeasurementParametric(f.factor)
148+
149+
getManifold(f::AdFactor) = getManifold(f.factor)
150+
function getSample(cf::CalcFactor{<:AdFactor})
151+
M = getManifold(cf)
152+
return sampleTangent(M, cf.factor.factor.Z)
153+
end
154+
102155
## ======================================================================================
103156
## ManifoldPrior
104157
## ======================================================================================

0 commit comments

Comments
 (0)