Time synchronized callback doesn't seem to work
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;
}
Asked by Arthur_Ace on 2019-02-26 14:35:55 UTC
Comments
If your messages do not have identical timestamps, you will need an approximate time synchronizer.
Asked by ahendrix on 2019-02-26 16:58:52 UTC
Tried that too, but even then my node doesn't enter the function...
Asked by Arthur_Ace on 2019-02-27 08:23:09 UTC
Do you try another queue size of TimeSynchronizer?
Asked by HankYuan on 2019-03-11 03:24:58 UTC