Ask Your Question

How to use TimeSynchronizer filter inside nodelet?

asked 2014-10-17 09:20:50 -0600

ArturK gravatar image


I started using ROS (indigo on Ubuntu 14.04) and I want convert my node (which running well and using TimeSynchronizer for two topics synchronized by timestamp that call manta_callback function) to nodelet. But after initialising my nodelet, TimeSynchronizer doesn't synchronize input topics & doesn't call manta_callback(). How can I debug TimeSynchronizer under nodelet or should I check another solution e.g. NodeletMUX for synchronize two topics under nodelet? Sources:

header file:

namespace detect_control_nodelet {

class MarkerDetectControl : public nodelet::Nodelet
        virtual void onInit();
    void manta_callback(const sensor_msgs::ImageConstPtr & image_msg,  ar_track_alvar_msgs_ext::AlvarMarkerExtConstPtr  arMarkerCorners);       



src file:

namespace detect_control_nodelet 
   void MarkerDetectControl::onInit()
    NODELET_DEBUG("Initializing nodelet..."); 
    ros::NodeHandle n("~");

   ros::NodeHandle nh = getNodeHandle();
   ros::NodeHandle& private_nh = getPrivateNodeHandle();
   ROS_INFO("In onInit()");     

message_filters::Subscriber<Image> image_sub(private_nh, "camera/image_raw", 1);
message_filters::Subscriber<ar_track_alvar_msgs_ext::AlvarMarkerExt> info_sub(private_nh, "ar_corners_marker",1);
TimeSynchronizer<Image, ar_track_alvar_msgs_ext::AlvarMarkerExt> sync(image_sub, info_sub, 50);
sync.registerCallback(boost::bind(&MarkerDetectControl::manta_callback,this,_1, _2));}


void MarkerDetectControl::manta_callback(const sensor_msgs::ImageConstPtr & image_msg, ar_track_alvar_msgs_ext::AlvarMarkerExtConstPtr arMarkerCorners) {
ROS_INFO("In function manta_callback");

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-17 13:43:47 -0600

kmhallen gravatar image

The variables image_sub, info_sub, and sync need to be class variables instead of local. When the subscribers go out of scope at the end of onInit(), their destructors unsubscribe from the topics.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-10-17 09:20:50 -0600

Seen: 605 times

Last updated: Oct 17 '14