convert 2d map (.pgm+.yaml) from slam toolboox to inflated cost map
To run this, you have to install the ROS 2 environment. Let's install ROS 2 Humble on the WSL Unbuntu 20.04:
sudo apt update
sudo apt upgrade -y
sudo apt install -y software-properties-common
sudo add-apt-repository universe
Add ROS 2 GPG key:
sudo apt install -y curl gnupg lsb-release
sudo mkdir -p /usr/share/keyrings
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
-o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Install Humble Desktop:
sudo apt update
sudo apt install -y ros-humble-desktop
Set ROS 2 in bashrc:
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc
Complete! You can test by using ROS 2 related commands:
ros2 topic list
Let's install Nav2 with ROS 2 Humble:
sudo apt update
sudo apt install -y ros-humble-navigation2 ros-humble-nav2-bringup
Move to the folder where your input map files exist:
cd /path/to/your/package/map_2d_convert
Run script:
./inflate_map.sh "input_map_file" "input_parameter_file" "output_map_name"
For example:
./inflate_map.sh map_3173.yaml nav2_params.yaml inflated_map
The map (.pgm, .yaml) will be saved in your current folder.
To view the map, use:
./show_map.sh "map_name"
For example:
./show_map.sh inflated_map

