In my project, I cannot get rviz to "center" the map based on the base_link's position. I have a node that publishes two transforms, one between base_link and a frame containing the corrected odometry position, and the other between this odometry frame and the map frame. However, I tried checking the tf tree using view_frames, and everything seems in order: the odometry frame is child to base_link and the map frame is child to the odometry's. The only odd thing I noticed is that if I try and echo the transform between base_link and the map, or viceversa, it fails once and then starts returning the transform. anyway, the code I use to publish these two transforms is:
ros::Time current_time=ros::Time::now();
tf::Transform l_to_o=tf::Transform(tf::createQuaternionFromYaw(theta_best), tf::Vector3(x_best, y_best, 0.0));
l_to_o=l_to_o.inverse();
odom_broadcaster.sendTransform(tf::StampedTransform(l_to_o, current_time, "/base_link", "/slam_gpu/odom"));
tf::Transform o_to_l=tf::Transform(tf::createQuaternionFromYaw(theta_old), tf::Vector3(x_old, y_old, 0.0));
tf::Transform o_to_m=(o_to_l*l_to_o);
odom_broadcaster.sendTransform(tf::StampedTransform(o_to_m, current_time, "/slam_gpu/odom", "/slam_gpu/map"));
Originally posted by Orgrim on ROS Answers with karma: 11 on 2014-02-21
Post score: 0
Original comments
Comment by ahendrix on 2014-02-21:
It sounds like your tf tree is probably OK. Are you seeing any error messages from rviz?
Comment by demmeln on 2014-02-24:
anything suspicious in tf_monitor?
Comment by demmeln on 2014-02-24:
also, what exactly do you mean by "center" the map?
Comment by Orgrim on 2014-02-24:
I'm sorry, in the end the problem didn't have anything to do with the tf.. I just forgot to set the frame id of the map upon publishing it. So the tf was there, but the map wasn't connected to the frame.