Skip to content

Commit b8046d9

Browse files
committed
Update Pose2 to LieGroups
1 parent c0ab1e4 commit b8046d9

File tree

6 files changed

+18
-42
lines changed

6 files changed

+18
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/dev
1+
dev
22
Manifest.toml
33
*.so
44
*.cov

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
1818
IncrementalInference = "904591bb-b899-562f-9e6f-b8df64c7d480"
1919
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
2020
KernelDensityEstimate = "2472808a-b354-52ea-a80e-1658a3c6056d"
21+
LieGroups = "6774de46-80ba-43f8-ba42-e41071ccfc5f"
2122
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2223
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
2324
ManifoldsBase = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
@@ -65,6 +66,7 @@ ImageIO = "0.6"
6566
IncrementalInference = "0.35"
6667
Interpolations = "0.14, 0.15"
6768
KernelDensityEstimate = "0.5.1, 0.6"
69+
LieGroups = "0.1.1"
6870
LinearAlgebra = "1.10"
6971
Manifolds = "0.10.1"
7072
ManifoldsBase = "0.15, 1"

src/RoME.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ using
2121
DistributedFactorGraphs,
2222
TensorCast,
2323
ManifoldsBase,
24-
Manifolds
24+
Manifolds,
25+
LieGroups
2526

2627
using StaticArrays
2728
using PrecompileTools
@@ -33,7 +34,7 @@ using Manifolds: hat, ProductGroup, ProductManifold, SpecialEuclidean, SpecialOr
3334
import Manifolds: project, project!, identity_element
3435

3536
import Rotations as _Rot
36-
import Rotations: , # TODO deprecate
37+
# import Rotations: ⊕, ⊖ # TODO deprecate
3738

3839
export SpecialOrthogonal, SpecialEuclidean
3940
export submanifold_component

src/factors/Inertial/IMUDeltaFactor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ function (cf::CalcFactor{<:IMUDeltaFactor})(
394394
q_SE3,
395395
q_vel,
396396
b = zeros(SVector{6,Float64})
397-
) where T <: Real
397+
)
398398
p = ArrayPartition(p_SE3.x[2], p_vel, p_SE3.x[1])
399399
q = ArrayPartition(q_SE3.x[2], q_vel, q_SE3.x[1])
400400
return cf(Δmeas, p, q, b)

src/factors/Pose2D.jl

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ Rigid transform between two Pose2's, assuming (x,y,theta).
88
Calcuated as:
99
```math
1010
\\begin{aligned}
11-
\\hat{q}=\\exp_pX_m\\\\
12-
X = \\log_q \\hat{q}\\\\
13-
X^i = \\mathrm{vee}(q, X)
11+
\\hat{X}_p=\\log_pq\\\\
12+
X^i = \\mathrm{vee}(X_m-\\hat{X})
1413
\\end{aligned}
1514
```
1615
with:
1716
``\\mathcal M= \\mathrm{SE}(2)`` Special Euclidean group\\
1817
``p`` and ``q`` ``\\in \\mathcal M`` the two Pose2 points\\
1918
the measurement vector ``X_m \\in T_p \\mathcal M``\\
20-
and the error vector ``X \\in T_q \\mathcal M``\\
19+
and the error vector ``\hat{X} \\in T_p \\mathcal M``\\
2120
``X^i`` coordinates of ``X``
2221
2322
DevNotes
@@ -27,53 +26,27 @@ Related
2726
2827
[`Pose3Pose3`](@ref), [`Point2Point2`](@ref), [`MutablePose2Pose2Gaussian`](@ref), [`DynPose2`](@ref), [`IMUDeltaFactor`](@ref)
2928
"""
30-
Base.@kwdef struct Pose2Pose2{T <: IIF.SamplableBelief} <: IIF.AbstractManifoldMinimize
29+
Base.@kwdef struct Pose2Pose2{T<:IIF.SamplableBelief} <: IIF.AbstractManifoldMinimize
3130
Z::T = MvNormal(Diagonal([1.0; 1.0; 1.0]))
3231
end
3332

3433
DFG.getManifold(::InstanceType{Pose2Pose2}) = Manifolds.SpecialEuclidean(2; vectors=HybridTangentRepresentation())
3534

3635
Pose2Pose2(::UniformScaling) = Pose2Pose2()
3736

38-
39-
# Assumes X is a tangent vector
40-
function (cf::CalcFactor{<:Pose2Pose2})(_X::AbstractArray{MT}, _p::AbstractArray{PT}, _q::AbstractArray{LT}) where {MT,PT,LT}
41-
#TODO remove this convertions
42-
# @warn "This warning should not be triggered after StaticArrays upgrade" maxlog=10
43-
T = promote_type(MT, PT, LT)
44-
X = convert(ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}, _X)
45-
p = convert(ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}, _p)
46-
q = convert(ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}, _q)
47-
return cf(X,p,q)
48-
end
49-
50-
# function calcPose2Pose2(
51-
function (cf::CalcFactor{<:Pose2Pose2})(
52-
X::ArrayPartition{XT, Tuple{SVector{2, XT}, SMatrix{2, 2, XT, 4}}},
53-
p::ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}},
54-
q::ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}) where {XT<:Real,T<:Real}
55-
56-
M = getManifold(Pose2)
57-
# ϵ0 = ArrayPartition(zeros(SVector{2,T}), SMatrix{2, 2, T}(I))
58-
ϵ0 = getPointIdentity(M)
59-
60-
ϵX = exp(M, ϵ0, X)
61-
# q̂ = Manifolds.compose(M, p, ϵX)
62-
= _compose(M, p, ϵX)
63-
X_hat = log(M, q, q̂)#::ArrayPartition{T, Tuple{SVector{2, T}, SMatrix{2, 2, T, 4}}}
64-
# Xc = vee(M, q, X_hat)
65-
Xc = _vee(M, X_hat)#::SVector{3,T}
66-
return Xc
37+
function (cf::CalcFactor{<:Pose2Pose2})(X, p, q)
38+
G = getManifold(Pose2)
39+
= log(base_manifold(G), getPointIdentity(G), compose(G, inv(G, p), q))
40+
return vee(LieAlgebra(G), X - X̂)
6741
end
6842

69-
7043
# NOTE, serialization support -- will be reduced to macro in future
7144
# ------------------------------------
7245

7346
"""
7447
$(TYPEDEF)
7548
"""
76-
Base.@kwdef struct PackedPose2Pose2 <: AbstractPackedFactor
49+
Base.@kwdef struct PackedPose2Pose2 <: AbstractPackedFactor
7750
Z::PackedSamplableBelief
7851
end
7952
function convert(::Type{Pose2Pose2}, d::PackedPose2Pose2)
@@ -85,7 +58,7 @@ end
8558

8659

8760
# FIXME, rather have separate compareDensity functions
88-
function compare(a::Pose2Pose2,b::Pose2Pose2; tol::Float64=1e-10)
61+
function compare(a::Pose2Pose2, b::Pose2Pose2; tol::Float64=1e-10)
8962
return compareDensity(a.Z, b.Z)
9063
end
9164

src/variables/VariableTypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $(TYPEDEF)
3232
3333
Pose2 is a SE(2) mechanization of two Euclidean translations and one Circular rotation, used for general 2D SLAM.
3434
"""
35-
@defVariable Pose2 SpecialEuclidean(2; vectors=HybridTangentRepresentation()) ArrayPartition(SA[0;0.0],SA[1 0; 0 1.0])
35+
@defVariable Pose2 SpecialEuclideanGroup(2; variant=:right) ArrayPartition(SA[0;0.0],SA[1 0; 0 1.0])
3636

3737
"""
3838
$(TYPEDEF)

0 commit comments

Comments
 (0)