Skip to content

Commit

Permalink
Merge pull request #142 from JuliaRobotics/maintenance/adjusttesttol
Browse files Browse the repository at this point in the history
relax partial test slightly
  • Loading branch information
dehann authored Nov 13, 2018
2 parents 7205b96 + 5e015ea commit d96f493
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
21 changes: 14 additions & 7 deletions src/PartialPose3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,25 @@ function convert(::Type{Dict{String, Any}}, fact::RoME.PartialPriorRollPitchZ)
return pf
end


function compare(a::Normal, b::Normal; tol::Float64=1e-10)
TP = true
TP = TP && abs(a.μ - b.μ) < tol
TP = TP && abs(a.σ - b.σ) < tol
TP
end

function compare(a::PartialPriorRollPitchZ, b::PartialPriorRollPitchZ; tol::Float64=1e-10)
TP = true
TP = TP && compare(a.rp, b.rp) < tol
TP = TP && compare(a.z, b.z) < tol
TP = TP && compare(a.rp, b.rp)
TP = TP && compare(a.z, b.z)
TP = TP && norm(collect(a.partial)-collect(b.partial)) < tol
return TP
end





# Partial pairwise constraint between poses X,Y,Yaw
# ------------------------------------------------------------------------------

Expand Down Expand Up @@ -99,13 +106,13 @@ mutable struct PackedPartialPose3XYYaw <: IncrementalInference.PackedInferenceTy
xydata::String
yawdata::String
PackedPartialPose3XYYaw() = new()
PackedPartialPose3XYYaw(xy::Vector{Float64}, yaw::Array{Float64}) = new(x1, x2[:])
PackedPartialPose3XYYaw(xy::String, yaw::String) = new(xy, yaw)
end
function convert(::Type{PartialPose3XYYaw}, d::PackedPartialPose3XYYaw)
return PartialPose3XYYaw( extractdistribution(d.xydata), extractdistribution(d.yawdata) )
end
function convert(::Type{PackedPartialPose3XYYaw}, d::PartialPose3XYYaw)
return PackedPartialPose3XYYaw( d.xy, d.yaw )
return PackedPartialPose3XYYaw( string(d.xy), string(d.yaw) )
end

"""
Expand Down Expand Up @@ -136,8 +143,8 @@ end

function compare(a::PartialPose3XYYaw, b::PartialPose3XYYaw; tol::Float64=1e-10)
TP = true
TP = TP && norm(a.xyy.μ-b.xyy.μ) < tol
TP = TP && norm(a.xyy.Σ.mat[:]-b.xyy.Σ.mat[:]) < tol
TP = TP && compare(a.xy, b.xy)
TP = TP && compare(a.yaw, b.yaw)
TP = TP && norm(collect(a.partial)-collect(b.partial)) < tol
return TP
end
Expand Down
7 changes: 5 additions & 2 deletions test/testpackingconverters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@ end
end



@testset "test conversions of PartialPose3XYYaw" begin
global xyy = PartialPose3XYYaw(MvNormal([1.0;2.0;0.5],0.1*Matrix{Float64}(LinearAlgebra.I, 3,3)))
global xyy = PartialPose3XYYaw(
MvNormal( [1.0;2.0],
0.1*Matrix{Float64}(LinearAlgebra.I, 2,2) ),
Normal(0.5, 0.1)
)

global pxyy = convert(PackedPartialPose3XYYaw, xyy)
global unp = convert(PartialPose3XYYaw, pxyy)
Expand Down
2 changes: 1 addition & 1 deletion test/testpartialpose3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end
@test 0.0 < norm(res) < 0.3

global meas = getSample(xyy,100)
@test norm(Statistics.std(meas[1],dims=2) - [0.01;0.01;0.002]) < 0.01
@test norm(Statistics.std(meas[1],dims=2) - [0.01;0.01;0.002]) < 0.05

end

Expand Down

0 comments on commit d96f493

Please sign in to comment.