Skip to content

Commit 2102a9f

Browse files
committed
Refactors automatic reset and adds some comments
1 parent c300cb0 commit 2102a9f

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

include/continuous_clustering/clustering/continuous_clustering.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum
2424
struct ContinuousRangeImageConfiguration
2525
{
2626
bool sensor_is_clockwise{true};
27-
int num_columns{1700};
27+
int num_columns{1700}; // rows are automatically read from number of points in firing
2828
bool supplement_inclination_angle_for_nan_cells{true};
2929
};
3030

src/clustering/continuous_clustering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ContinuousClustering::ContinuousClustering() = default;
1111
void ContinuousClustering::reset(int num_rows, bool sequential_execution)
1212
{
1313
// recalculate some intermediate values in case the parameters have changed
14-
num_columns_ = config_.range_image.num_columns; // TODO: also pass num columns as parameter here?
14+
num_columns_ = config_.range_image.num_columns;
1515
num_rows_ = num_rows;
1616
srig_azimuth_width_per_column = static_cast<float>((2 * M_PI)) / static_cast<float>(num_columns_);
1717
ring_buffer_max_columns = num_columns_ * 10;

src/ros/continuous_clustering_node.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,25 @@ class RosContinuousClustering
107107
ros::Time stamp_current_firing;
108108
stamp_current_firing.fromNSec(firing->stamp);
109109

110-
// handle time jumps and bad start condition (TODO: put it into library?)
110+
// handle time jumps and bad start condition
111111
double dt = (stamp_current_firing - last_update_).toSec();
112-
if (clustering_.resetRequired() || (!first_firing_after_reset && std::abs(dt) > 0.1))
112+
if (!first_firing_after_reset)
113113
{
114-
ROS_WARN_STREAM("Detected jump in time ("
115-
<< dt << ") or bad start condition was encountered. Reset continuous clustering.");
116-
reset(static_cast<int>(firing->points.size()));
117-
return;
114+
// resetting takes some time (often more than 0.1s) therefore we do not want to reset again when the
115+
// first firing after reset arrives
116+
117+
if (clustering_.resetRequired())
118+
{
119+
ROS_WARN_STREAM("Detected reconfiguration or bad start condition. Reset continuous clustering.");
120+
reset(static_cast<int>(firing->points.size()));
121+
return;
122+
}
123+
else if (std::abs(dt) > 0.1)
124+
{
125+
ROS_WARN_STREAM("Detected jump in time (" << dt << "). Reset continuous clustering.");
126+
reset(static_cast<int>(firing->points.size()));
127+
return;
128+
}
118129
}
119130
first_firing_after_reset = false;
120131
last_update_ = stamp_current_firing;

0 commit comments

Comments
 (0)