Skip to content

Commit f7347f4

Browse files
authored
Fix Bearing2D bug (#730)
1 parent 57b2b48 commit f7347f4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/factors/Bearing2D.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ preambleCache(::AbstractDFG, ::AbstractVector{<:DFGVariable}, ::Pose2Point2Beari
1919

2020
getManifold(::Pose2Point2Bearing) = SpecialOrthogonal(2)
2121
# Pose2Point2Bearing(x1::B) where {B <: IIF.SamplableBelief} = Pose2Point2Bearing{B}(x1)
22-
# FIXME, there might be something wrong with the sign here
23-
function getSample(cfo::CalcFactor{<:Pose2Point2Bearing})
24-
return rand(cfo.factor.Z)
25-
end
2622

27-
function (cfo::CalcFactor{<:Pose2Point2Bearing})(Xc, p, l)
23+
function (cfo::CalcFactor{<:Pose2Point2Bearing})(X, p, l)
2824
# wl = l
2925
# wTp = p
3026
# pl = pTw*wl
3127
pl = transpose(p.x[2]) * (l - p.x[1])
3228
# δθ = mθ - plθ
33-
δθ = Manifolds.sym_rem(Xc[1] - atan(pl[2], pl[1]))
29+
δθ = Manifolds.sym_rem(X[2] - atan(pl[2], pl[1]))
3430
return [δθ]
3531
end
3632

test/testBearing2D.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ rs = [0, -pi/4, -pi/2, -3pi/4, -pi, 3pi/4, pi/2, pi/4, pi/4, -pi/4]
3434
push!(rs, pi/4 - atan(3,4))
3535

3636
q = [5., 5]
37-
m = [pi/4]
37+
SO2 = SpecialOrthogonal(2)
38+
m = hat(SO2, getPointIdentity(SO2), [pi/4])
3839

3940
f = Pose2Point2Bearing(Normal(pi/4,0.05))
4041

@@ -59,7 +60,9 @@ res = calcFactorResidualTemporary(f, (Pose2, Point2), [], (xi, xj))
5960
f = Pose2Point2Bearing(Normal(pi,0.001))
6061
xi = ArrayPartition([0.,0], [1. 0; 0 1])
6162
xj = [-1, -0.001]
62-
res = calcFactorResidualTemporary(f, (Pose2, Point2), [pi], (xi, xj))
63+
64+
m = hat(SO2, getPointIdentity(SO2), [pi])
65+
res = calcFactorResidualTemporary(f, (Pose2, Point2), m, (xi, xj))
6366
@test isapprox(res, [-0.001], atol=1e-3)
6467

6568
##
@@ -200,9 +203,9 @@ lmp_noise = Matrix(Diagonal([0.01;0.01].^2))
200203
fg = initfg()
201204

202205
# landmarks
203-
addVariable!(fg, :l1, Point2)
204-
addVariable!(fg, :l2, Point2)
205-
addVariable!(fg, :l3, Point2)
206+
addVariable!(fg, :l1, RoME.Point2)
207+
addVariable!(fg, :l2, RoME.Point2)
208+
addVariable!(fg, :l3, RoME.Point2)
206209

207210
addFactor!(fg, [:l1], PriorPoint2(MvNormal([-10.0;1.0-10.0],lmp_noise)), graphinit=false)
208211
addFactor!(fg, [:l2], PriorPoint2(MvNormal([-10.0+sqrt(3)/2;-0.5-10.0],lmp_noise)), graphinit=false)

0 commit comments

Comments
 (0)