Skip to content

Commit

Permalink
Merge pull request #123 from JuliaRobotics/maintenance/prep018
Browse files Browse the repository at this point in the history
Maintenance/prep018
  • Loading branch information
dehann committed Oct 2, 2018
2 parents 608dc79 + eb7c807 commit 82bad93
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 68 deletions.
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.6
IncrementalInference 0.3.8 0.3.9
julia 0.6 0.7
IncrementalInference 0.3.9 0.4.0
Graphs 0.9.0
TransformUtils 0.0.6
CoordinateTransformations 0.5.0
Expand Down
14 changes: 7 additions & 7 deletions src/BearingRange2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
mutable struct Pose2Point2Range{T} <: IncrementalInference.FunctorPairwise
Z::T
Pose2Point2Range{T}() where T = new()
Pose2Point2Range{T}(Z::T) where {T <: SamplableBelief} = new{T}(Z)
Pose2Point2Range{T}(Z::T) where {T <: IIF.SamplableBelief} = new{T}(Z)
end
Pose2Point2Range(Z::T) where {T <: SamplableBelief} = Pose2Point2Range{T}(Z)
Pose2Point2Range(Z::T) where {T <: IIF.SamplableBelief} = Pose2Point2Range{T}(Z)

function getSample(pp2::Pose2Point2Range, N::Int=1)
return (reshape(rand(pp2.Z,N),1,N) , 2*pi*rand(N))
Expand All @@ -31,13 +31,13 @@ end
# bearing and range available


mutable struct Pose2Point2BearingRange{B <: SamplableBelief, R <: SamplableBelief} <: IncrementalInference.FunctorPairwise
mutable struct Pose2Point2BearingRange{B <: IIF.SamplableBelief, R <: IIF.SamplableBelief} <: IncrementalInference.FunctorPairwise
bearing::B
range::R
Pose2Point2BearingRange{B,R}() where {B,R} = new{B,R}()
Pose2Point2BearingRange{B,R}(x1::B,x2::R) where {B <: SamplableBelief,R <: SamplableBelief} = new{B,R}(x1,x2)
Pose2Point2BearingRange{B,R}(x1::B,x2::R) where {B <: IIF.SamplableBelief,R <: IIF.SamplableBelief} = new{B,R}(x1,x2)
end
Pose2Point2BearingRange(x1::B,x2::R) where {B <: SamplableBelief,R <: SamplableBelief} = Pose2Point2BearingRange{B,R}(x1,x2)
Pose2Point2BearingRange(x1::B,x2::R) where {B <: IIF.SamplableBelief,R <: IIF.SamplableBelief} = Pose2Point2BearingRange{B,R}(x1,x2)
function getSample(pp2br::Pose2Point2BearingRange, N::Int=1)
smpls = zeros(2, N)
smpls[1,:] = rand(pp2br.bearing, N)[:]
Expand Down Expand Up @@ -71,13 +71,13 @@ mutable struct PackedPose2Point2BearingRange <: IncrementalInference.PackedInfer
PackedPose2Point2BearingRange(s1::AS, s2::AS) where {AS <: AbstractString} = new(string(s1),string(s2))
end

function convert(::Type{PackedPose2Point2BearingRange}, d::Pose2Point2BearingRange{B, R}) where {B <: SamplableBelief, R <: SamplableBelief}
function convert(::Type{PackedPose2Point2BearingRange}, d::Pose2Point2BearingRange{B, R}) where {B <: IIF.SamplableBelief, R <: IIF.SamplableBelief}
return PackedPose2Point2BearingRange(string(d.bearing), string(d.range))
end

# TODO -- should not be resorting to string, consider specialized code for parametric distribution types and KDEs
function convert(::Type{Pose2Point2BearingRange}, d::PackedPose2Point2BearingRange)
# where {B <: SamplableBelief, R <: SamplableBelief}
# where {B <: IIF.SamplableBelief, R <: IIF.SamplableBelief}
Pose2Point2BearingRange(extractdistribution(d.bearstr), extractdistribution(d.rangstr))
end

Expand Down
4 changes: 2 additions & 2 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# old type interfaces

function Point2DPoint2DRange(mu,stdev,w)
warn("Point2DPoint2DRange deprecated in favor of Point2Point2Range{<:SamplableBelief}.")
warn("Point2DPoint2DRange deprecated in favor of Point2Point2Range{<:IIF.SamplableBelief}.")
Point2Point2Range{Normal}(Normal(mu,stdev))
end
function Point2DPoint2D(d::D) where {D <: SamplableBelief}
function Point2DPoint2D(d::D) where {D <: IIF.SamplableBelief}
warn("Point2DPoint2D deprecated in favor of Point2Point2{<:Distribution}.")
Point2Point2{D}(d)
end
Expand Down
32 changes: 16 additions & 16 deletions src/DynPose2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@



mutable struct DynPose2VelocityPrior{T1,T2} <: IncrementalInference.FunctorSingleton where {T1 <: SamplableBelief,T2 <: SamplableBelief}
mutable struct DynPose2VelocityPrior{T1,T2} <: IncrementalInference.FunctorSingleton where {T1 <: IIF.SamplableBelief,T2 <: IIF.SamplableBelief}
Zpose::T1
Zvel::T2
DynPose2VelocityPrior{T1,T2}() where {T1 <: SamplableBelief,T2 <: SamplableBelief} = new{T1,T2}()
DynPose2VelocityPrior{T1,T2}(z1::T1,z2::T2) where {T1 <: SamplableBelief,T2 <: SamplableBelief} = new{T1,T2}(z1,z2)
DynPose2VelocityPrior{T1,T2}() where {T1 <: IIF.SamplableBelief,T2 <: IIF.SamplableBelief} = new{T1,T2}()
DynPose2VelocityPrior{T1,T2}(z1::T1,z2::T2) where {T1 <: IIF.SamplableBelief,T2 <: IIF.SamplableBelief} = new{T1,T2}(z1,z2)
end
DynPose2VelocityPrior(z1::T1,z2::T2) where {T1 <: SamplableBelief, T2 <: SamplableBelief} = DynPose2VelocityPrior{T1,T2}(z1,z2)
getSample(dp2v::DynPose2VelocityPrior{T1,T2}, N::Int=1) where {T1 <: SamplableBelief, T2 <: SamplableBelief} = ([rand(dp2v.Zpose,N);rand(dp2v.Zvel,N)], )
DynPose2VelocityPrior(z1::T1,z2::T2) where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief} = DynPose2VelocityPrior{T1,T2}(z1,z2)
getSample(dp2v::DynPose2VelocityPrior{T1,T2}, N::Int=1) where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief} = ([rand(dp2v.Zpose,N);rand(dp2v.Zvel,N)], )



Expand All @@ -25,22 +25,22 @@ end



mutable struct VelPose2VelPose2{T1,T2} <: IncrementalInference.FunctorPairwiseMinimize where {T1 <: SamplableBelief, T2 <: SamplableBelief}
mutable struct VelPose2VelPose2{T1,T2} <: IncrementalInference.FunctorPairwiseMinimize where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief}
Zpose::Pose2Pose2{T1} #Zpose::T1
Zvel::T2
reuseres::Vector{Vector{Float64}}
VelPose2VelPose2{T1,T2}() where {T1 <: SamplableBelief, T2 <: SamplableBelief} = new{T1,T2}()
VelPose2VelPose2{T1,T2}(z1::T1, z2::T2) where {T1 <: SamplableBelief, T2 <: SamplableBelief} = new{T1,T2}(Pose2Pose2(z1),z2,[zeros(3) for i in 1:Threads.nthreads()])
VelPose2VelPose2{T1,T2}() where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief} = new{T1,T2}()
VelPose2VelPose2{T1,T2}(z1::T1, z2::T2) where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief} = new{T1,T2}(Pose2Pose2(z1),z2,[zeros(3) for i in 1:Threads.nthreads()])
end
VelPose2VelPose2(z1::T1, z2::T2) where {T1 <: SamplableBelief, T2 <: SamplableBelief} = VelPose2VelPose2{T1,T2}(z1, z2)
VelPose2VelPose2(z1::T1, z2::T2) where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief} = VelPose2VelPose2{T1,T2}(z1, z2)
getSample(vp2vp2::VelPose2VelPose2, N::Int=1) = ([rand(vp2vp2.Zpose.z,N);rand(vp2vp2.Zvel,N)], )
function (vp2vp2::VelPose2VelPose2{T1,T2})(
res::Array{Float64},
userdata::FactorMetadata,
idx::Int,
meas::Tuple,
Xi::Array{Float64,2},
Xj::Array{Float64,2} ) where {T1 <: SamplableBelief, T2 <: SamplableBelief}
Xj::Array{Float64,2} ) where {T1 <: IIF.SamplableBelief, T2 <: IIF.SamplableBelief}
#
z = meas[1][:,idx]
wxi, wxj = Xi[:,idx], Xj[:,idx]
Expand All @@ -58,29 +58,29 @@ function (vp2vp2::VelPose2VelPose2{T1,T2})(
res[1]
end

# import RoME: VelPose2VelPose2, SamplableBelief
# import RoME: VelPose2VelPose2, IIF.SamplableBelief
# import IncrementalInference: FactorMetadata





mutable struct DynPose2Pose2{T} <: IncrementalInference.FunctorPairwise where {T <: SamplableBelief}
mutable struct DynPose2Pose2{T} <: IncrementalInference.FunctorPairwise where {T <: IIF.SamplableBelief}
Zpose::Pose2Pose2{T} #Zpose::T1
# reuseres::Vector{Float64}
partial::Tuple
DynPose2Pose2{T}() where {T <: SamplableBelief} = new{T}()
DynPose2Pose2{T}(z1::T) where {T <: SamplableBelief} = new{T}(Pose2Pose2(z1), (1,2,3))
DynPose2Pose2{T}() where {T <: IIF.SamplableBelief} = new{T}()
DynPose2Pose2{T}(z1::T) where {T <: IIF.SamplableBelief} = new{T}(Pose2Pose2(z1), (1,2,3))
end
DynPose2Pose2(z1::T) where {T <: SamplableBelief} = DynPose2Pose2{T}(z1)
DynPose2Pose2(z1::T) where {T <: IIF.SamplableBelief} = DynPose2Pose2{T}(z1)
getSample(vp2vp2::DynPose2Pose2, N::Int=1) = (rand(vp2vp2.Zpose.z,N), )
function (vp2vp2::DynPose2Pose2{T})(
res::Array{Float64},
userdata::FactorMetadata,
idx::Int,
meas::Tuple,
Xi::Array{Float64,2},
Xj::Array{Float64,2} ) where {T <: SamplableBelief}
Xj::Array{Float64,2} ) where {T <: IIF.SamplableBelief}
#
vp2vp2.Zpose(res, userdata, idx, meas, Xi, Xj)
nothing
Expand Down
18 changes: 9 additions & 9 deletions src/Point2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function getSample(p2::PriorPoint2, N::Int=1)
return (rand(p2.Z, N),)
end

mutable struct Point2Point2Range{D <: SamplableBelief} <: IncrementalInference.FunctorPairwiseMinimize
mutable struct Point2Point2Range{D <: IIF.SamplableBelief} <: IncrementalInference.FunctorPairwiseMinimize
Z::D
Point2Point2Range{D}() where {D} = new{D}()
Point2Point2Range{D}(d::D) where {D <: SamplableBelief} = new{D}(d)
Point2Point2Range{D}(d::D) where {D <: IIF.SamplableBelief} = new{D}(d)
end
Point2Point2Range(d::D) where {D <: SamplableBelief} = Point2Point2Range{D}(d)
function getSample(pp2::Point2Point2Range{T}, N::Int=1) where {T <: SamplableBelief}
Point2Point2Range(d::D) where {D <: IIF.SamplableBelief} = Point2Point2Range{D}(d)
function getSample(pp2::Point2Point2Range{T}, N::Int=1) where {T <: IIF.SamplableBelief}
return (reshape(rand(pp2.Z,N),1,N), 2*pi*rand(N))
end
function (pp2r::Point2Point2Range{T})(
Expand All @@ -36,7 +36,7 @@ function (pp2r::Point2Point2Range{T})(
idx::Int,
meas::Tuple,
xi::Array{Float64,2},
lm::Array{Float64,2} ) where {T <: SamplableBelief}
lm::Array{Float64,2} ) where {T <: IIF.SamplableBelief}
#
z = meas[1][1,idx]
XX = lm[1,idx] - (z*cos(meas[2][idx]) + xi[1,idx])
Expand All @@ -47,7 +47,7 @@ function (pp2r::Point2Point2Range{T})(
end
# import RoME: Point2Point2Range

mutable struct Point2Point2{D <: SamplableBelief} <: FunctorPairwise #BetweenPoses
mutable struct Point2Point2{D <: IIF.SamplableBelief} <: FunctorPairwise #BetweenPoses
Zij::D
Point2Point2{T}() where T = new{T}()
Point2Point2{T}(x::T) where {T <: Sampleable} = new{T}(x)
Expand All @@ -71,14 +71,14 @@ end



mutable struct Point2Point2WorldBearing{T} <: IncrementalInference.FunctorPairwise where {T <: SamplableBelief}
mutable struct Point2Point2WorldBearing{T} <: IncrementalInference.FunctorPairwise where {T <: IIF.SamplableBelief}
Z::T
rangemodel::Rayleigh
# zDim::Tuple{Int, Int}
Point2Point2WorldBearing{T}() where T = new{T}()
Point2Point2WorldBearing{T}(x::T) where {T <: SamplableBelief} = new{T}(x, Rayleigh(100))
Point2Point2WorldBearing{T}(x::T) where {T <: IIF.SamplableBelief} = new{T}(x, Rayleigh(100))
end
Point2Point2WorldBearing(x::T) where {T <: SamplableBelief} = Point2Point2WorldBearing{T}(x)
Point2Point2WorldBearing(x::T) where {T <: IIF.SamplableBelief} = Point2Point2WorldBearing{T}(x)
function getSample(pp2::Point2Point2WorldBearing, N::Int=1)
sp = Array{Float64,2}(2,N)
sp[1,:] = rand(pp2.Z,N)
Expand Down
18 changes: 9 additions & 9 deletions src/Pose2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ end
# getSample(s::Prior, N::Int=1) = (rand(s.z,N), )


mutable struct Pose2Pose2{T} <: IncrementalInference.FunctorPairwise where {T <: SamplableBelief}
mutable struct Pose2Pose2{T} <: IncrementalInference.FunctorPairwise where {T <: IIF.SamplableBelief}
z::T
Pose2Pose2{T}() where {T <: SamplableBelief} = new{T}()
Pose2Pose2{T}(z1::T) where {T <: SamplableBelief} = new{T}(z1)
Pose2Pose2{T}() where {T <: IIF.SamplableBelief} = new{T}()
Pose2Pose2{T}(z1::T) where {T <: IIF.SamplableBelief} = new{T}(z1)
end
Pose2Pose2(z::T) where {T <: SamplableBelief} = Pose2Pose2{T}(z)
Pose2Pose2(z::T) where {T <: IIF.SamplableBelief} = Pose2Pose2{T}(z)
function Pose2Pose2(mean::Array{Float64,1}, cov::Array{Float64,2})
warn("Pose2Pose2(mu,cov) is deprecated in favor of Pose2Pose2(T(...)) -- use for example Pose2Pose2(MvNormal(mu, cov))")
Pose2Pose2(MvNormal(mean, cov))
Expand All @@ -45,8 +45,8 @@ function Pose2Pose2(mean::Array{Float64,1}, cov::Array{Float64,2}, w::Vector{Flo
warn("Pose2Pose2(mu,cov,w) is deprecated in favor of Pose2Pose2(T(...)) -- use for example Pose2Pose2(MvNormal(mu, cov))")
Pose2Pose2(MvNormal(mean, cov))
end
getSample(s::Pose2Pose2{<:SamplableBelief}, N::Int=1) = (rand(s.z,N), )
function (s::Pose2Pose2{<:SamplableBelief})(res::Array{Float64},
getSample(s::Pose2Pose2{<:IIF.SamplableBelief}, N::Int=1) = (rand(s.z,N), )
function (s::Pose2Pose2{<:IIF.SamplableBelief})(res::Array{Float64},
userdata,
idx::Int,
meas::Tuple,
Expand Down Expand Up @@ -119,13 +119,13 @@ end



mutable struct PartialPriorYawPose2{T} <: IncrementalInference.FunctorSingleton where {T <: SamplableBelief}
mutable struct PartialPriorYawPose2{T} <: IncrementalInference.FunctorSingleton where {T <: IIF.SamplableBelief}
Z::T
partial::Tuple
PartialPriorYawPose2{T}() where T = new{T}()
PartialPriorYawPose2{T}(x::T) where {T <: SamplableBelief} = new{T}(x, (3,))
PartialPriorYawPose2{T}(x::T) where {T <: IIF.SamplableBelief} = new{T}(x, (3,))
end
PartialPriorYawPose2(x::T) where {T <: SamplableBelief} = PartialPriorYawPose2{T}(x)
PartialPriorYawPose2(x::T) where {T <: IIF.SamplableBelief} = PartialPriorYawPose2{T}(x)

function getSample(p2::PartialPriorYawPose2, N::Int=1)
return (reshape(rand(p2.Z,N),1,N), )
Expand Down
8 changes: 1 addition & 7 deletions src/RoME.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ export
FactorMetadata,
doautoinit!,
batchSolve!,
# overloaded functions from IIF
# decodefg,
# convertfrompackedfunctionnode,

# RoME specific functions
SamplableBelief, # moved to IIF 0.3.9
# IIF.SamplableBelief, # moved to IIF 0.3.9
initfg,
measureMeanDist,
predictBodyBR,
Expand All @@ -90,9 +87,6 @@ export
\,
RangeAzimuthElevation,

# types
# BetweenPoses,

# helper functions
get2DSamples,
getAll2D,
Expand Down
13 changes: 3 additions & 10 deletions src/SpecialDefinitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
const IIF = IncrementalInference
const KDE = KernelDensityEstimate

@compat const VoidUnion{T} = Union{Void, T}
const VoidUnion{T} = Union{Void, T}

@compat const CTs = CoordinateTransformations
@compat const TUs = TransformUtils
const CTs = CoordinateTransformations
const TUs = TransformUtils


# TODO remove in RoME v0.1.7+, for use with IIF v0.3.9 and beyond
# import IncrementalInference: SamplableBelief
# SamplableBelief = Union{Distributions.Distribution, KernelDensityEstimate.BallTreeDensity, IIF.AliasingScalarSampler}
SamplableBelief = Union{Distributions.Distribution, KernelDensityEstimate.BallTreeDensity}

# @compat abstract type BetweenPoses <: IncrementalInference.FunctorPairwise end


vectoarr2(v) = reshape(v, length(v),1)
11 changes: 5 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ println("[TEST] ensure Pose3Pose3NH evaluations...")
include("testPose3Pose3NH.jl")
println("[SUCCESS]")

warn("temporarily disabling JLD file testing. (for RoME v0.1.7)")
# println("[TEST] saving to and loading from .jld file")
# savejld(fg, file="tempfg.jld" )
# fgu = loadjld( file="tempfg.jld" )
# Base.rm("tempfg.jld")
# println("Success")
println("[TEST] saving to and loading from .jld file")
savejld(fg, file="tempfg.jld" )
fgu = loadjld( file="tempfg.jld" )
Base.rm("tempfg.jld")
println("Success")

println("[TEST] partial pose3 evaluations...")
include("testpartialpose3.jl")
Expand Down

0 comments on commit 82bad93

Please sign in to comment.