Skip to content

Commit

Permalink
Merge pull request #247 from JuliaRobotics/23Q3/enh/legacyN
Browse files Browse the repository at this point in the history
legacy fixes
  • Loading branch information
dehann committed Sep 16, 2023
2 parents 3c0132b + c5482c8 commit bd5c45c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/Interface.jl
Expand Up @@ -183,19 +183,21 @@ function Base.replace( dest::ManifoldKernelDensity{M,<:BallTreeDensity,Nothing},
) where {M<:AbstractManifold}
#
pl = src._partial
oldPts = getPoints(dest.belief)
# FIXME what about
destPts = getPoints(dest.belief)
# get source partial points only
newPts = getPoints(src.belief)
@assert size(newPts,2) == size(oldPts,2) "this replace currently requires the number of points to be the same, dest=$(size(oldPts,2)), src=$(size(newPts,2))"
for i in 1:size(oldPts, 2)
oldPts[pl,i] .= newPts[pl,i]
@assert size(destPts,2) <= size(newPts,2) "MKD replace currently requires the number of points to be the same, dest=$(size(destPts,2)), src=$(size(newPts,2))"
# TODO use eachindex or axes instead of 1:size
for i in 1:size(destPts, 2)
destPts[pl,i] .= newPts[pl,i]
end
# and new bandwidth
oldBw = getBW(dest.belief)[:,1]
oldBw[pl] .= getBW(src.belief)[pl,1]

# finaly update the belief with a new container
newBel = kde!(oldPts, oldBw)
newBel = kde!(destPts, oldBw)

# also set the metadata values
ipc = deepcopy(dest.infoPerCoord)
Expand All @@ -218,19 +220,19 @@ function Base.replace(dest::ManifoldKernelDensity{M,<:BallTreeDensity,<:Abstract
) where {M<:AbstractManifold}
#
pl = src._partial
oldPts = getPoints(dest.belief)
destPts = getPoints(dest.belief)
# get source partial points only
newPts = getPoints(src.belief)
@assert size(newPts,2) == size(oldPts,2) "this replace currently requires the number of points to be the same, dest=$(size(oldPts,2)), src=$(size(newPts,2))"
for i in 1:size(oldPts, 2)
oldPts[pl,i] .= newPts[pl,i]
@assert size(newPts,2) == size(destPts,2) "this replace currently requires the number of points to be the same, dest=$(size(destPts,2)), src=$(size(newPts,2))"
for i in 1:size(destPts, 2)
destPts[pl,i] .= newPts[pl,i]
end
# and new bandwidth
oldBw = getBW(dest.belief)[:,1]
oldBw[pl] .= getBW(src.belief)[pl,1]

# finaly update the belief with a new container
newBel = kde!(oldPts, oldBw)
newBel = kde!(destPts, oldBw)

# also set the metadata values
ipc = deepcopy(dest.infoPerCoord)
Expand Down
8 changes: 5 additions & 3 deletions src/Legacy.jl
Expand Up @@ -66,16 +66,18 @@ Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Euclid3)}) = (:Euclid,:Euclid,:Eu
Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Euclid4)}) = (:Euclid,:Euclid,:Euclid,:Euclid)
Base.convert(::Type{<:Tuple}, ::Type{<: typeof(SE2_Manifold)}) = (:Euclid,:Euclid,:Circular)
Base.convert(::Type{<:Tuple}, ::Type{<: typeof(SE3_Manifold)}) = (:Euclid,:Euclid,:Euclid,:Circular,:Circular,:Circular)
Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Manifolds.SpecialOrthogonal(2))}) = (:Circular,)
Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Manifolds.SpecialOrthogonal(3))}) = (:Circular,:Circular,:Circular)

# Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Manifolds.SpecialOrthogonal(2))}) = (:Circular,)
# Base.convert(::Type{<:Tuple}, ::Type{<: typeof(Manifolds.SpecialOrthogonal(3))}) = (:Circular,:Circular,:Circular)
Base.convert(::Type{<:Tuple}, ::typeof(Manifolds.SpecialOrthogonal(2))) = (:Circular,)
Base.convert(::Type{<:Tuple}, ::typeof(Manifolds.SpecialOrthogonal(3))) = (:Circular,:Circular,:Circular)

Base.convert(::Type{<:Tuple}, ::typeof(Euclid)) = (:Euclid,)
Base.convert(::Type{<:Tuple}, ::typeof(Euclid2)) = (:Euclid,:Euclid)
Base.convert(::Type{<:Tuple}, ::typeof(Euclid3)) = (:Euclid,:Euclid,:Euclid)
Base.convert(::Type{<:Tuple}, ::typeof(Euclid4)) = (:Euclid,:Euclid,:Euclid,:Euclid)
Base.convert(::Type{<:Tuple}, ::typeof(SE2_Manifold)) = (:Euclid,:Euclid,:Circular)
Base.convert(::Type{<:Tuple}, ::typeof(SE3_Manifold)) = (:Euclid,:Euclid,:Euclid,:Circular,:Circular,:Circular)
Base.convert(::Type{<:Tuple}, ::typeof(Manifolds.SpecialOrthogonal(3))) = (:Circular,:Circular,:Circular)

"""
$(SIGNATURES)
Expand Down

0 comments on commit bd5c45c

Please sign in to comment.