From 071de1e3b44e7cd6614c6eae627b83aa3ea35486 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Tue, 22 Aug 2017 16:48:25 +0000 Subject: [PATCH] LazyNodelet for segmentation/SegmentDifferences --- .../segmentation/segment_differences.h | 4 +++ .../segmentation/segment_differences.cpp | 25 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pcl_ros/include/pcl_ros/segmentation/segment_differences.h b/pcl_ros/include/pcl_ros/segmentation/segment_differences.h index 287d8fb2..4914bc86 100644 --- a/pcl_ros/include/pcl_ros/segmentation/segment_differences.h +++ b/pcl_ros/include/pcl_ros/segmentation/segment_differences.h @@ -81,6 +81,10 @@ namespace pcl_ros /** \brief Nodelet initialization routine. */ void onInit (); + /** \brief LazyNodelet connection routine. */ + void subscribe (); + void unsubscribe (); + /** \brief Dynamic reconfigure callback * \param config the config object * \param level the dynamic reconfigure level diff --git a/pcl_ros/src/pcl_ros/segmentation/segment_differences.cpp b/pcl_ros/src/pcl_ros/segmentation/segment_differences.cpp index eceb5b17..22a7482b 100644 --- a/pcl_ros/src/pcl_ros/segmentation/segment_differences.cpp +++ b/pcl_ros/src/pcl_ros/segmentation/segment_differences.cpp @@ -46,8 +46,20 @@ pcl_ros::SegmentDifferences::onInit () // Call the super onInit () PCLNodelet::onInit (); - pub_output_ = pnh_->advertise ("output", max_queue_size_); + pub_output_ = advertise (*pnh_, "output", max_queue_size_); + NODELET_DEBUG ("[%s::onInit] Nodelet successfully created with the following parameters:\n" + " - max_queue_size : %d", + getName ().c_str (), + max_queue_size_); + + onInitPostProcess (); +} + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void +pcl_ros::SegmentDifferences::subscribe () +{ // Subscribe to the input using a filter sub_input_filter_.subscribe (*pnh_, "input", max_queue_size_); sub_target_filter_.subscribe (*pnh_, "target", max_queue_size_); @@ -69,11 +81,14 @@ pcl_ros::SegmentDifferences::onInit () sync_input_target_e_->connectInput (sub_input_filter_, sub_target_filter_); sync_input_target_e_->registerCallback (bind (&SegmentDifferences::input_target_callback, this, _1, _2)); } +} - NODELET_DEBUG ("[%s::onInit] Nodelet successfully created with the following parameters:\n" - " - max_queue_size : %d", - getName ().c_str (), - max_queue_size_); +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void +pcl_ros::SegmentDifferences::unsubscribe () +{ + sub_input_filter_.unsubscribe (); + sub_target_filter_.unsubscribe (); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////