def exp_readings_for_pose(pose, thresholds, ir_range=80, radius=26.5, plot=False): if type(thresholds) is list: thresholds_s = thresholds else: sorted_keys = thresholds.keys() sorted_keys.sort() thresholds_s = [thresholds[key] for key in sorted_keys if 'sensor' in key] exp_ds = exp_distances_for_pose(pose, ir_range, radius, plot) readings = [utils.estimated_reading(d, t) for d, t in zip(exp_ds, thresholds_s)] return readings
def reading_estimate(): r = Robot() sensor_num = raw_input('which sensor do you want to test?') or '3' while True: real_distance = raw_input('how far away in mm are you from a wall?') r.update_data() try: real_reading = r.data.sensor_values[int(sensor_num)] except IndexError: print 'no data at that index' continue threshold = r.data.thresholds['sensor'+sensor_num] guessed_reading = utils.estimated_reading(real_distance, threshold) print 'guessed reading: %.2f real reading: %.2f error: %.2f' % (guessed_reading, real_reading, abs(guessed_reading-real_reading))