Skip to content

Commit e52e8de

Browse files
author
Benjamin Maidel
authored
Merge pull request #5 from ipa-svn/indigo-devel
New cleanedup verison of pointcloud to laserscan including roi filter and frame publisher
2 parents 9312409 + 60a143b commit e52e8de

13 files changed

+1020
-340
lines changed

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,34 @@ find_package(catkin REQUIRED COMPONENTS
66
nodelet
77
roscpp
88
sensor_msgs
9+
tf
910
tf2
1011
tf2_ros
1112
tf2_sensor_msgs
1213
tf2_geometry_msgs
14+
pcl_ros
1315
)
1416

1517
catkin_package(
1618
INCLUDE_DIRS include
17-
LIBRARIES pointcloud_to_laserscan ipa_pointcloud_to_laserscan
18-
CATKIN_DEPENDS roscpp message_filters nodelet sensor_msgs tf2 tf2_ros tf2_sensor_msgs tf2_geometry_msgs
19+
LIBRARIES pointcloud_to_laserscan ipa_pointcloud_to_laserscan roi_outlier_removal
20+
CATKIN_DEPENDS roscpp message_filters nodelet sensor_msgs tf2 tf2_ros tf2_sensor_msgs tf2_geometry_msgs pcl_ros
1921
)
2022

2123
include_directories(
2224
include
2325
${catkin_INCLUDE_DIRS}
2426
)
2527

28+
add_library(frame_publisher src/frame_publisher.cpp)
29+
target_link_libraries(frame_publisher ${catkin_LIBRARIES})
30+
31+
add_executable(frame_publisher_node src/frame_publisher_node.cpp)
32+
target_link_libraries(frame_publisher_node frame_publisher ${catkin_LIBRARIES})
33+
34+
add_library(roi_outlier_removal src/roi_outlier_removal_nodelet.cpp)
35+
target_link_libraries(roi_outlier_removal ${catkin_LIBRARIES})
36+
2637
add_library(pointcloud_to_laserscan src/pointcloud_to_laserscan_nodelet.cpp)
2738
target_link_libraries(pointcloud_to_laserscan ${catkin_LIBRARIES})
2839

README

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
This package contains the original pointcloud to laserscan from Paul Bovbel and a new improved version from Fraunhofer IPA.
3+
The improvements are in form of strongly reduced computational time for the laserscan creation as described in detail below,
4+
and some added functionality also presented in detail below.
5+
6+
The procedure for converting the pointcloud to a laserscan follows the following principle roughly:
7+
1. Make sure the transformation between the original frame (frame of the pointcloud) and the goal frame (frame of the scan) is available
8+
2. Find the points that are within the specified region
9+
3. Translate the relevant point to scan coordinates
10+
4. Update scan if range of new point is shorter than current range for the same angle
11+
12+
13+
14+
The two versions of pointcloud to laserscan (pointcloud_to_laserscan_nodelet and ipa_pointcloud_to_laserscan_nodelet) differs in the following ways:
15+
* The IPA version converts the borders for the point selection to the original coordinates and does so avoid further processing of points that are outside the selected borders. Thsi savers a lot of computational time compared to the original version where the complete pointcloud was transformed.
16+
17+
* The ipa version if not based on MessageFilters. This choise was made due to the problem that the message filter stops generating cloud callbacks completely after an arbitrary amout of time (mostely after at least 30 min oparation). We have not had time to investigate the problem further but the effect is removed by not using the Message filter interface.
18+
19+
* The ipa version applies an additional outlier filter to the created scan. The filter is configured and called directly in the cloud callback and can be configured and activated/deactivated over parameter cofiguartions. This filter was implemented becaue of the noise clusters in the kinnect pointcloud. More about the filter below.
20+
21+
Using the ipa version without the outlier filter activated should result in exactly the same scans as the original version (only faster). We have however not had time to test this extensively enough to assure correctness of this statement.
22+
23+
24+
25+
The scan_outlier_removal_filter removes noise clusters with much smaller range than the surrounding points. The filter can be configured with the following three parameters cluster_break_distance, max_noise_cluster_size, max_noise_cluster_distance.
26+
This filter was constructed to handle noise clusters detected in the kinnect pointcloud. Those noise clusters are in form of false clusters of 15-35 points sporadically occuring at distances of up to a couple of meters in fromt of the sensor. They seems to be caused by reflection phenomenas in the environment. Finding and removing the clusters in the pointcloud was taking to much computational time. Standard statistical filters not applicabe du to the relatively large cluster size. The constructed filter removes the effect in the constructed scan so that this can be used for freespace generation and navigation.
27+
28+
29+
The roi_outlier_removal_nodelet creates a new pointcloud only containing the points that are within the specified region of intereset. The region of interest can be specified in any frame as long as the transformation to the pointcloud frame is known by the tf tree. The reduced pointcloud is given in the same frame as the original pointcloud. The point selection algorithm is the same as used within the ipa pointcloud to laserscan nodelet. This filter should be moved out of this package in the future since this functionality is not directly related to the cloud to scan functionality. For not it is a useful tool if one want to use external pointcloud filters befor constructing the scan, but want to save resources by only filtering a reduced pointcloud.
30+
31+
A useful method for getting a decent scan out of a noisy pointcloud is: roi_outlier_removal -> statistical pcl filter -> ipa_pointcloud_to_laserscan (using outlier_remval_filer).
32+
33+
The frame_publisher publishes a new frame spatialy aligned with the specified base_frame but with the specified rotations from the rotation_frame. This node should not be inside this package.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2016, Fraunhofer IPA.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
*
35+
*/
36+
37+
/*
38+
* Author: Sofie Nilsson
39+
*/
40+
41+
#ifndef FRAME_PUB_H
42+
#define FRAME_PUB_H
43+
44+
#include <ros/ros.h>
45+
46+
#include <tf/transform_listener.h>
47+
#include <tf/transform_broadcaster.h>
48+
#include <tf/transform_datatypes.h>
49+
50+
class FramePublisher
51+
{
52+
public:
53+
bool initialize();
54+
55+
private:
56+
void frameBroadcastCallback(const ros::TimerEvent& event);
57+
58+
private:
59+
ros::NodeHandle nh_, priv_nh_;
60+
tf::TransformListener tf_listener_;
61+
tf::TransformBroadcaster tf_broadcaster_;
62+
63+
ros::Timer frame_broadcast_timer_;
64+
double update_rate_;
65+
std::string base_frame_;
66+
std::string rotation_frame_;
67+
std::string target_frame_;
68+
bool rot_z_, rot_x_, rot_y_;
69+
};
70+
71+
#endif // FRAME_PUB_H

include/pointcloud_to_laserscan/ipa_pointcloud_to_laserscan_nodelet.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Software License Agreement (BSD License)
33
*
44
* Copyright (c) 2010-2012, Willow Garage, Inc.
5+
* Copyright (c) 2015, Fraunhofer IPA.
56
* All rights reserved.
67
*
78
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
1415
* copyright notice, this list of conditions and the following
1516
* disclaimer in the documentation and/or other materials provided
1617
* with the distribution.
17-
* * Neither the name of Willow Garage, Inc. nor the names of its
18+
* * Neither the name of the copyright holders nor the names of its
1819
* contributors may be used to endorse or promote products derived
1920
* from this software without specific prior written permission.
2021
*
@@ -33,7 +34,7 @@
3334
*
3435
*
3536
*/
36-
37+
3738
/*
3839
* Author: Paul Bovbel
3940
* Author: Sofie Nilsson
@@ -49,7 +50,8 @@
4950
#include "tf2_ros/buffer.h"
5051
#include "tf2_ros/transform_listener.h"
5152
#include "tf2_ros/message_filter.h"
52-
#include "message_filters/subscriber.h"
53+
#include <tf2_sensor_msgs/tf2_sensor_msgs.h>
54+
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
5355
#include "sensor_msgs/PointCloud2.h"
5456
#include <pointcloud_to_laserscan/scan_outlier_removal_filter.h>
5557

@@ -72,21 +74,17 @@ namespace pointcloud_to_laserscan
7274
virtual void onInit();
7375

7476
void cloudCb(const sensor_msgs::PointCloud2ConstPtr &cloud_msg);
75-
void failureCb(const sensor_msgs::PointCloud2ConstPtr &cloud_msg,
76-
tf2_ros::filter_failure_reasons::FilterFailureReason reason);
77-
78-
void connectCb();
7977

80-
void disconnectCb();
78+
void convert_pointcloud_to_laserscan(const sensor_msgs::PointCloud2ConstPtr &cloud, sensor_msgs::LaserScan &output, const tf2::Transform &T, const double range_min );
8179

8280
ros::NodeHandle nh_, private_nh_;
8381
ros::Publisher pub_;
8482
boost::mutex connect_mutex_;
8583

8684
boost::shared_ptr<tf2_ros::Buffer> tf2_;
8785
boost::shared_ptr<tf2_ros::TransformListener> tf2_listener_;
88-
message_filters::Subscriber<sensor_msgs::PointCloud2> sub_;
89-
boost::shared_ptr<MessageFilter> message_filter_;
86+
87+
ros::Subscriber sub_;
9088

9189
scan_outlier_filter::ScanOutlierRemovalFilter outlier_filter_;
9290
// ROS Parameters
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2016, Fraunhofer IPA.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
*
35+
*/
36+
37+
/*
38+
* Author: Sofie Nilsson
39+
*/
40+
41+
#ifndef ROI_OUTLIER_REMOVAL_NODELET
42+
#define ROI_OUTLIER_REMOVAL_NODELET
43+
44+
#include "ros/ros.h"
45+
#include "boost/thread/mutex.hpp"
46+
47+
#include "nodelet/nodelet.h"
48+
#include "tf2_ros/buffer.h"
49+
#include "tf2_ros/transform_listener.h"
50+
#include "tf2_ros/message_filter.h"
51+
#include <tf2_sensor_msgs/tf2_sensor_msgs.h>
52+
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
53+
#include "sensor_msgs/PointCloud2.h"
54+
55+
// includes for pcl filtering
56+
#include <pcl_ros/point_cloud.h>
57+
58+
namespace pointcloud_to_laserscan
59+
{
60+
typedef tf2_ros::MessageFilter<sensor_msgs::PointCloud2> MessageFilter;
61+
/**
62+
* The ROI outlier removal removes all points outside the specified region of interest (ROI) and publishes the remaining points into a new pointcloud.
63+
* The roi is defined as a z value range, angle range in the xy plane, and a max and min range in the xyy plane, for a chosen frame.
64+
* The filter converts the roi borders to to the original pointcloud frame in order to not have to waist time on transforming points
65+
* that are not to be used later on.
66+
* The points within the roi are transformed to and published in the same frame as the borders were given.
67+
* The filter is relevant to the pointcloud to laserscan transformation since it creates a possibility to apply additional statistical filtering
68+
* to a reduced pointcloud before creating the scan. The loclation of this filter within the pointcloud to laserscan package is however questionable.
69+
*/
70+
class RoiOutlierRemovalNodelet : public nodelet::Nodelet
71+
{
72+
73+
public:
74+
RoiOutlierRemovalNodelet();
75+
void configure_roi_settings();
76+
77+
private:
78+
virtual void onInit();
79+
80+
void cloudCb(const sensor_msgs::PointCloud2ConstPtr &cloud_msg);
81+
82+
void reduce_point_cloud_to_roi(const pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_cloud,
83+
pcl::PointCloud<pcl::PointXYZ>::Ptr reduced_pcl_cloud,
84+
const tf2::Transform &T);
85+
86+
ros::NodeHandle nh_, private_nh_;
87+
ros::Publisher pub_;
88+
89+
boost::shared_ptr<tf2_ros::Buffer> tf2_;
90+
boost::shared_ptr<tf2_ros::TransformListener> tf2_listener_;
91+
92+
ros::Subscriber sub_;
93+
94+
// ROS Parameters
95+
unsigned int input_queue_size_;
96+
std::string roi_def_frame_;
97+
double tolerance_;
98+
double min_height_, max_height_, angle_min_, angle_max_, angle_increment_, range_min_, range_max_;
99+
};
100+
101+
} // roi_outlier_removal
102+
103+
#endif // ROI_OUTLIER_REMOVAL_NODELET

include/pointcloud_to_laserscan/scan_outlier_removal_filter.h

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Software License Agreement (BSD License)
44
*
5-
* Copyright (c) 2010-2012, Fraunhofer IPA
5+
* Copyright (c) 2016, Fraunhofer IPA.
66
* All rights reserved.
77
*
88
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
1515
* copyright notice, this list of conditions and the following
1616
* disclaimer in the documentation and/or other materials provided
1717
* with the distribution.
18-
* * Neither the name of Willow Garage, Inc. nor the names of its
18+
* * Neither the name of the copyright holder nor the names of its
1919
* contributors may be used to endorse or promote products derived
2020
* from this software without specific prior written permission.
2121
*
@@ -39,31 +39,37 @@
3939
* Author: Sofie Nilsson
4040
*/
4141

42+
/*
43+
* The scan_outlier_removal_filter removes noise clusters with much smaller range than the surrounding points.
44+
* The filter can be configured with the following three parameters cluster_break_distance, max_noise_cluster_size,
45+
* max_noise_cluster_distance.
46+
*/
47+
4248
#ifndef IPA_POINTCLOUD_TO_LASERSCAN_SCAN_OUTLIER_REMOVAL_FILTER
4349
#define IPA_POINTCLOUD_TO_LASERSCAN_SCAN_OUTLIER_REMOVAL_FILTER
4450

4551
#include <sensor_msgs/LaserScan.h>
4652

47-
namespace scan_outlier_filter
48-
{
49-
class ScanOutlierRemovalFilter
50-
{
51-
private:
52-
bool filter_configured_;
53-
double cluster_break_distance_;
54-
int max_noise_cluster_size_;
55-
double max_noise_cluster_distance_;
53+
namespace scan_outlier_filter
54+
{
55+
class ScanOutlierRemovalFilter
56+
{
57+
private:
58+
bool filter_configured_;
59+
double cluster_break_distance_;
60+
int max_noise_cluster_size_;
61+
double max_noise_cluster_distance_;
5662

57-
public:
58-
ScanOutlierRemovalFilter():
59-
filter_configured_(false),
60-
cluster_break_distance_(0.0),
61-
max_noise_cluster_size_(0),
62-
max_noise_cluster_distance_(0.0)
63-
{};
64-
void configure(const double cluster_break_distance, const int max_noise_cluster_size, const double max_noise_cluster_distance);
63+
public:
64+
ScanOutlierRemovalFilter():
65+
filter_configured_(false),
66+
cluster_break_distance_(0.0),
67+
max_noise_cluster_size_(0),
68+
max_noise_cluster_distance_(0.0)
69+
{};
70+
void configure(const double cluster_break_distance, const int max_noise_cluster_size, const double max_noise_cluster_distance);
6571

66-
void remove_outliers(sensor_msgs::LaserScan &scan);
67-
};
72+
void remove_outliers(sensor_msgs::LaserScan &scan);
73+
};
6874
}
6975
#endif //IPA_POINTCLOUD_TO_LASERSCAN_SCAN_OUTLIER_REMOVAL_FILTER

nodelets.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@
2121
</class>
2222

2323
</library>
24+
25+
<library path="lib/libroi_outlier_removal">
26+
27+
<class name="pointcloud_to_laserscan/RoiOutlierRemovalNodelet"
28+
type="pointcloud_to_laserscan::RoiOutlierRemovalNodelet"
29+
base_class_type="nodelet::Nodelet">
30+
<description>
31+
Nodelet to remove all points not witin the defined field of view. The remaining points are published to a new pointcloud.
32+
</description>
33+
</class>
34+
35+
</library>

0 commit comments

Comments
 (0)