LazyNodelet for segmentation/EuclideanClusterExtraction

This commit is contained in:
Kentaro Wada 2017-08-22 16:22:30 +00:00 committed by Paul Bovbel
parent 6f2d30996a
commit 76ea38194e
2 changed files with 36 additions and 12 deletions

View File

@ -74,6 +74,10 @@ namespace pcl_ros
/** \brief Nodelet initialization routine. */ /** \brief Nodelet initialization routine. */
void onInit (); void onInit ();
/** \brief LazyNodelet connection routine. */
void subscribe ();
void unsubscribe ();
/** \brief Dynamic reconfigure callback /** \brief Dynamic reconfigure callback
* \param config the config object * \param config the config object
* \param level the dynamic reconfigure level * \param level the dynamic reconfigure level

View File

@ -71,15 +71,33 @@ pcl_ros::EuclideanClusterExtraction::onInit ()
pnh_->getParam ("publish_indices", publish_indices_); pnh_->getParam ("publish_indices", publish_indices_);
if (publish_indices_) if (publish_indices_)
pub_output_ = pnh_->advertise<PointIndices> ("output", max_queue_size_); pub_output_ = advertise<PointIndices> (*pnh_, "output", max_queue_size_);
else else
pub_output_ = pnh_->advertise<PointCloud> ("output", max_queue_size_); pub_output_ = advertise<PointCloud> (*pnh_, "output", max_queue_size_);
// Enable the dynamic reconfigure service // Enable the dynamic reconfigure service
srv_ = boost::make_shared <dynamic_reconfigure::Server<EuclideanClusterExtractionConfig> > (*pnh_); srv_ = boost::make_shared <dynamic_reconfigure::Server<EuclideanClusterExtractionConfig> > (*pnh_);
dynamic_reconfigure::Server<EuclideanClusterExtractionConfig>::CallbackType f = boost::bind (&EuclideanClusterExtraction::config_callback, this, _1, _2); dynamic_reconfigure::Server<EuclideanClusterExtractionConfig>::CallbackType f = boost::bind (&EuclideanClusterExtraction::config_callback, this, _1, _2);
srv_->setCallback (f); srv_->setCallback (f);
NODELET_DEBUG ("[%s::onInit] Nodelet successfully created with the following parameters:\n"
" - max_queue_size : %d\n"
" - use_indices : %s\n"
" - cluster_tolerance : %f\n",
getName ().c_str (),
max_queue_size_,
(use_indices_) ? "true" : "false", cluster_tolerance);
// Set given parameters here
impl_.setClusterTolerance (cluster_tolerance);
onInitPostProcess ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
pcl_ros::EuclideanClusterExtraction::subscribe ()
{
// If we're supposed to look for PointIndices (indices) // If we're supposed to look for PointIndices (indices)
if (use_indices_) if (use_indices_)
{ {
@ -103,17 +121,19 @@ pcl_ros::EuclideanClusterExtraction::onInit ()
else else
// Subscribe in an old fashion to input only (no filters) // Subscribe in an old fashion to input only (no filters)
sub_input_ = pnh_->subscribe<PointCloud> ("input", max_queue_size_, bind (&EuclideanClusterExtraction::input_indices_callback, this, _1, PointIndicesConstPtr ())); sub_input_ = pnh_->subscribe<PointCloud> ("input", max_queue_size_, bind (&EuclideanClusterExtraction::input_indices_callback, this, _1, PointIndicesConstPtr ()));
}
NODELET_DEBUG ("[%s::onInit] Nodelet successfully created with the following parameters:\n" //////////////////////////////////////////////////////////////////////////////////////////////
" - max_queue_size : %d\n" void
" - use_indices : %s\n" pcl_ros::EuclideanClusterExtraction::unsubscribe ()
" - cluster_tolerance : %f\n", {
getName ().c_str (), if (use_indices_)
max_queue_size_, {
(use_indices_) ? "true" : "false", cluster_tolerance); sub_input_filter_.unsubscribe ();
sub_indices_filter_.unsubscribe ();
// Set given parameters here }
impl_.setClusterTolerance (cluster_tolerance); else
sub_input_.shutdown ();
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////