0
$\begingroup$

Rosanswers logo

Hello,

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
{
    public:
        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_sub(private_nh, "camera/image_raw", 1); message_filters::Subscriber info_sub(private_nh, "ar_corners_marker",1); TimeSynchronizer 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"); } --- [Originally posted](https://answers.ros.org/question/195238/how-to-use-timesynchronizer-filter-inside-nodelet?/) by [ArturK](https://answers.ros.org/users/20496/arturk/) on ROS Answers with karma: 23 on 2014-10-17 Post score: 2
$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by kmhallen with karma: 1416 on 2014-10-17

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.