Skip to content

Commit

Permalink
Slightly faster and cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Affie committed Aug 11, 2022
1 parent abc9708 commit cf32ff9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/factors/Pose2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function preambleCache(dfg::AbstractDFG, vars::AbstractVector{<:DFGVariable}, pp
(;manifold=M, ϵ0=getPointIdentity(M), Xc=zeros(3), q̂=getPointIdentity(M))
end

@inline function _vee(::SpecialEuclidean{2}, X::ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}) where T<:Real
return SVector{3,T}(X.x[1][1],X.x[1][2],X.x[2][2])
end

@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
return ArrayPartition(p.x[1] + p.x[2]*q.x[1], p.x[2]*q.x[2])
end

# Assumes X is a tangent vector
function (cf::CalcFactor{<:Pose2Pose2})(_X::AbstractArray{MT}, _p::AbstractArray{PT}, _q::AbstractArray{LT}) where {MT,PT,LT}
T = promote_type(MT, PT, LT)
Expand All @@ -60,14 +68,10 @@ function (cf::CalcFactor{<:Pose2Pose2})(

ϵX = exp(M, ϵ0, X)
# q̂ = Manifolds.compose(M, p, ϵX)
tp, Rp = Manifolds.submanifold_components(M, p)
tq, Rq = Manifolds.submanifold_components(M, ϵX)
R = Rp*Rq
t = tp + Rp*(tq)
= ArrayPartition(t,R)
X = log(M, q, q̂)
# Xc = vee(M, q, q̂)
Xc = SA[X.x[1][1], X.x[1][2], X.x[2][2]]
= _compose(M, p, ϵX)
X_hat = log(M, q, q̂)
# Xc = vee(M, q, X_hat)
Xc = _vee(M, X_hat)
return Xc
end

Expand Down

0 comments on commit cf32ff9

Please sign in to comment.