πΊοΈ Mapping#
Mapping refers to the process of creating a symbolic representation of the environment using the robotβs sensors. Having a map of the environment enables the robot to efficiently plan paths to reach a goal location, avoid obstacles, and improve localization accuracy by correcting odometry errors.
There are different types of maps that can be created depending on the sensors available on the robot, the environment in which it operates and the application requirements.
The process of creating an accurate map of the environment while localizing the robot is called SLAM which stands for Simultaneous Localization and Mapping. As it is a very common problem in robotics, there are many algorithms and techniques to solve it, such as:
EKF SLAM
Particle Filter SLAM
Graph SLAM
Occupancy Grid Mapping#
Warning
Your robot can create a 2D OccupancyGrid only if it is equipped with a 2D Laser Sensor.
An OccupancyGrid is a 2D symbolic representation of the environment that expresses the world as a grid of cells, where each cell can be either occupied (100), free (0) or unknown (-1).
For the creation of a 2D Occupancy Grid, PAL Robots use the SLAM toolbox package which implements a Graph-based SLAM algorithm.
As the robot moves in the environment, either teleoperated or autonomously, the SLAM algorithm processes the odometry information, the laser scans and creates a Graph representative of the robot poses and the landmarks in the environment. This Graph is then optimized to correct odometry and measurement errors and create an accurate and consistent map of the environment.
Usage#
PAL Robots already come with some pre-configured and tested slam_toolbox
configurations that are customized
for different environments and different robots.
To list all the available configurations, you can use the command:
ls /opt/pal/$PAL_DISTRO/share/pal_navigation_cfg_params/params/slam_toolbox/
By default, PAL Robots start in localization mode. To start mapping, you first need to stop the localization pipeline with the command:
pal module stop localization
And then start the mapping pipeline with the command:
pal module start slam
Attention
Both the localization and the mapping pipelines will publish a transform between the frames map and base_footprint. For this reason, you should not start both pipelines at the same time. When starting the mapping pipeline make sure you first shut down the localization pipeline and vice-versa.
Once you are satisfied with the created map, you can save it using the slam_toolbox
RViz plugin:
or using the /slam_toolbox/save_map with the following command:
ros2 service call /slam_toolbox/save_map slam_toolbox/srv/SaveMap "name:
data: 'my_map'"
Configuration#
In addition to the available PAL configurations for the slam_toolbox
package, you can create new configurations
for your robot. To do so, you first need to create a new directory in the .pal
folder of your robot.
mkdir -p ~/.pal/pal_navigation_cfg_params/params/slam_toolbox
And then, within this folder, you can create a new slam_toolbox
configuration file.
touch ~/.pal/pal_navigation_cfg_params/params/slam_toolbox/my_slam_config.yaml
Within the newly created my_slam_config.yaml
file, you can insert your custom slam_toolbox
parameters.
For the list of available parameters, their meaning and how they affect the SLAM algorithm, you can refer to the
slam_toolbox configuration guide.
When creating a new Navigation configuration file, apart from the node parameters, you also need to specify the
robot to which they refer.
pal_navigation_cfg:
ros__parameters:
supported_robots:
- some_pal_robot # e.g. tiago, omni_base, tiago_pro, etc.
slam_toolbox_sync:
# Your slam_toolbox Parameters
Once created, to start using your custom slam_toolbox
configuration, you need to set it in the slam pipeline by
modifying the <robot>_slam.yaml
file in the <robot>_2dnav
package.
sudo vi /opt/pal/$PAL_DISTRO/share/<robot>_2dnav/params/<robot>_slam.yaml
And then, change the params
field of the slam_toolbox_sync to the name of your custom slam_toolbox
configuration file.
nodes:
# Other nodes
slam_toolbox_sync:
app: slam_toolbox_sync
params: [my_slam_config]
Attention
Make sure that the name of the custom slam_toolbox
configuration file you use in the params
field
(my_slam_config
) is the same as the name of the file you created in the .pal
folder
(my_slam_config.yaml
).
Finally, to apply the changes and start using the new slam_toolbox
configuration,
you need to restart the slam pipeline with the command:
pal module restart slam
ROS 2 API#
To interact with the slam_toolbox_sync, you can refer to the following ROS 2 interfaces:
Topics |
Services |
---|---|