0
$\begingroup$

Rosanswers logo

I am trying to receive data from two different publishers as listed below-

  1. Message Type: baxter_core_msgs::EndpointState. Topic Name: /robot/limb/right/endpoint_state
  2. Message Type: sensor_msgs::PointCloud2. Topic Name: /kinect2/sd/points

Please see the code snippet below-

void DataCollector::callback(const baxter_core_msgs::EndpointStateConstPtr& ee_msg, const sensor_msgs::PointCloud2ConstPtr& pc_msg)
{
    std::cout << "Solve all of perception here" << std::endl;
}

DataCollector::DataCollector()
{
    ros::NodeHandle nh;
    message_filters::Subscriber<baxter_core_msgs::EndpointState> baxter_arm_sub(nh, "/robot/limb/right/endpoint_state", 1);
    message_filters::Subscriber<sensor_msgs::PointCloud2> point_cloud_sub(nh, "/kinect2/sd/points", 1);
    TimeSynchronizer<baxter_core_msgs::EndpointState, sensor_msgs::PointCloud2> sync(baxter_arm_sub, point_cloud_sub, 100);
    sync.registerCallback(boost::bind(&DataCollector::callback, this, _1, _2));
    ros::spin();
}

Unfortunately, there is no callback received. I dig into the problem and noticed that baxter_core_msgs::EndpointState message is being received in high frequency compared to sensor_msgs::PointCloud2.

Plese see below the screenshot of the output of rostopic echo /robot/limb/right/endpoint_state|grep secs and rostopic echo /kinect2/sd/points|grep secs in respective terminals taken at the same time-

image description


Originally posted by ravijoshi on ROS Answers with karma: 1744 on 2018-02-15

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

See #q60903 and #q172676 for almost duplicates.

Summarising: TimeSynchronizer needs timestamps to match exactly. If you don't have that happening in your message stream, but still want callbacks for messages that are "close enough", then you should use the ApproximateTimePolicy.


Originally posted by gvdhoorn with karma: 86574 on 2018-02-15

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2018-02-15:
Note also that if your Kinect2 is not connected to the Baxter PC, you might want to look into synchronising the clocks between all hosts in your ROS node graph. This will still not make TimeSynchronizer call your callbacks, but it will avoid problems later on (with TF fi).

Comment by ravijoshi on 2018-02-15:
Got it. Thank you very much.

Comment by gvdhoorn on 2018-02-15:
If I may suggest: try to search for these kind of problems. It's not that we don't want to help, but getting answers on this forum takes time, so if you find it yourself, you save time.

Use Google (not the integrated search). I always do something like:

$search_term site:answers.ros.org

Comment by ravijoshi on 2018-02-17:
Thanks for telling the trick.I got it.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.