Exercise 2.7: Map not found in Rviz2

Hello,

I’m having trouble getting the expected output for 2.7. I’m able to execute turtlebot teleop, run my cartographer package’s launch file, and start up rviz. However, when I do go to the rviz interface, it doesn’t show anything close to the expected output. I believe the error is that there is no map being transmitted to Rviz at this point, but I’m not sure of that. I have edited the setup.py to search for the launch and config files rather than the CMakeList.txt which caused the package to not run at all. That is the only deviation I’ve made from the instructions. Below is an image of the output I get.

The things I have tried are

  1. Executing "rviz tb3_cartographer.rviz.
  2. Changing the recommended values within the exercise instructions.
  3. Copy-pasting the provided source code in the answer section after 1 and 2 didn’t work.
  4. Running the launch file with and without a CMakeList.txt file (which originally isn’t included in the package so I don’t know why it’s being referenced, unless we need to create it which I tried.)

Any help would be greatly appreciated.

Hello @jgermann2017 ,

With the 1st proposed configuration:

TRAJECTORY_BUILDER_2D.min_range = 3.5
TRAJECTORY_BUILDER_2D.max_range = 7.0

you are not going to be able to create any map (because the maximum range of the lidar is 3.5). So it is expected that you don’t see any map.

Only with the 2nd configuration you will be able to create the map:

TRAJECTORY_BUILDER_2D.min_range = 1.0
TRAJECTORY_BUILDER_2D.max_range = 3.5

Also, when trying to visalize the map you should always use map as the Fixed Frame.

Thank you! It looks like it works well now. Although does the CMakeList.txt file do anything to the package? It wasn’t included when I first created the package, so I tried adding one and inserting the code provided, but nothing different seems to have happened.

Hello @jgermann2017 ,

What code did you add to the CMakeLists.txt file? What this file does depends on what you put in it.

The lines I added are the following:

install(DIRECTORY
  launch
  config
  DESTINATION share/${PROJECT_NAME}/
)

Ok @jgermann2017 ,

What this code does is to install the folders launch and config of your package inside the install folder of your workspace. You have to do this because the ROS system will look for these folders/files there.

Okay that makes sense. Although why wouldn’t it automatically be included within the package when we first create it? That seems like it would be a vital component.