TF Transform on a callback

asked 2015-12-03 04:16:18 -0500

metRo_ gravatar image

I have two sensors, camera and lidar, that publish the data on their specific frame. I had setup a TF transform for my robot and sensors.

When I read the callback data I have to transform all the sensors data to the same frame.

if (!tf_->waitForTransform(frame_id, camera_frame, msg.header.stamp, ros::Duration(1.0)))
    ROS_WARN_STREAM ("VISION CALLBACK: Timed out waiting for transform from " << camera_frame << " to "
                     << frame_id << " at " << ros::Time().toSec());

target.header.frame_id = frame_id;
target.header.stamp = msg.header.stamp;

target_in_vision.header.frame_id = camera_frame;
target_in_vision.header.stamp = msg.header.stamp;
target_in_vision.pose.position.x = msg.x;
target_in_vision.pose.position.y = msg.y;
target_in_vision.pose.position.z = 0.0;
target_in_vision.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);

tf_->transformPose(frame_id, target_in_vision, target);

Is it ok to use the msg.header.stamp that have been generated at sensor acquisition or should I use ros::time::now()? All the code I saw on the internet use ros::time::now() what for me doesn’t make sense because it isn't the same time of sensor acquisition.

BTW on my robot lidar and camera are always on the same position in the robot so have to include the time for tf transform make even less sense.

I read the TF tutorials but I'm still a little confused.

edit retag flag offensive close merge delete


Hi, I'm working on a similar problem. Did you have any luck with the timestamp issue?

Venkat Ganesh gravatar image Venkat Ganesh  ( 2016-05-19 09:43:00 -0500 )edit

Hi, I'm using the msg.header.stamp without any issue, what is your problem?

metRo_ gravatar image metRo_  ( 2016-07-20 16:55:12 -0500 )edit