Rosanswers logo

Hi! I've just started with ROS and I need help understanding how TF works.

I'm trying to run this simulation on ROS2 Eloquent:
and I'd like to use SLAM from Slam Toolbox:

The robot has 2 frames:

  <!-- output -->

The robot is positioned at -37 5.6 in the "world":

<!-- Dolly -->
  <pose>-37 5.6 0.33 0 0 0</pose>

When I run slam_toolbox it outputs /map topic with OccupancyGrid messages.
I'm using static_transform_publisher to transform map frame to chassis with all zeroes.

Now in RViz I see all 3 frames in the center of the grid (map, chassis and odom_demo).
I can also see the laser scan results which start from the center of the grid.

However I see the map display way outside of the grid.
I suspect it's because robot position is at -37 5.6, chassis and map are statically linked through static_transform_publisher, which "pushes" map away from center. Here is how it looks(don't have enough point to post an image directly):

What I'd like to see is map being in the center and see robot move on the grid as I move the robot in simulation.
Something like the last gif on https://github.com/SteveMacenski/slam_toolbox

Am I correct in assuming that I need:

  1. Make map a "fixed frame" in Rviz
  2. Somehow make transformation between map and odom_demo dynamic so it would take position calculated via slam_toolbox and transform it to the robot position on the grid.

This way "OccupancyGrid" will stay at the center of RViz grid and when robot moves it will change odom_demo position which will change chassis frame with it.
How do I do that? Does slam_toolbox already have this transformation?
Is this even a correct understanding of what TF means?

Another question:
I've been reading https://www.ros.org/reps/rep-0105.html and I think my frames correspond to:
earth -> don't have one, I've also seen world in a couple of places, how do I create one?
map -> map
odom -> odom_demo
chassis -> base_link

Is this correct?


Originally posted by Leonti on ROS Answers with karma: 62 on 2020-02-12

Post score: 0


1 Answer 1


Rosanswers logo

It seems like my initial understanding was correct - chassis -> map transforms were already published by Slam Toolbox, I just had to select map as a Fixed Frame in Rviz.

The second problem was not using the sim time in Slam Toolbox, so the map was published with the system's timestamp, so the transform only worked in one direction (I could select odom_demo as a fixed frame in RViz, but not the map).
Switching to sim time and checking Use Timestamp in RViz for the Map solved the problem.

Originally posted by Leonti with karma: 62 on 2020-02-22

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

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