ticks_to_mm = 0.349 robot_width = 150.0 # The start pose we obtained miraculously. pose = (1850.0, 1897.0, 3.717551306747922) # Read the logfile which contains all scans. logfile = LegoLogfile() logfile.read("robot4_motors.txt") logfile.read("robot4_scan.txt") # Iterate over all positions. out_file = file("estimate_wall_transform.txt", "w") for i in xrange(len(logfile.scan_data)): # Compute the new pose. pose = filter_step(pose, logfile.motor_ticks[i], ticks_to_mm, robot_width, scanner_displacement) # Subsample points. subsampled_points = get_subsampled_points(logfile.scan_data[i]) world_points = [ LegoLogfile.scanner_to_world(pose, c) for c in subsampled_points ] # Get the transformation left, right = get_corresponding_points_on_wall(world_points) trafo = estimate_transform(left, right, fix_scale=True) # Correct the initial position using trafo. Also transform points. if trafo: pose = correct_pose(pose, trafo) world_points = [apply_transform(trafo, p) for p in world_points]
# Read the logfile which contains all scans. logfile = LegoLogfile() logfile.read("robot4_motors.txt") logfile.read("robot4_scan.txt") # Also read the reference cylinders (the map). logfile.read("robot_arena_landmarks.txt") reference_cylinders = [l[1:3] for l in logfile.landmarks] # Iterate over all positions. out_file = file("find_cylinder_pairs.txt", "w") for i in xrange(len(logfile.scan_data)): # Compute the new pose. pose = filter_step(pose, logfile.motor_ticks[i], ticks_to_mm, robot_width, scanner_displacement) # Extract cylinders, also convert them to world coordinates. cartesian_cylinders = compute_scanner_cylinders( logfile.scan_data[i], depth_jump, minimum_valid_distance, cylinder_offset) world_cylinders = [LegoLogfile.scanner_to_world(pose, c) for c in cartesian_cylinders] # For every cylinder, find the closest reference cylinder. cylinder_pairs = find_cylinder_pairs( world_cylinders, reference_cylinders, max_cylinder_distance) # Write to file. # The pose.