0
$\begingroup$

Rosanswers logo

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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I would take a look at the Views section of the manual and make sure your view is attached to your base_link frame.

I think rviz has changed a little since the manual was written, so things may be in slightly different places, but you should still be able to find the Views panel and set the frame to base_link.


Originally posted by ahendrix with karma: 47576 on 2014-02-21

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Orgrim on 2014-02-21:
nope, I tried setting the target frame of the view but it didn't change anything. And there's no error from rviz either in rqt_console.

Comment by demmeln on 2014-02-24:
so fixed_frame is map and target_frame is base_link?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.