sac_segmentation.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2009, Willow Garage, Inc.
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 Willow Garage, Inc. 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  * $Id: sac_segmentation.h 35564 2011-01-27 07:32:12Z rusu $
35  *
36  */
37 
38 #ifndef PCL_ROS_SAC_SEGMENTATION_H_
39 #define PCL_ROS_SAC_SEGMENTATION_H_
40 
41 #include "pcl_ros/pcl_nodelet.h"
43 
44 // PCL includes
45 #include <pcl/segmentation/sac_segmentation.h>
46 
47 // Dynamic reconfigure
48 #include <dynamic_reconfigure/server.h>
49 #include "pcl_ros/SACSegmentationConfig.h"
50 #include "pcl_ros/SACSegmentationFromNormalsConfig.h"
51 
52 namespace pcl_ros
53 {
55 
57 
61  class SACSegmentation : public PCLNodelet
62  {
63  typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
66 
67  public:
70 
74  inline void setInputTFframe (std::string tf_frame) { tf_input_frame_ = tf_frame; }
75 
77  inline std::string getInputTFframe () { return (tf_input_frame_); }
78 
82  inline void setOutputTFframe (std::string tf_frame) { tf_output_frame_ = tf_frame; }
83 
85  inline std::string getOutputTFframe () { return (tf_output_frame_); }
86 
87  protected:
88  // The minimum number of inliers a model must have in order to be considered valid.
90 
91  // ROS nodelet attributes
94 
97 
100 
103 
105  std::string tf_input_frame_;
106 
108  std::string tf_input_orig_frame_;
109 
111  std::string tf_output_frame_;
112 
116 
118  virtual void onInit ();
119 
121  virtual void subscribe ();
122  virtual void unsubscribe ();
123 
128  void config_callback (SACSegmentationConfig &config, uint32_t level);
129 
134  void input_indices_callback (const PointCloudConstPtr &cloud, const PointIndicesConstPtr &indices);
135 
140 
144  inline void
146  {
147  indices_ = *indices;
148  }
149 
153  inline void
155  {
156  indices_.header = fromPCL(input->header);
157  PointIndicesConstPtr indices;
158  indices.reset (new PointIndices (indices_));
159  nf_pi_.add (indices);
160  }
161 
162  private:
164  boost::mutex mutex_;
165 
167  pcl::SACSegmentation<pcl::PointXYZ> impl_;
168 
172 
173  public:
174  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
175  };
176 
178 
182  {
183  typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
186 
187  typedef pcl::PointCloud<pcl::Normal> PointCloudN;
190 
191  public:
195  inline void setInputTFframe (std::string tf_frame) { tf_input_frame_ = tf_frame; }
196 
198  inline std::string getInputTFframe () { return (tf_input_frame_); }
199 
203  inline void setOutputTFframe (std::string tf_frame) { tf_output_frame_ = tf_frame; }
204 
206  inline std::string getOutputTFframe () { return (tf_output_frame_); }
207 
208  protected:
209  // ROS nodelet attributes
212 
215 
218 
223  inline void
225  {
226  PointIndices indices;
227  indices.header.stamp = fromPCL(cloud->header).stamp;
228  nf_.add (boost::make_shared<PointIndices> (indices));
229  }
230 
234 
236  std::string tf_input_frame_;
238  std::string tf_input_orig_frame_;
240  std::string tf_output_frame_;
241 
243  virtual void onInit ();
244 
246  virtual void subscribe ();
247  virtual void unsubscribe ();
248 
252  void axis_callback (const pcl_msgs::ModelCoefficientsConstPtr &model);
253 
258  void config_callback (SACSegmentationFromNormalsConfig &config, uint32_t level);
259 
266  const PointCloudNConstPtr &cloud_normals,
267  const PointIndicesConstPtr &indices);
268 
269  private:
271  boost::mutex mutex_;
272 
274  pcl::SACSegmentationFromNormals<pcl::PointXYZ, pcl::Normal> impl_;
275 
279 
280  public:
281  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
282  };
283 }
284 
285 #endif //#ifndef PCL_ROS_SAC_SEGMENTATION_H_
pcl_ros::SACSegmentation::mutex_
boost::mutex mutex_
Internal mutex.
Definition: sac_segmentation.h:164
pcl_ros::SACSegmentation::getInputTFframe
std::string getInputTFframe()
Get the TF frame the input PointCloud should be transformed into before processing.
Definition: sac_segmentation.h:77
pcl_ros::SACSegmentation::sync_input_indices_e_
boost::shared_ptr< message_filters::Synchronizer< sync_policies::ExactTime< PointCloud, PointIndices > > > sync_input_indices_e_
Synchronized input, and indices.
Definition: sac_segmentation.h:170
pcl_ros::SACSegmentationFromNormals::impl_
pcl::SACSegmentationFromNormals< pcl::PointXYZ, pcl::Normal > impl_
The PCL implementation used.
Definition: sac_segmentation.h:274
ros::Publisher
pcl_ros::PCLNodelet
PCLNodelet represents the base PCL Nodelet class. All PCL nodelets should inherit from this class.
Definition: pcl_nodelet.h:73
pcl_ros::SACSegmentationFromNormals::tf_input_frame_
std::string tf_input_frame_
The input TF frame the data should be transformed into, if input.header.frame_id is different.
Definition: sac_segmentation.h:236
pcl_ros::SACSegmentationFromNormals::srv_
boost::shared_ptr< dynamic_reconfigure::Server< SACSegmentationFromNormalsConfig > > srv_
Pointer to a dynamic reconfigure service.
Definition: sac_segmentation.h:217
pass_through.h
boost::shared_ptr
pcl_ros::SACSegmentation::PointCloudPtr
boost::shared_ptr< PointCloud > PointCloudPtr
Definition: sac_segmentation.h:64
pcl_ros
Definition: boundary.h:46
pcl_ros::SACSegmentation::setInputTFframe
void setInputTFframe(std::string tf_frame)
Set the input TF frame the data should be transformed into before processing, if input....
Definition: sac_segmentation.h:74
pcl_ros::SACSegmentationFromNormals::PointCloudNPtr
boost::shared_ptr< PointCloudN > PointCloudNPtr
Definition: sac_segmentation.h:188
pcl_ros::SACSegmentationFromNormals::tf_input_orig_frame_
std::string tf_input_orig_frame_
The original data input TF frame.
Definition: sac_segmentation.h:238
pcl_ros::SACSegmentation::nf_pi_
message_filters::PassThrough< pcl_msgs::PointIndices > nf_pi_
Null passthrough filter, used for pushing empty elements in the synchronizer.
Definition: sac_segmentation.h:115
pcl_ros::SACSegmentation::onInit
virtual void onInit()
Nodelet initialization routine.
Definition: sac_segmentation.cpp:47
pcl_ros::SACSegmentation::SACSegmentation
SACSegmentation()
Constructor.
Definition: sac_segmentation.h:69
pcl_ros::SACSegmentation::input_callback
void input_callback(const PointCloudConstPtr &input)
Input callback. Used when latched_indices_ is set.
Definition: sac_segmentation.h:154
pcl_ros::SACSegmentationFromNormals::sync_input_normals_indices_e_
boost::shared_ptr< message_filters::Synchronizer< sync_policies::ExactTime< PointCloud, PointCloudN, PointIndices > > > sync_input_normals_indices_e_
Definition: sac_segmentation.h:278
pcl_ros::SACSegmentation::sync_input_indices_a_
boost::shared_ptr< message_filters::Synchronizer< sync_policies::ApproximateTime< PointCloud, PointIndices > > > sync_input_indices_a_
Definition: sac_segmentation.h:171
pcl_ros::SACSegmentationFromNormals::nf_
message_filters::PassThrough< PointIndices > nf_
Null passthrough filter, used for pushing empty elements in the synchronizer.
Definition: sac_segmentation.h:233
pcl_ros::SACSegmentationFromNormals::mutex_
boost::mutex mutex_
Internal mutex.
Definition: sac_segmentation.h:271
pcl_ros::SACSegmentationFromNormals::tf_output_frame_
std::string tf_output_frame_
The output TF frame the data should be transformed into, if input.header.frame_id is different.
Definition: sac_segmentation.h:240
pcl_ros::SACSegmentation::impl_
pcl::SACSegmentation< pcl::PointXYZ > impl_
The PCL implementation used.
Definition: sac_segmentation.h:167
pcl_ros::SACSegmentationFromNormals::PointCloudPtr
boost::shared_ptr< PointCloud > PointCloudPtr
Definition: sac_segmentation.h:184
pcl_ros::PCLNodelet::PointIndicesConstPtr
PointIndices::ConstPtr PointIndicesConstPtr
Definition: pcl_nodelet.h:84
pcl_ros::SACSegmentationFromNormals::PointCloud
pcl::PointCloud< pcl::PointXYZ > PointCloud
Definition: sac_segmentation.h:183
pcl_nodelet.h
pcl_ros::SACSegmentation::PointCloud
pcl::PointCloud< pcl::PointXYZ > PointCloud
Definition: sac_segmentation.h:63
pcl_ros::SACSegmentation::indices_callback
void indices_callback(const PointIndicesConstPtr &indices)
Indices callback. Used when latched_indices_ is set.
Definition: sac_segmentation.h:145
message_filters::Subscriber< PointCloudN >
pcl_ros::SACSegmentationFromNormals::PointCloudConstPtr
boost::shared_ptr< const PointCloud > PointCloudConstPtr
Definition: sac_segmentation.h:185
pcl_ros::SACSegmentation::min_inliers_
int min_inliers_
Definition: sac_segmentation.h:89
pcl_ros::SACSegmentationFromNormals::sub_normals_filter_
message_filters::Subscriber< PointCloudN > sub_normals_filter_
The normals PointCloud subscriber filter.
Definition: sac_segmentation.h:211
pcl_ros::SACSegmentationFromNormals::input_normals_indices_callback
void input_normals_indices_callback(const PointCloudConstPtr &cloud, const PointCloudNConstPtr &cloud_normals, const PointIndicesConstPtr &indices)
Input point cloud callback.
Definition: sac_segmentation.cpp:586
pcl_ros::SACSegmentation::tf_output_frame_
std::string tf_output_frame_
The output TF frame the data should be transformed into, if input.header.frame_id is different.
Definition: sac_segmentation.h:111
pcl_ros::SACSegmentation::unsubscribe
virtual void unsubscribe()
Definition: sac_segmentation.cpp:181
fromPCL
void fromPCL(const pcl::ModelCoefficients &pcl_mc, pcl_msgs::ModelCoefficients &mc)
pcl_ros::SACSegmentationFromNormals::sync_input_normals_indices_a_
boost::shared_ptr< message_filters::Synchronizer< sync_policies::ApproximateTime< PointCloud, PointCloudN, PointIndices > > > sync_input_normals_indices_a_
Synchronized input, normals, and indices.
Definition: sac_segmentation.h:277
pcl_ros::SACSegmentationFromNormals::PointCloudNConstPtr
boost::shared_ptr< const PointCloudN > PointCloudNConstPtr
Definition: sac_segmentation.h:189
pcl_ros::SACSegmentationFromNormals::getOutputTFframe
std::string getOutputTFframe()
Get the TF frame the PointCloud should be transformed into after processing.
Definition: sac_segmentation.h:206
pcl_ros::SACSegmentationFromNormals::getInputTFframe
std::string getInputTFframe()
Get the TF frame the input PointCloud should be transformed into before processing.
Definition: sac_segmentation.h:198
pcl_ros::SACSegmentationFromNormals::PointCloudN
pcl::PointCloud< pcl::Normal > PointCloudN
Definition: sac_segmentation.h:187
message_filters::PassThrough::add
void add(const EventType &evt)
pcl_ros::SACSegmentation::input_indices_callback
void input_indices_callback(const PointCloudConstPtr &cloud, const PointIndicesConstPtr &indices)
Input point cloud callback. Used when use_indices is set.
Definition: sac_segmentation.cpp:267
pcl_ros::SACSegmentation::subscribe
virtual void subscribe()
LazyNodelet connection routine.
Definition: sac_segmentation.cpp:131
pcl_ros::SACSegmentationFromNormals::sub_axis_
ros::Subscriber sub_axis_
The input PointCloud subscriber.
Definition: sac_segmentation.h:214
pcl_ros::SACSegmentationFromNormals::subscribe
virtual void subscribe()
LazyNodelet connection routine.
Definition: sac_segmentation.cpp:446
pcl_ros::SACSegmentation::tf_input_frame_
std::string tf_input_frame_
The input TF frame the data should be transformed into, if input.header.frame_id is different.
Definition: sac_segmentation.h:105
pcl_ros::SACSegmentation::PointCloudConstPtr
boost::shared_ptr< const PointCloud > PointCloudConstPtr
Definition: sac_segmentation.h:65
pcl_ros::SACSegmentation::pub_model_
ros::Publisher pub_model_
The output ModelCoefficients publisher.
Definition: sac_segmentation.h:96
message_filters::sync_policies
pcl_ros::SACSegmentationFromNormals::setInputTFframe
void setInputTFframe(std::string tf_frame)
Set the input TF frame the data should be transformed into before processing, if input....
Definition: sac_segmentation.h:195
pcl_ros::SACSegmentation::tf_input_orig_frame_
std::string tf_input_orig_frame_
The original data input TF frame.
Definition: sac_segmentation.h:108
pcl_ros::SACSegmentationFromNormals::config_callback
void config_callback(SACSegmentationFromNormalsConfig &config, uint32_t level)
Dynamic reconfigure callback.
Definition: sac_segmentation.cpp:520
message_filters::PassThrough< pcl_msgs::PointIndices >
pcl_ros::SACSegmentationFromNormals::axis_callback
void axis_callback(const pcl_msgs::ModelCoefficientsConstPtr &model)
Model callback.
Definition: sac_segmentation.cpp:503
pcl_ros::SACSegmentationFromNormals
SACSegmentationFromNormals represents the PCL nodelet segmentation class for Sample Consensus methods...
Definition: sac_segmentation.h:181
pcl_ros::SACSegmentationFromNormals::unsubscribe
virtual void unsubscribe()
Definition: sac_segmentation.cpp:490
pcl_ros::SACSegmentation::pub_indices_
ros::Publisher pub_indices_
The output PointIndices publisher.
Definition: sac_segmentation.h:93
pcl_ros::SACSegmentation::indices_
PointIndices indices_
Pointer to a set of indices stored internally. (used when latched_indices_ is set).
Definition: sac_segmentation.h:139
pcl_ros::SACSegmentationFromNormals::onInit
virtual void onInit()
Nodelet initialization routine.
Definition: sac_segmentation.cpp:363
pcl_ros::SACSegmentation::config_callback
void config_callback(SACSegmentationConfig &config, uint32_t level)
Dynamic reconfigure callback.
Definition: sac_segmentation.cpp:194
pcl_ros::SACSegmentationFromNormals::setOutputTFframe
void setOutputTFframe(std::string tf_frame)
Set the output TF frame the data should be transformed into after processing.
Definition: sac_segmentation.h:203
pcl_ros::SACSegmentation::srv_
boost::shared_ptr< dynamic_reconfigure::Server< SACSegmentationConfig > > srv_
Pointer to a dynamic reconfigure service.
Definition: sac_segmentation.h:102
pcl_ros::PCLNodelet::PointIndices
pcl_msgs::PointIndices PointIndices
Definition: pcl_nodelet.h:82
pcl_ros::SACSegmentation
SACSegmentation represents the Nodelet segmentation class for Sample Consensus methods and models,...
Definition: sac_segmentation.h:61
pcl_ros::SACSegmentation::getOutputTFframe
std::string getOutputTFframe()
Get the TF frame the PointCloud should be transformed into after processing.
Definition: sac_segmentation.h:85
pcl_ros::SACSegmentation::setOutputTFframe
void setOutputTFframe(std::string tf_frame)
Set the output TF frame the data should be transformed into after processing.
Definition: sac_segmentation.h:82
pcl_ros::SACSegmentation::sub_input_
ros::Subscriber sub_input_
The input PointCloud subscriber.
Definition: sac_segmentation.h:99
pcl_ros::SACSegmentationFromNormals::input_callback
void input_callback(const PointCloudConstPtr &cloud)
Input point cloud callback. Because we want to use the same synchronizer object, we push back empty e...
Definition: sac_segmentation.h:224
ros::Subscriber


pcl_ros
Author(s): Open Perception, Julius Kammerl , William Woodall
autogenerated on Fri Jul 12 2024 02:54:40