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

Creating tf from map to base_link

asked 2016-03-25 22:23:28 -0500

meeple gravatar image

updated 2016-03-25 22:26:28 -0500

I am using gmapping and robot_pose_ekf. gmapping provides tf from map to odom_combined, and robot_pose_ekf provides odom_combined to base_link. I want to see in rviz the location of the robot which is map to base_link. I therefore wrote a tf publisher to broadcast this transform.

#include <ros ros.h="">
#include <tf transform_listener.h="">
#include <tf transform_broadcaster.h="">

int main(int argc, char** argv){ ros::init(argc, argv, "tf_linker"); ros::NodeHandle node; tf::TransformListener listener; static tf::TransformBroadcaster br; ros::Rate rate(20.0); while (node.ok()){ tf::StampedTransform t_bo; tf::StampedTransform t_om; try{ listener.lookupTransform("base_link","odom_combined",ros::Time(0),t_bo); listener.lookupTransform("odom_combined","map",ros::Time::Time(0),t_om); } catch(tf::TransformException &ex){ ROS_ERROR("%s", ex.what()); ros::Duration(1.0).sleep(); continue; } tf::Transform transform; transform.setOrigin(t_bo.getOrigin()+t_om.getOrigin()); transform.setRotation(t_om.getRotation()+t_bo.getRotation()); br.sendTransform(tf::StampedTransform(transform,ros::Time::now(),"map","base_link")); } }

The problem is that the tf times seems to not be synced by fraction of a second.

Here is the error message:

    [ERROR] [1458961860.893869464]: Lookup would require extrapolation into the future.  Requested time 1458961860.893782533 but the latest data is at time 1458961860.893781547, when looking up transform from frame [map] to frame [odom_combined]
Warning: TF_OLD_DATA ignoring data from the past for frame base_link at time 1.45896e+09 according to authority unknown_publisher
Does tf require exactly the same time? That seems very unreasonable. How do I fix it? thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-27 12:57:35 -0500

Hi There, You don't need to broadcast this transform at all. In-fact doing do will confuse the TF system. If your system is already broadcasting the two TF's map -> odom_combined and odom_combined -> base_link then the job is done. The TF system can work out any transforms from map to base_link automatically.

To view this in Rviz you will need to make sure that the fixed frame is set to map. This is an option in the top left of the UI.

Hope this helps.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-25 22:23:28 -0500

Seen: 2,560 times

Last updated: Mar 27 '16