Skip to content

Commit 44231dc

Browse files
committed
firx fast slam bug
1 parent e0c1529 commit 44231dc

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

Localization/unscented_kalman_filter/unscented_kalman_filter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
3-
Uncented kalman filter (UKF) localization sample
3+
Unscented kalman filter (UKF) localization sample
44
55
author: Atsushi Sakai (@Atsushi_twi)
66
@@ -32,8 +32,8 @@
3232

3333
def calc_input():
3434
v = 1.0 # [m/s]
35-
yawrate = 0.1 # [rad/s]
36-
u = np.array([[v, yawrate]]).T
35+
yawRate = 0.1 # [rad/s]
36+
u = np.array([[v, yawRate]]).T
3737
return u
3838

3939

@@ -100,15 +100,15 @@ def generate_sigma_points(xEst, PEst, gamma):
100100

101101

102102
def predict_sigma_motion(sigma, u):
103-
# Sigma Points predition with motion model
103+
# Sigma Points prediction with motion model
104104
for i in range(sigma.shape[1]):
105105
sigma[:, i:i + 1] = motion_model(sigma[:, i:i + 1], u)
106106

107107
return sigma
108108

109109

110110
def predict_sigma_observation(sigma):
111-
# Sigma Points predition with observation model
111+
# Sigma Points prediction with observation model
112112
for i in range(sigma.shape[1]):
113113
sigma[0:2, i] = observation_model(sigma[:, i])
114114

@@ -187,14 +187,14 @@ def plot_covariance_ellipse(xEst, PEst):
187187

188188

189189
def setup_ukf(nx):
190-
lamda = ALPHA ** 2 * (nx + KAPPA) - nx
190+
lamb = ALPHA ** 2 * (nx + KAPPA) - nx
191191
# calculate weights
192-
wm = [lamda / (lamda + nx)]
193-
wc = [(lamda / (lamda + nx)) + (1 - ALPHA ** 2 + BETA)]
192+
wm = [lamb / (lamb + nx)]
193+
wc = [(lamb / (lamb + nx)) + (1 - ALPHA ** 2 + BETA)]
194194
for i in range(2 * nx):
195-
wm.append(1.0 / (2 * (nx + lamda)))
196-
wc.append(1.0 / (2 * (nx + lamda)))
197-
gamma = math.sqrt(nx + lamda)
195+
wm.append(1.0 / (2 * (nx + lamb)))
196+
wc.append(1.0 / (2 * (nx + lamb)))
197+
gamma = math.sqrt(nx + lamb)
198198

199199
wm = np.array([wm])
200200
wc = np.array([wc])

SLAM/FastSLAM1/fast_slam1.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,14 @@ def compute_weight(particle, z, Q):
190190
dx = z[0, 0: 2].T - zp
191191
dx[1, 0] = pi_2_pi(dx[1, 0])
192192

193-
S = particle.lmP[2 * lm_id:2 * lm_id + 2]
194193
try:
195-
invS = np.linalg.inv(S)
194+
invS = np.linalg.inv(Sf)
196195
except np.linalg.linalg.LinAlgError:
197196
print("singuler")
198197
return 1.0
199198

200199
num = math.exp(-0.5 * dx.T * invS * dx)
201-
den = 2.0 * math.pi * math.sqrt(np.linalg.det(S))
200+
den = 2.0 * math.pi * math.sqrt(np.linalg.det(Sf))
202201

203202
w = num / den
204203

SLAM/FastSLAM2/fast_slam2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,14 @@ def compute_weight(particle, z, Q):
191191
dz = z[0, 0: 2].T - zp
192192
dz[1, 0] = pi_2_pi(dz[1, 0])
193193

194-
S = particle.lmP[2 * lm_id:2 * lm_id + 2]
195194
try:
196-
invS = np.linalg.inv(S)
195+
invS = np.linalg.inv(Sf)
197196
except np.linalg.linalg.LinAlgError:
198197
print("singuler")
199198
return 1.0
200199

201200
num = math.exp(-0.5 * dz.T * invS * dz)
202-
den = 2.0 * math.pi * math.sqrt(np.linalg.det(S))
201+
den = 2.0 * math.pi * math.sqrt(np.linalg.det(Sf))
203202

204203
w = num / den
205204

0 commit comments

Comments
 (0)