@@ -64,6 +64,7 @@ struct ScatterAlignPose3 <: IIF.AbstractManifoldMinimize
6464 align:: ScatterAlign{Pose3,<:Any,<:Any}
6565end
6666
67+ _getPoseType (:: ScatterAlign{P} ) where P = P
6768
6869# replace inner constructor with transform on image
6970function ScatterAlignPose2 (im1:: AbstractMatrix{T} ,
@@ -156,9 +157,8 @@ getManifold(::IIF.InstanceType{<:ScatterAlignPose3}) = getManifold(Pose3Pose3)
156157# runs once upon addFactor! and returns object later used as `cache`
157158function preambleCache (dfg:: AbstractDFG , vars:: AbstractVector{<:DFGVariable} , fnc:: Union{<:ScatterAlignPose2,<:ScatterAlignPose3} )
158159 #
159- _getPoseType (sa:: ScatterAlign{P} ) where P = P
160160 M = getManifold (_getPoseType (fnc. align))
161- e0 = getPointIdentity (M) # ArrayPartition(SVector(0.0,0.0), SMatrix{2,2}(1.0, 0.0, 0.0, 1.0))
161+ e0 = getPointIdentity (M)
162162
163163 # reconstitute cloud belief from dataEntry
164164 for (va,de,cl) in zip (vars,[fnc. align. dataEntry_cloud1,fnc. align. dataEntry_cloud2],[fnc. align. cloud1,fnc. align. cloud2])
@@ -182,10 +182,12 @@ function preambleCache(dfg::AbstractDFG, vars::AbstractVector{<:DFGVariable}, fn
182182end
183183
184184
185- function getSample ( cf:: CalcFactor{<: ScatterAlignPose2} )
185+ function getSample ( cf:: CalcFactor{S} ) where {S <: Union{<: ScatterAlignPose2,<:ScatterAlignPose3} }
186186 #
187187 M = cf. cache. M
188188 e0 = cf. cache. e0
189+ ntr = length (Manifolds. submanifold_component (e0,1 ))
190+ nrt = Manifolds. manifold_dimension (M)- ntr
189191 # R0 = submanifold_component(e0,2)
190192
191193 pVi = cf. cache. smps1
@@ -203,7 +205,7 @@ function getSample( cf::CalcFactor{<:ScatterAlignPose2} )
203205 cost (xyr) = mmd (M. manifold[1 ], pVi, pVj (xyr), length (pVi), length (qVj), cf. _allowThreads; cf. cache. bw)
204206
205207 # return mmd as residual for minimization
206- res = Optim. optimize (cost, [5 * randn (2 ); 0.1 * randn ()], Optim. BFGS () )
208+ res = Optim. optimize (cost, [5 * randn (ntr ); 0.1 * randn (nrt )], Optim. BFGS () )
207209
208210 cf. cache. score[] = res. minimum
209211
@@ -213,20 +215,29 @@ function getSample( cf::CalcFactor{<:ScatterAlignPose2} )
213215end
214216
215217
216- function (cf:: CalcFactor{<:ScatterAlignPose2} )(pXq, wPp, wPq)
218+ function (cf:: CalcFactor{S} )(X, p, q
219+ ) where {S <: Union{<:ScatterAlignPose2,<:ScatterAlignPose3} }
217220 #
218221
219222 M = cf. cache. M
220- e0 = cf. cache. e0
221-
222- # get the current relative transform estimate
223- wPq_ = Manifolds. compose (M, wPp, exp (M, e0, pXq))
224-
225- # TODO allocalte for vee! see Manifolds #412, fix for AD
226- Xc = zeros (3 )
227- vee! (M, Xc, wPq, log (M, wPq, wPq_))
223+ ϵ0 = cf. cache. e0
228224
225+ # copied from Pose2Pose2
226+ q̂ = allocate (q)
227+ exp! (M, q̂, ϵ0, X)
228+ Manifolds. compose! (M, q̂, p, q̂)
229+ Xc = vee (M, q, log! (M, q̂, q, q̂))
229230 return Xc
231+
232+ # pXq,
233+ # wPp,
234+ # wPq
235+ # # get the current relative transform estimate
236+ # wPq_ = Manifolds.compose(M, wPp, exp(M, e0, pXq))
237+ # #TODO allocalte for vee! see Manifolds #412, fix for AD
238+ # Xc = zeros(3)
239+ # vee!(M, Xc, wPq, log(M, wPq, wPq_))
240+ # return Xc
230241end
231242
232243
0 commit comments