Time synchronized callback doesn't seem to work

asked 2019-02-26 13:35:55 -0600

Arthur_Ace gravatar image

Hey there, I need your help again.

My goal is to synchronize two topics: The first is a pointCloud2Topic which I want to synchronize with a message/topic that I wrote which revolves around the state of a robot.

Both messages have a header and a timestamp. Also I made sure that ROS can see my message and it does pop up when I enter "rosmgs show"... So time synchronization should be possible, but my node never enters my Callback function. Can you help me out?

Oh yeah, one big question: Should I use the Approximate Time Synchronizer instead and if yes: can you give me an example on how that works?

Here's the code:

using namespace sensor_msgs;
using namespace message_filters;

float distance;


void callback(const my_msgs::RobotLinksData::ConstPtr &data,
     const sensor_msgs::PointCloud2::ConstPtr cloud_msg) {


std::cout << "ARE YOU SURE ABOUT THAT?" << std::endl;
// Solve all of perception here...

for (int i = 0; i < data->name.size(); i++) {

    std::cout << data->name[i] << std::endl;

     //TODO:MORE STUFF

}


}


int main(int argc, char **argv) {
ros::init(argc, argv, "vision_node");


ros::NodeHandle nh;


message_filters::Subscriber<my_msgs::RobotLinksData> datastream(nh, "RobotAwareness", 1);


message_filters::Subscriber<sensor_msgs::PointCloud2> PC_points(nh, "/kinect2/qhd/points", 1);


TimeSynchronizer<my_msgs::RobotLinksData, sensor_msgs::PointCloud2> sync(datastream, PC_points, 10);


sync.registerCallback(boost::bind(&callback, _1, _2));


ros::spin();

return 0;

}

edit retag flag offensive close merge delete

Comments

If your messages do not have identical timestamps, you will need an approximate time synchronizer.

ahendrix gravatar image ahendrix  ( 2019-02-26 15:58:52 -0600 )edit

Tried that too, but even then my node doesn't enter the function...

Arthur_Ace gravatar image Arthur_Ace  ( 2019-02-27 07:23:09 -0600 )edit

Do you try another queue size of TimeSynchronizer?

HankYuan gravatar image HankYuan  ( 2019-03-11 03:24:58 -0600 )edit