For reference, here is my solution:
def move(self, motion): # Do not change the name of this function
# ADD CODE HERE
alpha = float(motion[0]) + random.gauss(0.0, self.steering_noise)
d = float(motion[1]) + random.gauss(0.0, self.distance_noise)
beta = tan(alpha) * d / self.length
new_orientation = (self.orientation + beta)
new_orientation %= 2 * pi
if abs(beta) < 0.001:
new_x = self.x + d * cos(self.orientation)
new_y = self.y + d * sin(self.orientation)
else:
R = d / beta
cx = self.x - R * sin(self.orientation)
cy = self.y + R * cos(self.orientation)
new_x = cx + R * sin(self.orientation + beta)
new_y = cy - R * cos(self.orientation + beta)
result = robot(self.length)
result.set(new_x, new_y, new_orientation)
result.set_noise(self.bearing_noise, self.steering_noise, self.distance_noise)
return result # make sure your move function returns an instance
# of the robot class with the correct coordinates.
def sense(self, noisy=1): #do not change the name of this function
Z = []
for land in landmarks:
bearing = atan2(land[0] - self.y, land[1] - self.x) - self.orientation
if noisy == 1:
bearing += random.gauss(0.0, self.bearing_noise)
bearing %= 2 * pi
Z.append(bearing)
return Z #Leave this line here. Return vector Z of 4 bearings.
Note the optional parameter noisy=1 in sense and the addition of noise in calculations using random.gauss
answered
16 Mar '12, 00:44
bhrgunatha 373
471●1●4●15