Files
rtabmap_ros/README.md
T

170 lines
9.6 KiB
Markdown
Raw Normal View History

2021-09-20 16:07:39 -04:00
rtabmap_ros [![Build Status](https://github.com/introlab/rtabmap_ros/actions/workflows/ros1.yml/badge.svg)](https://github.com/introlab/rtabmap_ros/actions/workflows/ros1.yml) [![docker](https://github.com/introlab/rtabmap_ros/actions/workflows/docker.yml/badge.svg)](https://github.com/introlab/rtabmap_ros/actions/workflows/docker.yml)
2021-09-21 08:01:25 -04:00
=======
2014-11-25 17:51:23 -05:00
2014-11-28 10:15:17 -05:00
RTAB-Map's ROS package.
2014-11-25 17:51:23 -05:00
2016-06-04 18:47:05 -04:00
For more information, demos and tutorials about this package, visit [rtabmap_ros](http://wiki.ros.org/rtabmap_ros) page on ROS wiki.
2014-11-25 17:51:23 -05:00
2016-06-04 18:47:05 -04:00
For the RTAB-Map libraries and standalone application, visit [RTAB-Map's home page](http://introlab.github.io/rtabmap) or [RTAB-Map's wiki](https://github.com/introlab/rtabmap/wiki).
2014-11-25 17:51:23 -05:00
2017-03-23 13:45:50 -04:00
# Installation
2014-11-27 13:51:23 -05:00
2020-01-31 10:32:41 -05:00
## ROS2 distribution
**Under construction**: see [ros2 branch](https://github.com/introlab/rtabmap_ros/tree/ros2#rtabmap_ros).
2017-03-23 13:45:50 -04:00
## ROS distribution
2017-03-23 14:03:48 -04:00
RTAB-Map is released as binaries in the ROS distribution.
* Noetic
```
2020-07-30 10:04:07 -04:00
$ sudo apt install ros-noetic-rtabmap-ros
```
2019-08-16 11:29:10 -04:00
* Melodic
```
2020-07-30 10:04:07 -04:00
$ sudo apt install ros-melodic-rtabmap-ros
2019-08-16 11:29:10 -04:00
```
2017-03-23 13:45:50 -04:00
* Kinetic
```
$ sudo apt-get install ros-kinetic-rtabmap-ros
```
* Indigo
```
$ sudo apt-get install ros-indigo-rtabmap-ros
```
2019-02-28 10:17:55 -05:00
* For armhf architecture, `ros-indigo-rtabmap-ros` is not available. Install `ros-indigo-rtabmap` and build from source `rtabmap_ros` using the `indigo-devel` branch.
```
$ cd catkin_ws
$ git clone -b indigo-devel https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
$ catkin_make -j1
```
2014-11-27 13:51:23 -05:00
When launching `rtabmap_ros`'s nodes, if you have the error `error while loading shared libraries...`, try `ldconfig` or add the next line at the end of your `~/.bashrc` to fix it:
2017-03-23 13:45:50 -04:00
2017-03-23 13:46:30 -04:00
```bash
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/noetic/lib/x86_64-linux-gnu
2017-03-23 13:46:30 -04:00
```
2016-06-02 14:03:14 -04:00
2019-03-01 11:46:56 -05:00
### Docker
* Go to [docker](https://github.com/introlab/rtabmap_ros/tree/master/docker) directory for an example.
2019-03-01 11:46:56 -05:00
2017-03-23 13:45:50 -04:00
## Build from source
This section shows how to install RTAB-Map ros-pkg on **ROS Hydro/Indigo/Jade/Kinetic/Lunar/Melodic/Noetic** (Catkin build). RTAB-Map works only with the PCL >=1.7, which is the default version installed with ROS Hydro/Indigo/Jade/Kinetic/Lunar/Melodic/Noetic (**Fuerte and Groovy are not supported**).
2014-11-27 13:51:23 -05:00
* The next instructions assume that you have set up your ROS workspace using this [tutorial](http://wiki.ros.org/catkin/Tutorials/create_a_workspace). I will use `noetic` prefix for convenience, but it should work with Hydro, Indigo, Jade, Kinetic, Lunar and Melodic. The workspace path is `~/catkin_ws` and your `~/.bashrc` contains:
2014-11-27 13:51:23 -05:00
2017-03-23 13:45:50 -04:00
```bash
$ source /opt/ros/noetic/setup.bash
2017-03-23 13:45:50 -04:00
$ source ~/catkin_ws/devel/setup.bash
```
2016-04-17 13:51:56 -04:00
2017-03-23 14:03:22 -04:00
0. Required dependencies
* The easiest way to get all them (Qt, PCL, VTK, OpenCV, ...) is to install/uninstall rtabmap binaries:
```bash
2020-07-30 10:03:44 -04:00
$ sudo apt install ros-noetic-rtabmap ros-noetic-rtabmap-ros
$ sudo apt remove ros-noetic-rtabmap ros-noetic-rtabmap-ros
2017-03-23 14:03:22 -04:00
```
2017-03-23 13:45:50 -04:00
2017-03-23 14:03:22 -04:00
1. Optional dependencies
* If you want SURF/SIFT on Indigo/Jade/Melodic/Noetic (Hydro/Kinetic has already SIFT/SURF), you have to build [OpenCV]([OpenCV](http://opencv.org/)) from source to have access to *xfeatures2d* and *nonfree* modules (note that SIFT is not in *nonfree* anymore since OpenCV 4.4.0). Install it in `/usr/local` (default) and rtabmap library should link with it instead of the one installed in ROS.
* On Indigo, I recommend to use latest 2.4 version ([2.4.11](https://github.com/Itseez/opencv/archive/2.4.11.zip)) and build it from source following these [instructions](http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#building-opencv-from-source-using-cmake-using-the-command-line). RTAB-Map can build with OpenCV3+[xfeatures2d](https://github.com/Itseez/opencv_contrib/tree/master/modules/xfeatures2d) module, but `rtabmap_ros` package will have libraries conflict as `cv_bridge` is depending on OpenCV2. If you want OpenCV3+, you should build [vision-opencv](https://github.com/ros-perception/vision_opencv) package yourself (and all ros packages depending on it) so it can link on OpenCV3+.
* On Kinetic/Melodic/Noetic, build from source with *xfeatures2d* module (and *nonfree* module if needed) the same OpenCV version already installed on the system. You will then avoid breaking `cv_bridge` with `rtabmap_ros`. If you want to install a more recent OpenCV version, I recommend to uninstall `libopencv*` libraries (with all ros packages depending on it) and rebuild all those ros packages in your catkin workspace (to make sure `cv_bridge` is linked on the OpenCV version you just compiled).
2015-10-06 09:51:31 -04:00
2020-07-30 10:02:51 -04:00
* [g2o](https://github.com/RainerKuemmerle/g2o): Should be already installed by `ros-noetic-libg2o`.
2015-10-06 09:51:31 -04:00
2020-07-30 09:46:26 -04:00
* [GTSAM](https://gtsam.org/get_started/): Install via PPA to avoid building from source. If you install from source, make sure to build with `cmake -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF -DGTSAM_USE_SYSTEM_EIGEN=ON`.
* [libpointmatcher](https://github.com/ethz-asl/libpointmatcher): **Recommended** if you are going to use lidars. Follow their [instructions](https://github.com/ethz-asl/libpointmatcher#quick-start) to install.
2017-03-23 13:45:50 -04:00
2017-03-23 14:03:22 -04:00
2. Install RTAB-Map standalone libraries. Add `-DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel` to `cmake` command below if you want to install in your Catkin's devel folder without `sudo`. **Do not clone in your Catkin workspace**.
2015-10-06 09:51:31 -04:00
```bash
2017-03-23 13:45:50 -04:00
$ cd ~
$ git clone https://github.com/introlab/rtabmap.git rtabmap
$ cd rtabmap/build
$ cmake .. [<---double dots included]
2017-04-05 09:16:05 -04:00
$ make
2017-03-23 13:45:50 -04:00
$ sudo make install
```
2015-10-06 09:51:31 -04:00
2017-03-23 14:03:22 -04:00
3. Install RTAB-Map ros-pkg in your src folder of your Catkin workspace.
2014-11-27 13:51:23 -05:00
2017-03-23 13:45:50 -04:00
```bash
$ cd ~/catkin_ws
$ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
2017-04-05 09:16:05 -04:00
$ catkin_make -j1
2017-03-23 13:45:50 -04:00
```
* Use `catkin_make -j1` if compilation requires more RAM than you have (e.g., some files require up to ~2 GB to build depending on gcc version).
* Options:
* Add `-DRTABMAP_SYNC_MULTI_RGBD=ON` to `catkin_make` if you plan to use multiple cameras.
* Add `-DRTABMAP_SYNC_USER_DATA=ON` to `catkin_make` if you plan to use user data synchronized topics.
2014-11-27 13:51:23 -05:00
2020-04-03 21:05:07 -04:00
## Build from source for Nvidia Jetson
These instructions are for Jetpack 3 (Ubuntu 16.04 with ROS Kinetic). For **Jetpack 4** (Ubuntu 18.04 with ROS Melodic), see this [post](https://github.com/introlab/rtabmap/issues/427#issuecomment-608052821).
2018-09-14 23:51:53 +00:00
To use `rtabmap_ros` on Jetson, you can follow the instructions above if you don't care if OpenCV is built for Tegra. However, if you want `rtabmap` to use OpenCV 4 Tegra, we must re-build [vision_opencv](https://github.com/ros-perception/vision_opencv) stack from source too to avoid conflicts with [vision_opencv](https://github.com/ros-perception/vision_opencv) stack binaries from ros (which are linked on a not optimized version of OpenCV). Here are the steps:
1. Install [JetPack](https://developer.nvidia.com/embedded/jetpack) with OpenCV on the Jetson.
2. Do steps 1.2 and 1.3 from http://wiki.ros.org/kinetic/Installation/Ubuntu
3. Install non-opencv dependent ros packages:
2020-03-10 11:54:22 -04:00
* Jetpack 3: `sudo apt-get install ros-kinetic-ros-base ros-kinetic-image-transport ros-kinetic-tf ros-kinetic-tf-conversions ros-kinetic-eigen-conversions ros-kinetic-laser-geometry ros-kinetic-pcl-conversions ros-kinetic-pcl-ros ros-kinetic-move-base-msgs ros-kinetic-rviz ros-kinetic-octomap-ros ros-kinetic-move-base libhdf5-openmpi-dev libsuitesparse-dev`
2018-09-14 23:51:53 +00:00
4. Do step 1.6 from http://wiki.ros.org/kinetic/Installation/Ubuntu
5. [Create your catkin workspace](http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment#Create_a_ROS_Workspace)
2018-09-14 21:35:04 -04:00
6. *Optional:* Install g2o and/or GTSAM dependencies as above (increase visual odometry and graph optimization accuracy).
2020-03-10 11:58:10 -04:00
7. To avoid [libGL undefined errors](https://devtalk.nvidia.com/default/topic/1007290/jetson-tx2/building-opencv-with-opengl-support-/post/5141945/#5141945):
2018-09-15 01:14:54 +00:00
```
$ cd /usr/lib/aarch64-linux-gnu/
2020-03-10 11:58:10 -04:00
# Jetpack 3:
2018-09-15 01:14:54 +00:00
$ sudo ln -sf tegra/libGL.so libGL.so
2020-03-10 11:58:10 -04:00
# Jetpack 4:
sudo ln -sf libGL.so.1.0.0 libGL.so
2018-09-15 01:14:54 +00:00
```
2020-03-10 11:58:10 -04:00
2020-04-03 21:05:07 -04:00
8. To avoid [libvtkproj4 errors](https://github.com/PointCloudLibrary/pcl/issues/1594#issuecomment-283873617):
2018-09-15 01:14:54 +00:00
```
$ sudo ln -s /usr/lib/aarch64-linux-gnu/libvtkCommonCore-6.2.so /usr/lib/libvtkproj4.so
$ sudo ln -s /usr/lib/aarch64-linux-gnu/libvtkCommonCore-6.2.so /usr/lib/aarch64-linux-gnu/libvtkproj4-6.2.so.6.2.0
```
9. Install RTAB-Map standalone libraries. Add `-DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel` to `cmake` command below if you want to install in your Catkin's devel folder without `sudo`. **Do not clone in your Catkin workspace**.
2018-09-14 23:51:53 +00:00
```bash
$ cd ~
$ git clone https://github.com/introlab/rtabmap.git rtabmap
$ cd rtabmap/build
$ cmake .. [<---double dots included]
$ make
$ sudo make install
```
2018-09-15 01:14:54 +00:00
10. Clone [vision_opencv](https://github.com/ros-perception/vision_opencv), [image_transport_plugins](https://github.com/ros-perception/image_transport_plugins) and `rtabmap_ros` packages in your catkin_ws:
2018-09-14 23:51:53 +00:00
2018-09-14 21:37:38 -04:00
```bash
2018-09-14 23:51:53 +00:00
$ cd ~/catkin_ws
$ git clone https://github.com/ros-perception/vision_opencv src/vision_opencv
$ git clone https://github.com/ros-perception/image_transport_plugins.git src/image_transport_plugins
2018-11-05 07:28:10 -08:00
$ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
2018-09-14 21:37:38 -04:00
$ catkin_make -j2
```
2017-03-23 13:45:50 -04:00
### Update to new version
2014-11-27 13:51:23 -05:00
2015-05-13 15:12:04 -04:00
```bash
2018-02-16 10:46:32 -05:00
###########
# rtabmap
###########
2018-03-27 15:53:24 -04:00
$ cd rtabmap
2018-02-16 10:47:44 -05:00
$ git pull origin master
$ cd build
2014-11-27 14:49:14 -05:00
$ make
$ make install
2016-10-11 14:39:15 -04:00
# Do "sudo make install" if you installed rtabmap in "/usr/local"
2014-11-27 13:51:23 -05:00
2018-02-16 10:46:32 -05:00
###########
# rtabmap_ros
###########
2014-12-02 09:44:08 -05:00
$ roscd rtabmap_ros
2014-11-27 14:49:14 -05:00
$ git pull origin master
2018-03-27 15:53:24 -04:00
$ roscd
$ cd ..
2018-02-16 10:46:32 -05:00
$ catkin_make -j1 --pkg rtabmap_ros
2014-11-27 13:51:23 -05:00
```