Nodelet to automatically subscribe/unsubscribe topics according to subscription of advertised topics. More...
#include <nodelet.h>
Public Member Functions | |
Nodelet () | |
Protected Member Functions | |
template<class T > | |
ros::Publisher | advertise (ros::NodeHandle &nh, std::string topic, int queue_size) |
Advertise a topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and publish topic with appropriate latch parameter. | |
image_transport::CameraPublisher | advertiseCamera (ros::NodeHandle &nh, const std::string &topic, int queue_size) |
Advertise an image topic camera info topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and it and publish topic with appropriate latch parameter. | |
image_transport::Publisher | advertiseImage (ros::NodeHandle &nh, const std::string &topic, int queue_size) |
Advertise an image topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and it and publish topic with appropriate latch parameter. | |
virtual void | cameraConnectionBaseCallback () |
callback function which is called when new subscriber come for camera image publisher or camera info publisher. This function is called from cameraConnectionCallback or cameraInfoConnectionCallback. | |
virtual void | cameraConnectionCallback (const image_transport::SingleSubscriberPublisher &pub) |
callback function which is called when new subscriber come for camera image publisher | |
virtual void | cameraInfoConnectionCallback (const ros::SingleSubscriberPublisher &pub) |
callback function which is called when new subscriber come for camera info publisher | |
virtual void | connectionCallback (const ros::SingleSubscriberPublisher &pub) |
callback function which is called when new subscriber come | |
virtual void | imageConnectionCallback (const image_transport::SingleSubscriberPublisher &pub) |
callback function which is called when new subscriber come for image publisher | |
virtual void | onInit () |
Initialize nodehandles nh_ and pnh_. Subclass should call this method in its onInit method. | |
virtual void | onInitPostProcess () |
Post processing of initialization of nodelet. You need to call this method in order to use always_subscribe feature. | |
virtual void | subscribe ()=0 |
This method is called when publisher is subscribed by other nodes. Set up subscribers in this method. | |
virtual void | unsubscribe ()=0 |
This method is called when publisher is unsubscribed by other nodes. Shut down subscribers in this method. | |
virtual void | warnNeverSubscribedCallback (const ros::WallTimerEvent &event) |
callback function which is called when walltimer duration run out. | |
Protected Attributes | |
bool | always_subscribe_ |
A flag to disable watching mechanism and always subscribe input topics. It can be specified via ~always_subscribe parameter. | |
std::vector < image_transport::CameraPublisher > | camera_publishers_ |
List of watching camera publishers. | |
boost::mutex | connection_mutex_ |
mutex to call subscribe() and unsubscribe() in critical section. | |
ConnectionStatus | connection_status_ |
Status of connection. | |
bool | ever_subscribed_ |
A flag to check if the node has been ever subscribed or not. | |
std::vector < image_transport::Publisher > | image_publishers_ |
List of watching image publishers. | |
boost::shared_ptr < ros::NodeHandle > | nh_ |
Shared pointer to nodehandle. | |
boost::shared_ptr < ros::NodeHandle > | pnh_ |
Shared pointer to private nodehandle. | |
std::vector< ros::Publisher > | publishers_ |
List of watching publishers. | |
bool | subscribed_ |
A flag to check if any publisher is already subscribed or not. | |
ros::WallTimer | timer_ |
WallTimer instance for warning about no connection. | |
bool | verbose_connection_ |
true if `~verbose_connection` or `verbose_connection` parameter is true. |
Nodelet to automatically subscribe/unsubscribe topics according to subscription of advertised topics.
It's important not to subscribe topic if no output is required.
In order to watch advertised topics, need to use advertise template method. And create subscribers in subscribe() and shutdown them in unsubscribed().
opencv_apps::Nodelet::Nodelet | ( | ) | [inline] |
Reimplemented from nodelet::Nodelet.
ros::Publisher opencv_apps::Nodelet::advertise | ( | ros::NodeHandle & | nh, |
std::string | topic, | ||
int | queue_size | ||
) | [inline, protected] |
Advertise a topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and publish topic with appropriate latch parameter.
nh | NodeHandle. |
topic | topic name to advertise. |
queue_size | queue size for publisher. |
latch | set true if latch topic publication. |
image_transport::CameraPublisher opencv_apps::Nodelet::advertiseCamera | ( | ros::NodeHandle & | nh, |
const std::string & | topic, | ||
int | queue_size | ||
) | [inline, protected] |
Advertise an image topic camera info topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and it and publish topic with appropriate latch parameter.
nh | NodeHandle. |
topic | topic name to advertise. |
queue_size | queue size for publisher. |
latch | set true if latch topic publication. |
image_transport::Publisher opencv_apps::Nodelet::advertiseImage | ( | ros::NodeHandle & | nh, |
const std::string & | topic, | ||
int | queue_size | ||
) | [inline, protected] |
Advertise an image topic and watch the publisher. Publishers which are created by this method. It automatically reads latch boolean parameter from nh and it and publish topic with appropriate latch parameter.
nh | NodeHandle. |
topic | topic name to advertise. |
queue_size | queue size for publisher. |
latch | set true if latch topic publication. |
void opencv_apps::Nodelet::cameraConnectionBaseCallback | ( | ) | [protected, virtual] |
callback function which is called when new subscriber come for camera image publisher or camera info publisher. This function is called from cameraConnectionCallback or cameraInfoConnectionCallback.
Definition at line 152 of file nodelet.cpp.
void opencv_apps::Nodelet::cameraConnectionCallback | ( | const image_transport::SingleSubscriberPublisher & | pub | ) | [protected, virtual] |
callback function which is called when new subscriber come for camera image publisher
Definition at line 140 of file nodelet.cpp.
void opencv_apps::Nodelet::cameraInfoConnectionCallback | ( | const ros::SingleSubscriberPublisher & | pub | ) | [protected, virtual] |
callback function which is called when new subscriber come for camera info publisher
Definition at line 146 of file nodelet.cpp.
void opencv_apps::Nodelet::connectionCallback | ( | const ros::SingleSubscriberPublisher & | pub | ) | [protected, virtual] |
callback function which is called when new subscriber come
Definition at line 73 of file nodelet.cpp.
void opencv_apps::Nodelet::imageConnectionCallback | ( | const image_transport::SingleSubscriberPublisher & | pub | ) | [protected, virtual] |
callback function which is called when new subscriber come for image publisher
Definition at line 106 of file nodelet.cpp.
void opencv_apps::Nodelet::onInit | ( | ) | [protected, virtual] |
Initialize nodehandles nh_ and pnh_. Subclass should call this method in its onInit method.
Implements nodelet::Nodelet.
Reimplemented in camshift::CamShiftNodelet, color_filter::HSVColorFilterNodelet, hough_circles::HoughCirclesNodelet, watershed_segmentation::WatershedSegmentationNodelet, lk_flow::LKFlowNodelet, edge_detection::EdgeDetectionNodelet, color_filter::HLSColorFilterNodelet, hough_lines::HoughLinesNodelet, general_contours::GeneralContoursNodelet, segment_objects::SegmentObjectsNodelet, contour_moments::ContourMomentsNodelet, simple_flow::SimpleFlowNodelet, adding_images::AddingImagesNodelet, face_detection::FaceDetectionNodelet, convex_hull::ConvexHullNodelet, color_filter::RGBColorFilterNodelet, goodfeature_track::GoodfeatureTrackNodelet, find_contours::FindContoursNodelet, people_detect::PeopleDetectNodelet, smoothing::SmoothingNodelet, fback_flow::FBackFlowNodelet, phase_corr::PhaseCorrNodelet, corner_harris::CornerHarrisNodelet, discrete_fourier_transform::DiscreteFourierTransformNodelet, color_filter::ColorFilterNodelet< Config >, color_filter::ColorFilterNodelet< color_filter::HSVColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::RGBColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::HLSColorFilterConfig >, and threshold::ThresholdNodelet.
Definition at line 40 of file nodelet.cpp.
void opencv_apps::Nodelet::onInitPostProcess | ( | ) | [protected, virtual] |
Post processing of initialization of nodelet. You need to call this method in order to use always_subscribe feature.
Definition at line 59 of file nodelet.cpp.
virtual void opencv_apps::Nodelet::subscribe | ( | ) | [protected, pure virtual] |
This method is called when publisher is subscribed by other nodes. Set up subscribers in this method.
Implemented in camshift::CamShiftNodelet, hough_circles::HoughCirclesNodelet, watershed_segmentation::WatershedSegmentationNodelet, lk_flow::LKFlowNodelet, edge_detection::EdgeDetectionNodelet, hough_lines::HoughLinesNodelet, general_contours::GeneralContoursNodelet, segment_objects::SegmentObjectsNodelet, contour_moments::ContourMomentsNodelet, simple_flow::SimpleFlowNodelet, face_detection::FaceDetectionNodelet, convex_hull::ConvexHullNodelet, goodfeature_track::GoodfeatureTrackNodelet, find_contours::FindContoursNodelet, people_detect::PeopleDetectNodelet, smoothing::SmoothingNodelet, fback_flow::FBackFlowNodelet, phase_corr::PhaseCorrNodelet, corner_harris::CornerHarrisNodelet, color_filter::ColorFilterNodelet< Config >, color_filter::ColorFilterNodelet< color_filter::HSVColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::RGBColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::HLSColorFilterConfig >, adding_images::AddingImagesNodelet, threshold::ThresholdNodelet, and discrete_fourier_transform::DiscreteFourierTransformNodelet.
virtual void opencv_apps::Nodelet::unsubscribe | ( | ) | [protected, pure virtual] |
This method is called when publisher is unsubscribed by other nodes. Shut down subscribers in this method.
Implemented in camshift::CamShiftNodelet, hough_circles::HoughCirclesNodelet, watershed_segmentation::WatershedSegmentationNodelet, lk_flow::LKFlowNodelet, edge_detection::EdgeDetectionNodelet, hough_lines::HoughLinesNodelet, general_contours::GeneralContoursNodelet, segment_objects::SegmentObjectsNodelet, contour_moments::ContourMomentsNodelet, simple_flow::SimpleFlowNodelet, face_detection::FaceDetectionNodelet, convex_hull::ConvexHullNodelet, goodfeature_track::GoodfeatureTrackNodelet, find_contours::FindContoursNodelet, people_detect::PeopleDetectNodelet, smoothing::SmoothingNodelet, fback_flow::FBackFlowNodelet, phase_corr::PhaseCorrNodelet, corner_harris::CornerHarrisNodelet, color_filter::ColorFilterNodelet< Config >, color_filter::ColorFilterNodelet< color_filter::HSVColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::RGBColorFilterConfig >, color_filter::ColorFilterNodelet< color_filter::HLSColorFilterConfig >, adding_images::AddingImagesNodelet, threshold::ThresholdNodelet, and discrete_fourier_transform::DiscreteFourierTransformNodelet.
void opencv_apps::Nodelet::warnNeverSubscribedCallback | ( | const ros::WallTimerEvent & | event | ) | [protected, virtual] |
callback function which is called when walltimer duration run out.
Definition at line 66 of file nodelet.cpp.
bool opencv_apps::Nodelet::always_subscribe_ [protected] |
std::vector<image_transport::CameraPublisher> opencv_apps::Nodelet::camera_publishers_ [protected] |
boost::mutex opencv_apps::Nodelet::connection_mutex_ [protected] |
mutex to call subscribe() and unsubscribe() in critical section.
bool opencv_apps::Nodelet::ever_subscribed_ [protected] |
std::vector<image_transport::Publisher> opencv_apps::Nodelet::image_publishers_ [protected] |
boost::shared_ptr<ros::NodeHandle> opencv_apps::Nodelet::nh_ [protected] |
Shared pointer to nodehandle.
Reimplemented from nodelet::Nodelet.
boost::shared_ptr<ros::NodeHandle> opencv_apps::Nodelet::pnh_ [protected] |
std::vector<ros::Publisher> opencv_apps::Nodelet::publishers_ [protected] |
bool opencv_apps::Nodelet::subscribed_ [protected] |
ros::WallTimer opencv_apps::Nodelet::timer_ [protected] |
bool opencv_apps::Nodelet::verbose_connection_ [protected] |