def get_icp_transform(world_points, iterations): # Iterate assignment and estimation of trafo a few times. # --->>> Implement your code here. # You may use the following strategy: # Start with the identity transform: overall_trafo = (1.0, 1.0, 0.0, 0.0, 0.0) # Then loop for j in xrange(iterations): # print world_points for j in xrange(iterations): # Transform the world_points using the curent overall_trafo # (see 05_b on how to do this) world_points1 = [apply_transform(overall_trafo, p) for p in world_points] # Call get_correspoinding_points_on_wall(...) left, right = get_corresponding_points_on_wall(world_points1) # Determine transformation which is needed "on top of" the current # overall_trafo: trafo = estimate_transform(...) trafo = estimate_transform(left, right, fix_scale = True) # Concatenate the found transformation with the current overall_trafo # to obtain a new, 'combined' transformation. You may use the function # overall_trafo = concatenate_transform(trafo, overall_trafo) # to concatenate two similarities. if trafo is None: return overall_trafo overall_trafo = concatenate_transform(trafo, overall_trafo) # Note also that estimate_transform may return None. # Return the final transformation. return overall_trafo
def get_icp_transform(world_points, iterations): overall_trafo = (1.0, 1.0, 0.0, 0.0, 0.0) for j in xrange(iterations): new_world_points = [apply_transform(overall_trafo, p) for p in world_points] # Get the transformation left, right = get_corresponding_points_on_wall(new_world_points) trafo = estimate_transform(left, right, fix_scale = True) if trafo: overall_trafo = concatenate_transform(trafo, overall_trafo) else: break return overall_trafo
# 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] else: world_points = [] # Write to file. # The pose. print >> out_file, "F %f %f %f" % pose # Write the scanner points and corresponding points. write_cylinders(out_file, "W C", world_points) out_file.close()
# 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] else: world_points = [] # Write to file. # The pose. print >> out_file, "F %f %f %f" % pose # Write the scanner points and corresponding points. write_cylinders(out_file, "W C", world_points) out_file.close()
# 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=False) # 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] else: world_points = [] # Write to file. # The pose. print >> out_file, "F %f %f %f" % pose # Write the scanner points and corresponding points. write_cylinders(out_file, "W C", world_points) out_file.close()