Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Pose2 preambleCache bug #562

Merged
merged 3 commits into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/factors/Pose2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ DFG.getManifold(::InstanceType{Pose2Pose2}) = getManifold(Pose2) # Manifolds.Spe

Pose2Pose2(::UniformScaling) = Pose2Pose2()

function preambleCache(dfg::AbstractDFG, vars::AbstractVector{<:DFGVariable}, pp::Pose2Pose2)
M = getManifold(pp)
(;manifold=M, ϵ0=identity_element(M), Xc=zeros(3), q̂=identity_element(M))
end

# Assumes X is a tangent vector
function (cf::CalcFactor{<:Pose2Pose2})(X, p, q)
@assert X isa ProductRepr "Pose2Pose2 expects measurement sample X to be a Manifolds tangent vector, not coordinate or point representation. Got X=$X"
M = getManifold(Pose2)
q̂ = Manifolds.compose(M, p, exp(M, identity_element(M, p), X)) #for groups
#TODO allocalte for vee! see Manifolds #412, fix for AD
Xc = zeros(3)
vee!(M, Xc, q, log(M, q, q̂))
return Xc
@assert X isa ProductRepr || X isa Manifolds.ArrayPartition "Pose2Pose2 expects measurement sample X to be a Manifolds tangent vector, not coordinate or point representation. Got X=$X"

M = cf.cache.manifold # getManifold(Pose2)
ϵ0 = cf.cache.ϵ0
q̂ = cf.cache.q̂

#for groups
Manifolds.compose!(M, q̂, p, exp(M, ϵ0, X))
fill!(cf.cache.Xc, 0.0)
vee!(M, cf.cache.Xc, q, log(M, q, q̂))
return cf.cache.Xc
end



# NOTE, serialization support -- will be reduced to macro in future
Expand Down