def raycasting(): raw_input('place the robot at the home position and press enter.') print 'starting a raycasting simulation' r = Robot() while True: r.update_data() real_readings = np.array(r.data.sensor_values) ray_readings = raycasting.exp_reading_for_pose(r.pose, r.distance_thresholds) ray_readings = np.array(ray_readings) print 'ray readings: %s real readings: %s errors: %s' % (ray_readings, real_readings, abs(real_readings-ray_readings))
def distance_estimate(): sensor_num = raw_input('which sensor do you want to test?') or '3' r = Robot() while True: r.update_data() try: reading = r.data.sensor_values[int(sensor_num)] except IndexError: print 'no data at that index' continue threshold = r.data.thresholds['sensor'+sensor_num] dist = utils.estimated_distance(reading, threshold) print '%.2f mm away on sensor %s' % (dist, sensor_num)
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))