Skip to content

Commit f8b22ef

Browse files
authored
Merge pull request #1339 from JuliaRobotics/21Q3/fix/identity
Fix identity to identity_element for Manifolds 0.6
2 parents c7c6081 + 70db4ab commit f8b22ef

File tree

10 files changed

+19
-67
lines changed

10 files changed

+19
-67
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
4343
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
4444

4545
[compat]
46-
ApproxManifoldProducts = "0.4.12"
46+
ApproxManifoldProducts = "0.4.13"
4747
BSON = "0.2, 0.3"
4848
Combinatorics = "1.0"
4949
DataStructures = "0.16, 0.17, 0.18"
@@ -55,7 +55,7 @@ FunctionalStateMachine = "0.2.9"
5555
JLD2 = "0.3, 0.4"
5656
JSON2 = "0.3"
5757
KernelDensityEstimate = "0.5.6"
58-
Manifolds = "0.5"
58+
Manifolds = "0.6"
5959
ManifoldsBase = "0.11, 0.12"
6060
MetaGraphs = "0.6.4"
6161
NLSolversBase = "7.6"

examples/dev/factors_sandbox.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function grad_PointPoint_distance(M, m, p, q)
1616
end
1717

1818
function PointPoint_distance(M, X, p, q, ::MeasurementOnTangent)
19-
= compose(M, p, exp(M, identity(M, p), X))
19+
= compose(M, p, exp(M, identity_element(M, p), X))
2020
return distance(M, q, q̂)
2121
end
2222

src/Factors/GenericFunctions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515

1616
#::MeasurementOnTangent
1717
function distanceTangent2Point(M::AbstractGroupManifold, X, p, q)
18-
= compose(M, p, exp(M, identity(M, p), X)) #for groups
18+
= compose(M, p, exp(M, identity_element(M, p), X)) #for groups
1919
# return log(M, q, q̂)
2020
return vee(M, q, log(M, q, q̂))
2121
# return distance(M, q, q̂)
@@ -53,7 +53,7 @@ end
5353
function default_identity(M::GroupManifold{ℝ, <:AbstractManifold})
5454
T = Float64
5555
s = representation_size(M)
56-
return identity(M, zeros(SArray{Tuple{s...},T}))
56+
return identity_element(M, zeros(SArray{Tuple{s...},T}))
5757
end
5858

5959
# function default_identity(::SpecialOrthogonal{N}) where N
@@ -113,7 +113,7 @@ DFG.getManifold(f::ManifoldPrior) = f.M
113113

114114
#TODO
115115
# function ManifoldPrior(M::AbstractGroupManifold, Z::SamplableBelief)
116-
# # p = identity(M, #TOOD)
116+
# # p = identity_element(M, #TOOD)
117117
# # similar to getPointIdentity(M)
118118
# return ManifoldPrior(M, Z, p)
119119
# end

src/Factors/Mixture.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function getSample( cf::CalcFactor{<:Mixture},
8787
for i in 1:N
8888
mixComponent = cf.factor.components[cf.factor.labels[i]]
8989
# measurements relate to the factor's manifold (either tangent vector or manifold point)
90-
_setPointsMani!(smpls[1][i], randToPoints(mixComponent,1)[1])
90+
setPointsMani!(smpls[1][i], randToPoints(mixComponent,1)[1])
9191
end
9292

9393
# TODO only does first element of meas::Tuple at this stage, see #1099

src/NumericalCalculations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function _solveLambdaNumeric( fcttype::Union{F,<:Mixture{N_,F,S,T}},
8585
# the variable is a manifold point, we are working on the tangent plane in optim for now.
8686
#
8787
#TODO this is not general to all manifolds, should work for lie groups.
88-
# ϵ = identity(M, u0)
88+
# ϵ = identity_element(M, u0)
8989
ϵ = getPointIdentity(variableType)
9090
# X0c = get_coordinates(M, u0, log(M, ϵ, u0), DefaultOrthogonalBasis())
9191
X0c = vee(M, u0, log(M, ϵ, u0))

src/SolverUtilities.jl

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,6 @@ randToPoints(distr::SamplableBelief, N::Int=1) = [rand(distr,1)[:] for i in 1:N]
2222
randToPoints(distr::ManifoldKernelDensity, N::Int=1) = rand(distr,N)
2323

2424

25-
_setPointsMani!(dest::AbstractVector, src::AbstractVector) = (dest .= src)
26-
_setPointsMani!(dest::AbstractMatrix, src::AbstractMatrix) = (dest .= src)
27-
function _setPointsMani!(dest::AbstractVector, src::AbstractMatrix)
28-
@assert size(src,2) == 1 "Workaround _setPointsMani! currently only allows size(::Matrix, 2) == 1"
29-
_setPointsMani!(dest, src[:])
30-
end
31-
function _setPointsMani!(dest::AbstractMatrix, src::AbstractVector)
32-
@assert size(dest,2) == 1 "Workaround _setPointsMani! currently only allows size(::Matrix, 2) == 1"
33-
_setPointsMani!(view(dest,:,1), src)
34-
end
35-
36-
function _setPointsMani!(dest::AbstractVector, src::AbstractVector{<:AbstractVector})
37-
@assert length(src) == 1 "Workaround _setPointsMani! currently only allows Vector{Vector{P}}(...) |> length == 1"
38-
_setPointsMani!(dest, src[1])
39-
end
40-
41-
function _setPointsMani!(dest::ProductRepr, src::ProductRepr)
42-
for (k,prt) in enumerate(dest.parts)
43-
_setPointsMani!(prt, src.parts[k])
44-
end
45-
end
46-
47-
# asPartial=true indicates that src coords are smaller than dest coords, and false implying src has dummy values in placeholder dimensions
48-
function _setPointsManiPartial!(Mdest::AbstractManifold,
49-
dest,
50-
Msrc::AbstractManifold,
51-
src,
52-
partial::AbstractVector{<:Integer},
53-
asPartial::Bool=true )
54-
#
55-
56-
e0 = identity(Mdest, dest)
57-
dest_ = vee(Mdest, e0, log(Mdest, e0, dest))
58-
59-
e0s = identity(Msrc, src)
60-
src_ = vee(Msrc, e0s, log(Msrc, e0s, src))
61-
62-
# do the copy in coords
63-
dest_[partial] .= asPartial ? src_ : view(src_, partial)
64-
65-
# update points base in original
66-
dest__ = exp(Mdest, e0, hat(Mdest, e0, dest_))
67-
_setPointsMani!(dest, dest__)
68-
69-
#
70-
return dest
71-
end
72-
73-
7425

7526
"""
7627
$TYPEDSIGNATURES
@@ -79,10 +30,11 @@ Calculate the Kernel Embedding MMD 'distance' between sample points (or kernel d
7930
8031
Notes
8132
- `bw::Vector=[0.001;]` controls the mmd kernel bandwidths.
33+
- Overloading from ApproxManifoldProducts
8234
8335
Related
8436
85-
`KDE.kld`
37+
`AMP.kld`
8638
"""
8739
function mmd( p1::AbstractVector{P1},
8840
p2::AbstractVector{P2},

src/Variables/DefaultVariables.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DFG.getDimension(val::InstanceType{ContinuousEuclid{N}}) where N = manifold_dime
4343
# DFG.getDimension(val::ContinuousEuclid{N}) where N = manifold_dimension(getManifold(val))
4444

4545
DFG.getPointType(::Type{ContinuousEuclid{N}}) where N = Vector{Float64}
46-
DFG.getPointIdentity(M_::Type{ContinuousEuclid{N}}) where N = zeros(N) # identity(getManifold(M_), zeros(N))
46+
DFG.getPointIdentity(M_::Type{ContinuousEuclid{N}}) where N = zeros(N) # identity_element(getManifold(M_), zeros(N))
4747

4848

4949
Base.convert(::Type{<:ManifoldsBase.AbstractManifold}, ::InstanceType{ContinuousEuclid{N}}) where N = TranslationGroup(N)

src/services/EvalFactor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function evalPotentialSpecific( Xi::AbstractVector{<:DFGVariable},
364364
for m in (1:length(addEntr))[ahmask]
365365
# FIXME, selection for all measurement::Tuple elements
366366
# @info "check broadcast" ccwl.usrfnc! addEntr[m] ccwl.measurement[1][m]
367-
_setPointsMani!(addEntr[m], ccwl.measurement[1][m])
367+
setPointsMani!(addEntr[m], ccwl.measurement[1][m])
368368
end
369369
# ongoing part of RoME.jl #244
370370
addEntropyOnManifold!(mani, addEntrNH, 1:getDimension(mani), spreadDist)
@@ -380,7 +380,7 @@ function evalPotentialSpecific( Xi::AbstractVector{<:DFGVariable},
380380
# FIXME, need ability to replace partial points
381381
partialCoords = ccwl.partialDims
382382
Msrc, = getManifoldPartial(mani,partialCoords)
383-
_setPointsManiPartial!(mani, addEntr[m], Msrc, ccwl.measurement[1][m], partialCoords)
383+
setPointsManiPartial!(mani, addEntr[m], Msrc, ccwl.measurement[1][m], partialCoords)
384384
# addEntr[m][dimnum] = ccwl.measurement[1][m][i]
385385
# end
386386
end

src/services/FactorGradients.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ end
108108
getCoordSizes(fgc::FactorGradientsCached!) = fgc._coord_sizes
109109

110110

111-
_setFGCSlack!(fgc::FactorGradientsCached!{F}, slack) where F = _setPointsMani!(fgc.slack_residual, slack)
111+
_setFGCSlack!(fgc::FactorGradientsCached!{F}, slack) where F = setPointsMani!(fgc.slack_residual, slack)
112112

113113
function _setFGCSlack!(fgc::FactorGradientsCached!{F,S}, slack::Number) where {F,S<:Number}
114114
fgc.slack_residual = slack
@@ -121,7 +121,7 @@ function (fgc::FactorGradientsCached!)(meas_pts...)
121121

122122
# update in-place the new measurement value in preparation for new gradient calculation
123123
for (m, tup_m) in enumerate(fgc.measurement)
124-
_setPointsMani!(tup_m, meas_pts[m])
124+
setPointsMani!(tup_m, meas_pts[m])
125125
end
126126

127127
# update the residual _slack in preparation for new gradient calculation
@@ -132,12 +132,12 @@ function (fgc::FactorGradientsCached!)(meas_pts...)
132132
new_slack = calcFactorResidualTemporary(fct, varTypes, measurement, pts; tfg=fgc._tfg)
133133
# TODO make sure slack_residual is properly wired up with all the lambda functions as expected
134134
_setFGCSlack!(fgc, new_slack)
135-
# _setPointsMani!(fgc.slack_residual, new_slack)
135+
# setPointsMani!(fgc.slack_residual, new_slack)
136136

137137
# set new points in preparation for new gradient calculation
138138
for (s,pt) in enumerate(meas_pts[(lenm+1):end])
139139
# update the local memory in fgc to take the values of incoming `pts`
140-
_setPointsMani!(fgc.currentPoints[s], pt)
140+
setPointsMani!(fgc.currentPoints[s], pt)
141141
end
142142

143143
# update the gradients at new values contained in fgc

test/testSpecialEuclidean2Mani.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ DFG.getManifold(::ManiPose2Point2) = TranslationGroup(2)
165165
function (cfo::CalcFactor{<:ManiPose2Point2})(measX, p, q)
166166
#
167167
M = SpecialEuclidean(2)
168-
q_SE = ProductRepr(q, identity(SpecialOrthogonal(2), p.parts[2]))
168+
q_SE = ProductRepr(q, identity_element(SpecialOrthogonal(2), p.parts[2]))
169169

170-
X_se2 = log(M, identity(M, p), compose(M, inv(M, p), q_SE))
170+
X_se2 = log(M, identity_element(M, p), compose(M, inv(M, p), q_SE))
171171
X = X_se2.parts[1]
172172
# NOTE wrong for what we want X̂ = log(M, p, q_SE)
173173
return measX - X

0 commit comments

Comments
 (0)