Skip to content

Commit 58ed0c3

Browse files
committed
Use LieGroups.MetricLieGroup and other pose related updates
1 parent 2adb03c commit 58ed0c3

6 files changed

Lines changed: 30 additions & 41 deletions

File tree

RoME/examples/Beehive2D.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ plotTreeProductDown(csmcStep19.cliqSubFg, csmcStep19.tree, :x4, :x5)
504504
printCliqHistorySummary(tree, :x3)
505505
csmc = getCliqSolveHistory(tree, :x3)[9][4]
506506

507-
getSolverParams(csmc.dfg).dbg = true
507+
IIF.getCliqueSolverParams(csmc).dbg = true
508508

509509
stuff = sandboxCliqResolveStep(tree, :x3, 9)
510510

RoME/src/canonical/GenerateCircular.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function generateGraph_Circle(
3838
biasTurn::Real = 0.0,
3939
kappaOdo::Real = 1.0,
4040
cyclePoses::Int = poses,
41+
sampleNoise::Bool = false,
4142
)
4243
# assume empty factor graph object fg
4344
@assert offsetPoses < poses "`offsetPoses` must be smaller than total number of `poses`"
@@ -69,10 +70,12 @@ function generateGraph_Circle(
6970
addVariable!(fg, nsym, Pose2)
7071
# TODO rework the addition of noise alongside simulated ground truth, maybe `noise_t_cb`.
7172
pp = Pose2Pose2(
72-
MvNormal(
73-
[10.0; 0; 2pi / (cyclePoses) + biasTurn],
74-
Matrix(Diagonal((kappaOdo * [0.1; 0.1; 0.1]) .^ 2)),
75-
),
73+
let d = MvNormal(
74+
[10.0; 0; 2pi / (cyclePoses) + biasTurn],
75+
Matrix(Diagonal((kappaOdo * [0.1; 0.1; 0.01]) .^ 2)),
76+
)
77+
sampleNoise ? MvNormal(rand(d), d.Σ) : d
78+
end,
7679
)
7780
addFactor!(fg, [psym; nsym], pp; graphinit = graphinit)
7881
end

RoME/src/factors/Pose2D.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ function (cf::CalcFactor{<:Pose2Pose2})(X, p, q)
4040
return vee(M, p, X - X̂) # TODO check sign
4141
end
4242

43+
# An alternative error function that parallel transports the error vector back to p
44+
# function (cf::CalcFactor{<:RobustPose2Pose2})(X, p, q)
45+
# G = getManifold(RobustPose2Pose2)
46+
# q̂ = exp(G, p, X)
47+
# E_q̂ = log(G, q̂, q)
48+
# # Parallel transport the error vector back to p.
49+
# E_p = parallel_transport_to(G, q̂, E_q̂, p)
50+
# return vee(LieAlgebra(G), E_p)
51+
# end
52+
53+
4354
# NOTE, serialization support -- will be reduced to macro in future
4455
# ------------------------------------
4556

RoME/src/factors/Poses.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ function (cf::CalcFactor{<:PriorPose3})(m, p)
2828
return vee(LieAlgebra(M), log(M, p, m))
2929
end
3030

31-
function (cf::CalcFactor{<:Pose3Pose3})(X, p::ArrayPartition{T}, q) where {T}
31+
function (cf::CalcFactor{<:Pose3Pose3})(X, p, q)
32+
# X ∈ TₚM, X̂ ∈ TₚM, p,q ∈ M
3233
M = getManifold(Pose3Pose3)
3334
= log(M, p, q)
34-
Xc::SVector{6, T} = vee(LieAlgebra(M), X - X̂)
35-
return Xc
35+
return vee(LieAlgebra(M), X - X̂)
3636
end
3737

3838
# FIXME, rather have separate compareDensity functions

RoMETypes/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1616
[compat]
1717
DistributedFactorGraphs = "0.27, 0.28.0"
1818
DocStringExtensions = "0.9.3"
19-
LieGroups = "0.1.3"
19+
LieGroups = "0.1.11"
2020
LinearAlgebra = "1.11.0"
2121
Manifolds = "0.10, 0.11"
2222
ManifoldsBase = "1.2.0, 2"

RoMETypes/src/manifolds/SOnxRn_MetricManifold.jl

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
struct MetricLieGroup{
2-
𝔽,
3-
O <: AbstractGroupOperation,
4-
M <: ManifoldsBase.AbstractManifold{𝔽},
5-
L <: LieGroup{𝔽, O, M},
6-
G <: RiemannianMetric,
7-
} <: AbstractLieGroup{𝔽, O, M}
8-
lie_group::L
9-
metric::G
10-
end
11-
12-
ManifoldsBase.base_manifold(G::MetricLieGroup) = G.lie_group
13-
function ManifoldsBase.submanifold_component(G::MetricLieGroup, args...)
14-
return submanifold_component(G.lie_group, args...)
15-
end
16-
function ManifoldsBase.submanifold_components(G::MetricLieGroup, args...)
17-
return submanifold_components(G.lie_group, args...)
18-
end
19-
LieGroups.LieAlgebra(G::MetricLieGroup) = LieAlgebra(base_manifold(G))
20-
LieGroups.inv!(G::MetricLieGroup, args...) = inv!(base_manifold(G), args...)
21-
LieGroups.inv(G::MetricLieGroup, args...) = inv(base_manifold(G), args...)
22-
LieGroups.compose!(G::MetricLieGroup, args...) = compose!(base_manifold(G), args...)
23-
LieGroups.compose(G::MetricLieGroup, args...) = compose(base_manifold(G), args...)
24-
function LieGroups.identity_element(G::MetricLieGroup, args...)
25-
return identity_element(base_manifold(G), args...)
26-
end
27-
function LieGroups.identity_element!(G::MetricLieGroup, args...)
28-
return identity_element!(base_manifold(G), args...)
29-
end
1+
using LieGroups: MetricLieGroup
302

313
# Left Invariant Rigid Body Kinematics Metric CrokeKumar eq 61.
324
# A family of left invariant metrics:
@@ -46,10 +18,13 @@ end
4618
SOnxRn_MetricManifoldType =
4719
Union{typeof(SOnxRn_MetricManifold(2)), typeof(SOnxRn_MetricManifold(3))}
4820

21+
#
22+
LieGroups.LieAlgebra(G::SOnxRn_MetricManifoldType) = LieAlgebra(G.lie_group)
23+
4924
# geodesics for metric (61) are the same as geodesics on the product manifold SO(3)×IR3
5025
function Manifolds.exp(M::SOnxRn_MetricManifoldType, X)
51-
G = base_manifold(M)
52-
ε = identity_element(M, typeof(X))
26+
G = base_lie_group(M)
27+
ε = identity_element(G, typeof(X))
5328
return exp(base_manifold(G), ε, X)
5429
end
5530

@@ -60,7 +35,7 @@ function Manifolds.exp!(M::SOnxRn_MetricManifoldType, g, X)
6035
end
6136

6237
function ManifoldsBase.log(M::SOnxRn_MetricManifoldType, p)
63-
G = base_manifold(M)
38+
G = base_lie_group(M)
6439
# ε = identity_element(G, typeof(p))
6540
# X = log(base_manifold(G), ε, p)
6641
PG = ProductLieGroup(map(LieGroup, G.manifold.manifolds, G.op.operations)...)

0 commit comments

Comments
 (0)