Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametric Point2Point2Range #398

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/factors/Range2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ function (cfo::CalcFactor{<:Point2Point2Range})(rho, theta, xi, lm)
#
XX = lm[1] - (rho[1]*cos(theta[1]) + xi[1])
YY = lm[2] - (rho[1]*sin(theta[1]) + xi[2])
#TODO JT - Should this have a sqrt for parametric?
# return XX^2 + YY^2
return sqrt(XX^2 + YY^2)
end

#Parametric only function fro Point2Point2Range
function (cfo::CalcFactor{<:Point2Point2Range})(rho, xi, lm)
# Basically `EuclidDistance`
return [rho[1] - norm(lm .- xi)]
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, understand now. Best solution would be to drop the additional theta variable, but we should look at how best to do together with the Manifolds.jl upgrade -- lots of overlap.

Copy link
Member

@dehann dehann Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never liked the additional theta thing. Perhaps the solution is just to skip immediately through to JuliaRobotics/IncrementalInference.jl#1051

and then we can drop the additional theta value since the inflated (high entropy) proposal will give the necessary spread.


passTypeThrough(d::FunctionNodeData{Point2Point2Range}) = d

Expand Down
27 changes: 27 additions & 0 deletions test/testParametric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,30 @@ vardict, result, varIds, Σ = IIF.solveFactorGraphParametric!(fg)
@test isapprox(vardict[:x1].val, [10, 0, 0, 10, 0], atol = 1e-3)

end


@testset "Test Parametric PriorPoint2 and Point2Point2Range" begin
fg = LightDFG( solverParams=SolverParams(algorithms=[:default, :parametric]))

addVariable!(fg, :x1, Point2)
addVariable!(fg, :l1, Point2)
addVariable!(fg, :l2, Point2)
addVariable!(fg, :l3, Point2)

addFactor!(fg, [:l1], PriorPoint2(MvNormal([0., 0], [0.01, 0.01])))
addFactor!(fg, [:l2], PriorPoint2(MvNormal([1., 0], [0.01, 0.01])))
addFactor!(fg, [:l3], PriorPoint2(MvNormal([0., 1], [0.01, 0.01])))

addFactor!(fg, [:x1; :l1], Point2Point2Range(Normal(sqrt(2), 0.1)))
addFactor!(fg, [:x1; :l2], Point2Point2Range(Normal(1.0, 0.1)))
addFactor!(fg, [:x1; :l3], Point2Point2Range(Normal(1.0, 0.1)))

ensureAllInitialized!(fg)

IIF.initParametricFrom!(fg)

vardict, result, varIds, Σ = IIF.solveFactorGraphParametric(fg) #autodiff=:finite)

@test isapprox(vardict[:x1].val, [1, 1], atol = 1e-3)

end