def set_receptors_firing_rate(x, y, theta, err_l, err_r, arena): """ Set the firing rate of the 18 neural receptors according to the robot's current view and the error in wheel speeds. @param x: Robot's current x position. @param y: Robot's current y position. @param theta: Robot's current orientation angle. @param err_l: Error between desired and actual speed in the left wheel. @param err_r: Error between desired and actual speed in the right wheel. """ il, ir = vision.get_visible_wall_coordinates(x, y, theta, arena) view_proportion = vision.get_walls_view_ratio(il, ir, x, y, theta, arena) view = vision.get_view(x, y, il, ir, view_proportion, arena) if len(view) != 64: print len(view), il, ir, view_proportion # Input pixels px = view[::4] while len(px) > 16: print len(px) px = np.delete(px, -1) px = vision.add_noise_to_pixels(px) px = list(np.abs(vision.laplace_filter(px))) px = vision.scale_list(px) simtime = nest.GetKernelStatus()['time'] # Update the 16 spike generators representing the visual # input according to the pixel values read for i in range(len(px)): if np.random.rand() < px[i]: nest.SetStatus([i+11], {'spike_times': [simtime + 1]}) # Set random rates for the two spike generators representing the # error in wheel speeds. if np.random.rand() < err_l: nest.SetStatus([27], {'spike_times': [simtime + 1]}) if np.random.rand() < err_r: nest.SetStatus([28], {'spike_times': [simtime + 1]}) return px