@@ -40,15 +40,38 @@ function preambleCache(dfg::AbstractDFG, vars::AbstractVector{<:DFGVariable}, pp
4040 (;manifold= M, ϵ0= getPointIdentity(M), Xc= zeros(3 ), q̂= getPointIdentity(M))
4141end
4242
43+ @inline function _vee(:: SpecialEuclidean{2} , X:: ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}} ) where T<: Real
44+ return SVector{3 ,T}(X. x[1 ][1 ],X. x[1 ][2 ],X. x[2 ][2 ])
45+ end
46+
47+ @inline function _compose(:: SpecialEuclidean{2} , p:: ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}} , q:: ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}} ) where T<: Real
48+ return ArrayPartition(p. x[1 ] + p. x[2 ]* q. x[1 ], p. x[2 ]* q. x[2 ])
49+ end
50+
4351# Assumes X is a tangent vector
44- function (cf:: CalcFactor{<:Pose2Pose2} )(X, p, q)
52+ function (cf:: CalcFactor{<:Pose2Pose2} )(_X:: AbstractArray{MT} , _p:: AbstractArray{PT} , _q:: AbstractArray{LT} ) where {MT,PT,LT}
53+ T = promote_type(MT, PT, LT)
54+ X = convert(ArrayPartition{T, Tuple{SVector{2 , T}, SMatrix{2 , 2 , T, 4 }}}, _X)
55+ p = convert(ArrayPartition{T, Tuple{SVector{2 , T}, SMatrix{2 , 2 , T, 4 }}}, _p)
56+ q = convert(ArrayPartition{T, Tuple{SVector{2 , T}, SMatrix{2 , 2 , T, 4 }}}, _q)
57+ return cf(X,p,q)
58+ end
59+
60+ # function calcPose2Pose2(
61+ function (cf:: CalcFactor{<:Pose2Pose2} )(
62+ X:: ArrayPartition{XT, Tuple{SVector{2, XT}, SMatrix{2, 2, XT, 4}}} ,
63+ p:: ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}} ,
64+ q:: ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}} ) where {XT<: Real ,T<: Real }
4565
46- q̂ = allocate(q)
4766 M = getManifold(Pose2)
48- ϵ0 = getPointIdentity(M)
49- exp!(M, q̂, ϵ0, X)
50- Manifolds. compose!(M, q̂, p, q̂)
51- Xc = vee(M, q, log!(M, q̂, q, q̂))
67+ ϵ0 = ArrayPartition(zeros(SVector{2 ,T}), SMatrix{2 , 2 , T}(I))
68+
69+ ϵX = exp(M, ϵ0, X)
70+ # q̂ = Manifolds.compose(M, p, ϵX)
71+ q̂ = _compose(M, p, ϵX)
72+ X_hat = log(M, q, q̂)
73+ # Xc = vee(M, q, X_hat)
74+ Xc = _vee(M, X_hat)
5275 return Xc
5376end
5477
0 commit comments