euclidean_cluster_nodelet.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
34 
35 int main(int argc, char **argv)
36 {
37  // Set up ROS.
38  ros::init(argc, argv, "euclidean_cluster_nodelet");
39  ros::NodeHandle n;
40 
41  // Variables to read from launch file
42  string pointcloud_input;
43  string cluster_markers;
44  string cluster_markers_text;
45 
46  // Create the euclidean_cluster_class object
48 
49  // Read data from launch file
50  ros::NodeHandle private_node_handle_("~");
51  private_node_handle_.param("pointcloud_input", pointcloud_input, string("pointcloud_input"));
52  private_node_handle_.param("cluster_markers", cluster_markers, string("cluster_markers"));
53  private_node_handle_.param("cluster_markers_text", cluster_markers_text, string("cluster_markers_text"));
54  private_node_handle_.param("cluster_tolerance", ec_class->cluster_tolerance, double(ec_class->cluster_tolerance));
55  private_node_handle_.param("min_cluster_size", ec_class->min_cluster_size, double(ec_class->min_cluster_size));
56  private_node_handle_.param("max_cluster_size", ec_class->max_cluster_size, double(ec_class->max_cluster_size));
57 
58  // Subscribe messages
59  ros::Subscriber sub_cloud = n.subscribe(pointcloud_input.c_str(), 1, &euclidean_cluster_extraction<PointXYZRGB>::callback_cloud,ec_class);
60 
61  // Publish messages
62  ros::Publisher pub_markers=n.advertise<visualization_msgs::Marker>(cluster_markers.c_str(),1000);
63  ros::Publisher pub_markers_text=n.advertise<visualization_msgs::Marker>(cluster_markers_text.c_str(),1000);
64 
65  // Set object pointers
66  ec_class->pub_marker_ptr=&pub_markers;
67  ec_class->pub_marker_text_ptr=&pub_markers_text;
68 
69  // Main loop.
70  while (n.ok())
71  {
72  ros::spinOnce();
73  }
74 
75  return 0;
76 }
double cluster_tolerance
cluster tolerance for segmentation
double max_cluster_size
maximum cluster points
int main(int argc, char **argv)
ros::Publisher * pub_marker_text_ptr
pointer to publish text markers
euclidean_cluster_extraction class declaration
ros::Publisher * pub_marker_ptr
pointer to publish markers
double min_cluster_size
minimum cluster points


pointcloud_segmentation
Author(s): Tiago Talhada
autogenerated on Mon Mar 2 2015 01:32:39