Ask Your Question

Occupancy grid not displaying in Rviz

asked 2021-02-02 06:20:37 -0500

sisko gravatar image

updated 2021-02-02 19:25:39 -0500

I have a custom model which I created from my xacro files and I can move around using a teleop node. BUT I now want to map a virtual room and I added the AMCL and Gmapping nodes to my launch file but I notice a number of things in Rziv which are definately NOT right :

  1. The occupancy grid is not visible in Rviz so the room is not being mapped
  2. The /map topic has no data published into it
  3. 2D pose estimates in Rviz does not show particle filters

The following is my launch file:

<?xml version="1.0"?>

    <!-- PARAMETERS -->
    <param name="robot_description" command="$(find xacro)/xacro $(find sweep_bot)/urdf/cleaner.xacro"/>

    <!-- RVIZ -->
    <node name='robot_state_publisher' pkg='robot_state_publisher' type='robot_state_publisher'/>
    <node name='joint_state_publisher_gui' pkg='joint_state_publisher_gui' type='joint_state_publisher_gui'/>
    <node name='rviz' pkg='rviz' type='rviz'/>

    <!-- GAZEBO -->
    <include file="$(find gazebo_ros)/launch/willowgarage_world.launch"></include>
    <node name='sweeper_bot' pkg='gazebo_ros' type='spawn_model' args='-urdf -model sweeper -param robot_description'/>

    <!--- Run AMCL --> 
    <include file="$(find amcl)/examples/amcl_omni.launch" />

    <!-- GMAPPING -->
    <node pkg="gmapping" type="slam_gmapping" name="gmapping" output="screen"></node>

    <!-- Move Base -->
    <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen"/>


My /tf and /odom topics show data is being published into them.

My terminal prints the following message repeatedly:

[ WARN] [1612313212.923369324, 5.005000000]: Timed out waiting for transform from base_link to map to become available before running costmap, tf error: canTransform: source_frame base_link does not exist.. canTransform returned after 0.1 timeout was 0.1.

image description As shown in the image above, rviz shows the laser detects obstacles but the occupancy grid does not display.

My questions :

  • I know my /tf is generated from joints as defined in my urdf file(s) but is the data in the /odom topic also auto generated from the urdf ?

  • Can anyone give me any insight into why my /map topic is empty ?


Below is the tf : image description

edit retag flag offensive close merge delete


First AMCL is for localization when you already know the map and gmapping is for localization while creating the map so they shouldn't be used at the same time. You should try to create the map first using only gmapping and then use AMCL with the map you've created.

Now you might have something wrong with your TFs, can you show us your tf tree ? (Using rosrun rqt_tf_tree rqt_tf_tree)

Delb gravatar image Delb  ( 2021-02-02 08:33:27 -0500 )edit

@Delb: Thanks for your input. I added my tf tree as requested.

sisko gravatar image sisko  ( 2021-02-02 17:52:29 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-02-02 23:29:50 -0500

sisko gravatar image

I figured it out.

The GMapping node was missing configuration parameters which would tell it agongst other things, what topic to publish map data to. See below :

<node pkg="gmapping" type="slam_gmapping" name="gmapping" output="screen">
   <param name="map_frame" value="map"/>
   <param name="base_frame" value="chasis"/> 
   <param name="odom_frame" value="odom"/> 

All available parameters are listed at

edit flag offensive delete link more

answered 2021-02-02 08:29:00 -0500

/odom topics are not automatically generated by urdf. For example, you need to use diff_drive_controller to generate /odom topics from urdf.

Also, even if you can generate an /odom topic, it may not create a map.

Even if you can generate an /odom topic, the map may not be created, because amcl and gmapping are not usually handled at the same time. amcl is a package that uses /map and /scan for localization. gmapping is a package that uses /scan to localize while issuing /map.

  1. Generate /map by running gmappingwithout using amcl.
  2. Save it with map_saver.
  3. Read the saved map with map_server and publish a /map topic.
  4. Localization with amcl.

You can probably get what you want by proceeding as follows.

edit flag offensive delete link more


I appreciate your comments. There is a lot I don't know so please bare with me.

The AMCL node in the launch file is commented out of my current build BUT I still find the occupancy grid does not display in Rviz.

Also, isn't the diff_drive_controller meant for a two wheeled robot ? My robot is four wheeled.

I added my tf tree above if that would help clarify things.

sisko gravatar image sisko  ( 2021-02-02 19:09:09 -0500 )edit

I'm glad to hear that it has been resolved. diff_drive_controller seems to be a node for motorcycles. ( I've only used it on two wheels. ) However, there seems to be a way to use it on four wheels.

miura gravatar image miura  ( 2021-02-04 05:48:38 -0500 )edit

@miura: Thank you for your input. I've only ever hear of the diff_drive_controller used on robots like the turtlebot 3 in a side-by-side configuration. It would be interesting to see if it can be used for motocycles.

sisko gravatar image sisko  ( 2021-02-04 07:19:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-02-02 06:20:37 -0500

Seen: 125 times

Last updated: Feb 02