51
51
52
52
namespace pointcloud_to_laserscan
53
53
{
54
- void scan_outlier_removal_filter (sensor_msgs::LaserScan &scan, double cluster_break_distance, int max_noise_cluster_size);
54
+ void scan_outlier_removal_filter (sensor_msgs::LaserScan &scan, double cluster_break_distance, int max_noise_cluster_size, double max_noise_cluster_distance );
55
55
56
56
IpaPointCloudToLaserScanNodelet::IpaPointCloudToLaserScanNodelet () {}
57
57
@@ -146,9 +146,11 @@ namespace pointcloud_to_laserscan
146
146
{
147
147
// Get filter related parameters
148
148
bool use_outlier_filter;
149
+ double max_noise_cluster_distance;
149
150
double cluster_break_distance;
150
151
int max_noise_cluster_size;
151
152
private_nh_.param <bool >(" use_outlier_filter" , use_outlier_filter, false );
153
+ private_nh_.param <double >(" max_noise_cluster_distance" , max_noise_cluster_distance, 2.0 );
152
154
private_nh_.param <double >(" cluster_break_distance" , cluster_break_distance, 0.3 );
153
155
private_nh_.param <int >(" max_noise_cluster_size" , max_noise_cluster_size, 5 );
154
156
@@ -307,7 +309,7 @@ namespace pointcloud_to_laserscan
307
309
308
310
if (use_outlier_filter)
309
311
{
310
- scan_outlier_removal_filter (output, cluster_break_distance, max_noise_cluster_size);
312
+ scan_outlier_removal_filter (output, cluster_break_distance, max_noise_cluster_size, max_noise_cluster_distance );
311
313
}
312
314
313
315
pub_.publish (output);
@@ -326,7 +328,7 @@ namespace pointcloud_to_laserscan
326
328
* @param cluster_break_distance The range jump to cause a cluster separation
327
329
* @param max_noise_cluster_size The maximum number of points a cluster can contain in order to be seen as noise and thereby removed
328
330
*/
329
- void scan_outlier_removal_filter (sensor_msgs::LaserScan &scan, double cluster_break_distance, int max_noise_cluster_size)
331
+ void scan_outlier_removal_filter (sensor_msgs::LaserScan &scan, double cluster_break_distance, int max_noise_cluster_size, double max_noise_cluster_distance )
330
332
{
331
333
// help function initialization
332
334
int ranges_size = scan.ranges .size ();
@@ -356,9 +358,25 @@ namespace pointcloud_to_laserscan
356
358
// Only remove cluster if it is closer than surrounding clusters
357
359
if ((i_current_cluster < max_noise_cluster_size) && (new_cluster_further_away != cluster_further_away))
358
360
{
361
+ // check if all cluster points are closer than the max noise distance
362
+ bool is_noise_cluster = true ;
359
363
for (int k = 0 ; k < i_current_cluster; k++)
360
364
{
361
- scan.ranges [cluster_indecies[k]] = scan.range_max ;
365
+ if (scan.ranges [cluster_indecies[k]] > max_noise_cluster_distance)
366
+ {
367
+ is_noise_cluster = false ;
368
+ break ;
369
+ }
370
+ }
371
+
372
+ // Only remove cluster points if all points are closer than the max noise distance
373
+ if (is_noise_cluster)
374
+ {
375
+ for (int k = 0 ; k < i_current_cluster; k++)
376
+ {
377
+ if (scan.ranges [cluster_indecies[k]] < max_noise_cluster_distance)
378
+ scan.ranges [cluster_indecies[k]] = scan.range_max ;
379
+ }
362
380
}
363
381
}
364
382
0 commit comments