Skip to content

Mapping

fontysrobotics edited this page Dec 23, 2020 · 1 revision

6.1 intro:

In this tutorial, we will look at how to use the robot we built in the previous tutorials to map an environment, like the house world we just made. We will look at what mapping is exactly, and how it works. Then we will look at how to use multiple LIDARS while mapping, and build a launch file that allows us to map our world, and save the map for later use. Finally, we will actually launch the simulation from the launch file we just built, and map the house. It is not recommended to follow this tutorial before finishing the ROS basics tutorial.

6.2 What is mapping:

Mapping is the process of taking raw sensor data from the LIDARs, and using it to determine where obstacles are located around the robot. All these obstacles can be collated into one map, which can then be saved and later used for navigation. This allows the robot to have knowledge of parts of the world that are beyond it’s sensor range, and plan accordingly.

6.3 How does mapping work:

The gmapping algorithm we will be using works by reading the data from the laser scan topic, as well as the position and orientation of the robot. It combines this data to work out where the sensor readings are coming from in the world, and adds all the data into one map, which is saved as a map.yaml file.

6.4 IRA_laser_tools:

On this robot, we want to use two LIDARs, to be able to see around the manipulator that is in the middle of the body. However, the mapping algorithm we are using only takes input from one laser scan topic. To solve this problem, a ROS package was made called ira laser tools. This package allows us to take data from multiple laser scan topics, and merge it into one output topic called scan that the mapping algorithm can use. First we need to download the package, and put it in its own directory in the catkin_ws/src directory. Then, rebuild the catkin workspace with catkin_make.

Navigate to the launch folder and open “laserscan_multi_merger.launch”. We want to edit the input topics to /scan1 and /scan2 (these are the topic names we defined earlier), and edit the output topic to be /scan, since this is the default topic gmapping listens to.

6.5 Creating the launch file:

The last step for us to start mapping is to create a launch file that will launch all the required ROS nodes, with the proper parameters.

Navigate to the launch directory in the example_urdf package, and create a file called mapping.launch:

$ cd ~/catkin_ws/src/example_urdf/launch

$ code mapping.launch

this file can be found in the git repo under tutorial_files / mapping/launch

6.6 mapping:

Now that we have set up our environment and launch files, we will start the mapping process. For this, we will need to launch all the launch files we made. Run the following commands in separate terminals in order:

$ roslaunch example_urdf gazebo.launch

$ roslaunch ira_laser_tools laserscan_multi_merger.launch

$ roslaunch example_urdf mapping.launch

In the rviz display panel click add -> by topic -> map Then, in the global options change the fixed frame to map

Then, in a new terminal:

$ rosrun teleop_twist_keyboard teleop_twist_keyboard.py

You can now start navigating the robot around the environment. Notice that when you do so, the map is being updated, as visualised in rviz.

In order to get a high quality map, it can be necessary to do multiple passes. When done mapping we will create a new folder in the package and call it maps, and save the map by running the following commands in a new terminal: $ cd catkin_ws/src/example_urdf/ $ mkdir maps $ cd maps/ $ rosrun map_server map_saver -f map

ROS will create 2 files, a .yaml and a .pgm file, which we will use later in the navigation tutorial.