How can we use a tf listener and message filter in one node?
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?`
Asked by fangkd8 on 2019-06-25 18:21:50 UTC
Answers
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.
Asked by gvdhoorn on 2019-06-26 02:13:55 UTC
Comments
Thank you, I will have a look at it.
Asked by fangkd8 on 2019-06-26 16:45:42 UTC
Comments