Achieve a 78% improvement in real-time localization accuracy by transitioning from classical particle filter methods to robust pose graph-based algorithms using OGM2PGBM. This approach enables you to leverage any existing 2D reference map for enhanced precision and reliability.
//:
This repo contains the following two applications:
OGM2PGBM
: generate pose graph-based maps on 2D occupancy grid maps, which can be created from a TLS Point cloud or a BIM/CAD model.
This pose graph-based maps can be used for accurate localization in changing and dynamic environments, as demostrated in our paper.
The following animation shows an overview of the method and compares AMCL and Cartographer; the latter can be applied after leveraging the Ogm2Pgbm package. It is clear that for AMCL is more difficult to keep track of the pose of the robot in comparison with the performance of Cartographer.
GMCL & CARTO/SLAM_toolbox
: conbine the fast global localization feature of GMCL with the more accurate pose tracking performance of Cartographer/SLAM_toolbox
Additionally, it includes the packages amcl
, gmcl
, cartographer
and slam_toolbox
, so that they can be used and compared with a bagfile that should be located in the mounted directory ~/workspace
easily.
If you plan to use our docker container, with all the methods installed (Warning: it requires >5 GB of space) you only need to install docker.
If you don't want to use docker and only want to use the Ogm2Pgbm package, you can install the content of this folder and use it as a normal catkin package.
If you still want to install all the different localization methods, you can have a look at the docker file and install the respective dependencies on your local machine.
The workflow of OGM2PGBM is as follows, see the function new_map_callback(self, grid_map)
for details:
self.skeletonize()
)self.CPP()
)
/laserscan
topic (see self.raytracer()
)It produces /tf
, /clock
, /odom
, /scan
topics with frame robot_map
, robot_odom
and robot_base_link
.
Since /tf
is needed, python2.7
is used in this script.
This package already provides a Dockerfile, which means you can run it on any Ubuntu version. However, for ROS2 users, the final step of generating .pbstream or .posegraph is different. I will explain this in detail below.
This might also be a way to edit the posegraph map, but it's a bit convoluted.
Modify the map as needed by adding or removing barriers. The most crucial step is to completely black out the obstacles, ensuring there are no white areas within any obstacles!
Before | After |
---|---|
First clone the repository
git clone https://github.com/MigVega/Ogm2Pgbm.git
cd Ogm2Pgbm
Pull the Docker image
LihanChen has build a Docker image for easy deployment. You can also choose to build your own Docker image.
docker pull lihanchen2004/ogm2pgbm:latest
Create the container based on docker image
If you are using a self-built image, please modify the image_name
at the beginning of autorun.sh.
./autorun.sh
Copy the .pgm
and .yaml
files you need to convert to the Ogm2Pgbm/workspace/map/
directory on the host machine.
All following operations should be performed inside the Docker container.
Ensure the current terminal is within the Docker container.
MAP_NAME=OGM_empty
roslaunch ogm2pgbm ogm2pgbm.launch map_file:=/root/workspace/map/$MAP_NAME.yaml record:=true
Wait for 2-3 minutes. After completion, the program will output "Done" in the terminal.
Terminate the program with Ctrl+C. The rosbag will automatically be saved to /root/.ros/ogm2pgbm_sensordata.bag
.
If you want to use posegraph or pbstream file directly in ROS1, please follow the tutorial in this section.
After generating bagfiles, use Cartographer to generate pbstream or SLAM toolbox to generate posegraph maps. With the following command Cartographer will run in offline mode, which will generate pbstream quite fast, but without any visual output in rviz.
roslaunch cartographer_ros ogm2pgbm_my_robot.launch bag_filename:=/root/.ros/ogm2pgbm_sensordata.bag
You can also launch Slam_toolbox. (There will be some error report in the terminal, just ignore them and wait for some seconds.)
roslaunch slam_toolbox ogm2pgbm.launch bag_filename:=/root/.ros/ogm2pgbm_sensordata.bag
The target pbstream file will be generated automatically at /root/.ros/ogm2pgbm_sensordata.bag.pbstream
after . For slam_toolbox, you also need to click on the serialization button on the rviz plugin. The target files are also located at /root/.ros
.
If you want to use posegraph or pbstream file in ROS2, please follow the tutorial in this section.
All following operations should be performed on the host machine.
Get the CONTAINER ID
of ogm2pgbm:
docker ps
Save the rosbag to the host machine:
Remember to modify CONTAINER_ID
! Here, I save the rosbag from the container to the host's Download directory:
CONTAINER_ID=xxx
CONTAINER_PATH=/root/.ros/ogm2pgbm_sensordata.bag
DST_PATH=~/Downloads/
docker cp $CONTAINER_ID:$CONTAINER_PATH $DST_PATH
In ROS1, rosbag files have a .bag suffix, which is a binary format for storing ROS messages. ROS2 has improved and extended the rosbag format, adopting an SQLite-based database format that includes a .db3 database and a .yaml file.
Install the rosbags conversion package:
pip install rosbags
Navigate to the directory containing the rosbag and execute the following command to convert ogm2pgbm_sensordata.bag
to ogm2pgbm_sensordata.db3
:
rosbags-convert --src ogm2pgbm_sensordata.bag \
--dst ogm2pgbm_sensordata \
--src-typestore empty \
--dst-typestore ros2_humble \
--exclude-topic /rosout /robot/map /rosout_agg
Preparation
You can use the following rviz configuration file for visualization.
In the 1st Shell: Start the slam_toolbox to prepare for mapping
ros2 run slam_toolbox async_slam_toolbox_node --ros-args \
-p use_sim_time:=True \
-p odom_frame:=robot_odom \
-p base_frame:=robot_base_link \
-p map_frame:=robot_map \
-p do_loop_closing:=False \
-p max_laser_range:=10.0
In the 2nd Shell: Play the rosbag
ros2 bag play ogm2pgbm_sensordata
In the 3rd Shell: Start rviz2 for visualization
Ensure to modify the rviz2 configuration file path
rviz2 -d ~/Downloads/ogm2pgbm.rviz
After the rosbag finishes playing, set the filename in the SlamToolBoxPlugin
on the left side of the rviz2 interface, and click Serialize Map
button to save the posegraph map.
The reason for not using Ogm2Pgbm to directly generate the .posegraph map is due to a previously encountered issue where maps generated in ROS1 could not be loaded in ROS2. This is likely due to a version issue with slam_toolbox.
[localization_slam_toolbox_node-12] [ERROR] [1715064875.276643345] [slam_toolbox]: serialization::Read: Failed to read file: Exception: unregistered class
[localization_slam_toolbox_node-12] [ERROR] [1715064875.276682895] [slam_toolbox]: DeserializePoseGraph: Failed to read file: /home/lihanchen/NAVIGATION_WS/RM2024_SMBU_auto_sentry_ws/install/rm_bringup/share/rm_bringup/map/RMUC.
As it is already a package managed by catkin, if you have changed the src code or configuation inside the container, you need to do the following instructions to compile and install the package and source the env.
catkin_make_isolated --install --use-ninja --pkg ogm2pgbm
source install_isolated/setup.bash
All the node will be closed when the rviz is closed, including the rosbag node
The parameters of cartographer when using OGM2PGBM scripts to generate pbstream are as follows (see cartographer_ros/configuration_files/ogm2pgbm_my_robot.lua
)
remap /scan
or /odom
in launch file if needed
This project combines the pros of the two algorithms, using the fast global localization feature of GMCL and the accurate pose tracking performance of Cartographer or SLAM toolbox.
~/catkin_ws/src/gmcl_carto/gmcl_carto.py
./root/workspace
.python ~/catkin_ws/src/gmcl_carto/gmcl_carto.py
.gmcl_carto/gmcl_slamtoolbox.py
instead.If you use this library for an academic work, please cite the original paper.
@inproceedings{ ogm2pgbm:vega:2022:2DLidarLocalization,
author = {Vega Torres, M.A. and Braun, A. and Borrmann, A.},
title = {Occupancy Grid Map to Pose Graph-based Map: Robust BIM-based 2D- LiDAR Localization for Lifelong Indoor Navigation in Changing and Dynamic Environments},
booktitle = {eWork and eBusiness in Architecture, Engineering and Construction: ECPPM 2022},
editor = {Eilif Hjelseth, Sujesh F. Sujan, and Raimar Scherer},
publisher = {CRC Press},
year = {2022},
month = {Sep},
url = {https://publications.cms.bgu.tum.de/2022_ECPPM_Vega.pdf},
isbn = {978-1-003-35422-2},
doi = {10.1201/9781003354222-72}
}
Please also cite the code and data, if you use it for your experiments:
@software{ogm2pgbm:vega:code,
author = {Vega Torres, M.A.},
title = {{Occupancy Grid Map to Pose Graph-based Map for
long-term 2D LiDAR-based localization}},
month = nov,
year = 2022,
publisher = {Zenodo},
version = {1.0},
doi = {10.5281/zenodo.7330270},
url = {https://doi.org/10.5281/zenodo.7330270}
}
@misc{ogm2pgbm:vega:data,
author = {Vega-Torres, Miguel A. and Braun, Alexander and Borrmann, André},
title = {{OGM2PGBM}},
year = {2024},
type = {Dataset},
keywords = {LiDAR; Localization; SLAM; OGM; BIM},
doi = {10.14459/2024mp1749236}
}