ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can we use a tf listener and message filter in one node?

asked 2019-06-25 18:21:50 -0500

fangkd8 gravatar image

updated 2019-06-26 14:13:52 -0500

I`m trying to get tf transform and sensor msgs from a rosbag. But I found the message filter with a call back function can only work outside the while loop, and tf transform can only work inside a while loop.

Is there any possible way to get tf and image_raw>

code:

void ImageCallback(const sensor_msgs::ImageConstPtr& msg){
  std::string odom = "/odom";
  std::string velo = "/velodyne";

  tf::TransformListener listener;
  tf::StampedTransform transform;

 try {
   listener.lookupTransform(odom, velo, 
   msg->header.stamp, transform);
   std::cout << transform.stamp_ << std::endl;
   std::cout << "img: " << msg->header.stamp << "\n";
 }
 catch (tf2::LookupException ex){

  }
}

I plan to get the sensor_msg in the call back and use the timestamp to get the transform, but I can not get it. Is this way plausible?`

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-26 02:13:55 -0500

gvdhoorn gravatar image

updated 2019-06-26 14:16:14 -0500

But I found the message filter with a call back function can only work outside the while loop, and tf transform can only work inside a while loop.

I'm not sure that is true. Are you referring to the fact that you'd have to call lookupTransform(..) repeatedly (in TF 1 at least)?

You probably want to have matched pairs of <message, tf>. In that case: take a look at Using Stamped datatypes with tf::MessageFilter.


Edit: what you show in your edit is exacly what the tf::MessageFilter is for.

edit flag offensive delete link more

Comments

Thank you, I will have a look at it.

fangkd8 gravatar image fangkd8  ( 2019-06-26 16:45:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-25 18:21:50 -0500

Seen: 535 times

Last updated: Jun 26 '19