Fix up bugs with assign groups 2
This commit is contained in:
@@ -205,20 +205,20 @@ def assign_groups_II(prev_groups, new_groups):
|
||||
max_group_number = 0
|
||||
unassigned_groups = []
|
||||
|
||||
def centres_from_groups(group):
|
||||
return icp.calc_mass_centre(np.array(group.points))
|
||||
def centres_from_groups(groups):
|
||||
return np.array([icp.calc_mass_centre(np.array([convert_lidar_to_cartesian(point) for point in group.get_points()])) for group in groups])
|
||||
|
||||
centre_func = np.vectorize(centres_from_groups)
|
||||
old_group_centres = centre_func(prev_groups)
|
||||
old_group_centres = centres_from_groups(prev_groups)
|
||||
old_group_indexes = np.arange(len(old_group_centres))
|
||||
|
||||
new_group_centers = centre_func(new_groups)
|
||||
new_group_centers = centres_from_groups(new_groups)
|
||||
new_group_indexes = np.arange(len(new_group_centers))
|
||||
|
||||
closest_points = icp.closest_points(new_group_centers, old_group_centres)
|
||||
# Now assign the new groups to the closest matching old group, if the distance is within a certain threshold.
|
||||
for i, point in enumerate(closest_points):
|
||||
matching_groups = prev_groups[old_group_centres == point]
|
||||
# TODO: Check the centres are within a certain threshold.
|
||||
new_groups[i].number = prev_groups[0].number
|
||||
|
||||
return new_groups
|
||||
|
||||
Reference in New Issue
Block a user