Skip to content

Commit b487b09

Browse files
committed
Fix tree id publishing and ensure that individual point trees are smaller than one rotation
1 parent 929b267 commit b487b09

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

include/continuous_clustering/clustering/continuous_clustering.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ struct Point
139139
std::set<RangeImageIndex> associated_trees{};
140140
RangeImageIndex tree_root_{0, -1};
141141
uint32_t tree_num_points{0};
142+
uint32_t cluster_width{0};
143+
uint64_t tree_id{0};
142144
uint64_t id{0};
143145
double visited_at_continuous_azimuth_angle{-1.};
144146
bool belongs_to_finished_cluster{false};

src/clustering/continuous_clustering.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -723,17 +723,26 @@ void ContinuousClustering::associatePointsInColumn(AssociationJob&& job)
723723
{
724724
if (point.tree_root_.column_index == -1)
725725
{
726-
// this point is not associated to any tree -> associate it
727-
point.tree_root_ = point_other.tree_root_;
728-
point_other.child_points.push_back(index);
729-
730-
// new point was associated to tree -> check if finish time will be delayed
726+
// this point is not associated to any tree -> associate it if the resulting cluster will be
727+
// not wider than one full rotation
731728
Point& point_root = range_image_[point_other.tree_root_.column_index * num_rows_ +
732729
point_other.tree_root_.row_index];
733-
point_root.finished_at_continuous_azimuth_angle =
734-
std::max(point_root.finished_at_continuous_azimuth_angle,
735-
point.continuous_azimuth_angle + max_angle_diff);
736-
point_root.tree_num_points++;
730+
uint32_t new_cluster_width = point.global_column_index - point_root.global_column_index;
731+
if (new_cluster_width < num_columns_)
732+
{
733+
point.tree_root_ = point_other.tree_root_;
734+
point.tree_id = point_root.global_column_index * num_rows_ + point_root.row_index;
735+
point_other.child_points.push_back(index);
736+
737+
// keep track of cluster width
738+
point_root.cluster_width = new_cluster_width;
739+
740+
// new point was associated to tree -> check if finish time will be delayed
741+
point_root.finished_at_continuous_azimuth_angle =
742+
std::max(point_root.finished_at_continuous_azimuth_angle,
743+
point.continuous_azimuth_angle + max_angle_diff);
744+
point_root.tree_num_points++;
745+
}
737746
}
738747
else
739748
{
@@ -787,9 +796,11 @@ void ContinuousClustering::associatePointsInColumn(AssociationJob&& job)
787796
{
788797
// this point could not be associated to any tree -> init new tree
789798
point.tree_root_ = index;
799+
point.tree_id = point.global_column_index * num_rows_ + point.row_index;
790800

791801
// calculate finish time (will be increased when new points are associated to tree)
792802
point.finished_at_continuous_azimuth_angle = point.continuous_azimuth_angle + max_angle_diff;
803+
point.cluster_width = 1;
793804

794805
// new tree has 1 point
795806
point.tree_num_points = 1;
@@ -1065,6 +1076,8 @@ void ContinuousClustering::clearColumns(int64_t from_global_column_index, int64_
10651076
point.tree_root_.row_index = 0;
10661077
point.tree_root_.column_index = -1;
10671078
point.tree_num_points = 0;
1079+
point.cluster_width = 0;
1080+
point.tree_id = 0;
10681081
point.id = 0;
10691082
point.visited_at_continuous_azimuth_angle = -1.;
10701083
point.belongs_to_finished_cluster = false;

src/ros/ros_utils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ void addPointToMessage(PointCloud2Iterators& container,
288288
*(*container.iter_tree_root_column_index + data_index_message) =
289289
static_cast<double>(point.tree_root_.column_index); // (*)
290290
*(*container.iter_number_of_visited_neighbors + data_index_message) = point.number_of_visited_neighbors;
291-
*(*container.iter_tree_id + data_index_message) =
292-
static_cast<double>(point.tree_root_.column_index * num_rows + point.tree_root_.row_index); // (*)
293-
*(*container.iter_id + data_index_message) = static_cast<double>(point.id); // (*)
291+
*(*container.iter_tree_id + data_index_message) = static_cast<double>(point.tree_id); // (*)
292+
*(*container.iter_id + data_index_message) = static_cast<double>(point.id); // (*)
294293
}
295294

296295
void addRawPointToMessage(PointCloud2Iterators& container, int data_index_message, const RawPoint& point)

0 commit comments

Comments
 (0)