Skip to content

Commit 9ec9a1f

Browse files
committed
imporve nomalize weight function
1 parent 119400e commit 9ec9a1f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

SLAM/FastSLAM1/fast_slam1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def normalize_weight(particles):
6060

6161
sumw = sum([p.w for p in particles])
6262

63-
if sumw <= 0.0000001:
63+
try:
64+
for i in range(N_PARTICLE):
65+
particles[i].w /= sumw
66+
except ZeroDivisionError:
6467
for i in range(N_PARTICLE):
6568
particles[i].w = 1.0 / N_PARTICLE
6669

6770
return particles
6871

69-
for i in range(N_PARTICLE):
70-
particles[i].w /= sumw
71-
7272
return particles
7373

7474

0 commit comments

Comments
 (0)