AttributeError: 'NoneType' object has no attribute 'measurement_prob'

Viewed 140
def measurement_prob(self, measurement):
    prob = 1.0
    for i in range(len(landmarks_loc)):
        dist = sqrt((self.x - landmarks_loc[i][0]) ** 2 + (self.y - landmarks_loc[i][1]) ** 2)
        prob *= self.gauss_roz(dist, self.sense_noise, measurement[i])
    return prob

for t in range(T): myrobot.move(0.1, 5.0) Z = myrobot.sense()

p2 = []
w = []

for i in range(N):
    p2.append(p[i].move(0.1, 5.0))
p = p2


for i in range(N):
    w.append(p[i].measurement_prob(Z))
p3 = []

I have a huge problem with that task, the definition function is in class robot

1 Answers

Have a look at the error message:

AttributeError: 'NoneType' object has no attribute 'measurement_prob'

This happens when you call p[i].measurement_prob(Z) with p[i] being None.

Since (at this point) p is the same as p2, what you need to look at is what p[i].move() returns in the previous for-loop.

Related