vSLAM using rtabmap and Realsense
By: Helena Sieh
By: Helena Sieh
This tutorial will go over how to setup the realsense camera in RTABmap and run visual SLAM.
https://github.com/IntelRealSense/librealsense
https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy
DO:
Build rtabmap from source and make sure to remove rtabmap installation before building from source.
Remove rtabmap installation:
sudo apt-get remove ros-noetic-rtabmap
sudo apt-get autoremove
Install Dependencies:
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
git \
libboost-all-dev \
libeigen3-dev \
libopencv-dev \
libpcl-dev \
libflann-dev \
libvtk6-dev \
libusb-1.0-0-dev \
libyaml-cpp-dev \
libgoogle-glog-dev \
libgflags-dev \
ros-noetic-pcl-ros \
ros-noetic-vision-opencv \
ros-noetic-sensor-msgs \
ros-noetic-message-filters \
ros-noetic-tf2-ros \
ros-noetic-tf2-eigen
Build from Source:
cd ~/catkin_ws/src
git clone https://github.com/introlab/rtabmap.git
cd ~/catkin_ws
catkin_make
(may have to run catkin_make_isolated if there are non ROS files)
source devel/setup.bash
Launch rtabmap gui:
rtabmap
Install realsense2_camera as a debian package of ROS distribution by using the command: sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
This will install both realsense2_camera and its dependents, including librealsense2 library and matching udev-rules.
Install Intel® RealSense™ ROS from Sources:
In terminal type following commands:
cd ~/catkin_urop/src
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
*Make sure all dependent packages are installed. You can check .travis.yml file for reference.
*Make sure that the ros package ddynamic_reconfigure is installed. If ddynamic_reconfigure cannot be installed using APT
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
The published topics differ according to the device and parameters. After running the above command with D435i attached, the following list of topics will be available (This is a partial list. For full one type rostopic list):
/camera/color/camera_info
/camera/color/image_raw
/camera/color/metadata
/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/depth/metadata
/camera/extrinsics/depth_to_color
/camera/extrinsics/depth_to_infra1
/camera/extrinsics/depth_to_infra2
/camera/infra1/camera_info
/camera/infra1/image_rect_raw
/camera/infra2/camera_info
/camera/infra2/image_rect_raw
/camera/gyro/imu_info
/camera/gyro/metadata
/camera/gyro/sample
/camera/accel/imu_info
/camera/accel/metadata
/camera/accel/sample
/diagnostics
This section is about mapping the environment using the realsense and rtabmap.
roslaunch realsense2_camera rs_camera.launch
By using this command, this will stream all camera sensors and publish on the appropriate ROS topics listed above.
Other stream resolutions and frame rates can optionally be provided as parameters to the 'rs_camera.launch' file.
To run rtabmap, simply type rtabmap in the terminal.
Create a new database.
By utilizing the RTAB-Map database, we can visualize, optimize, edit, refine and interact with previously collected map data (. db file), allowing us to explore and analyze the environment in detail.
In the interface, make sure that the realsense camera is detected and connected.
Make sure that mapping mode is selected.
To do so, go to Detection in the toolbar. Make sure there is a dot indicating that mapping mode is on.
Loop Closure Detection:
The process of identifying the places that a robot has visited before, which can help the robot relocate when it loses its trajectory due to motion blur, forming a topologically consistent trajectory map
Make sure loop closure detection is enabled!
Helpful Tips for Mapping:
Make sure to click on the pause on loop closure detection
Make slow movements to enable precise mapping
When the screen turns red, pause mapping and restart.
When restarting, be sure to revisit previously mapped areas to confirm that RTAB-Map has recognized the location you've already visited. This will allow you to review or further analyze the detected loop before continuing to create the map.
Full Built Map of Lab Space
Open3d Map
This section will go over how to configure and save the point cloud data into a .ply or .pcd file.