Closed derektan95 closed 3 years ago
You have opencv 4.1 and 3.2 installed. But you should not mix them up.
Change this line: https://github.com/introlab/rtabmap/blob/master/CMakeLists.txt#L212
to
FIND_PACKAGE(OpenCV 3.2 REQUIRED QUIET)
to specify the version.
Make the same change for rtabmap_ros and try again.
Hi @thohemp ,
Thanks for your tip. What I'm confused by is this:
There wasn't any openCV installed prior (I performed a sudo apt remove libopencv*). I performed the installation of rtab-map from binaries, and then removed it as per instructions. However, it seems like this step installs 2 versions of opencv, as you can see from the log posted in the first post.
I think your fix might solve the issue. But I'm curious if the instructions will cause issues for others who does not use this fix?
I can't tell how version 4.1 got on your system. But any ros related stuff normally uses version 3.2 and I am pretty rtabmap does the same. Perhaps, version 4.1 was introduced by another package not related to this.
Are you on a jetson? In latest jetpack they changed default libopencv-dev to use version 4 instead of 3.2, while ros packages are still linked to 3.2. Here more info.
Hi @thohemp and @matlabbe,
Thank you both for your comments. That is a good catch. I'm actually using a Jetson TX2, which is why I'm facing the issue of OpenCV being version 4 by default. I've fixed this by carefully fixing this by building OpenCV from source, along with a few other dependencies. I will post my solutions as a possible guide once I'm on a computer. Thank you very much!
sudo apt-get install ros-melodic-rtabmap ros-melodic-rtabmap-ros
sudo apt remove ros-melodic-rtabmap ros-melodic-rtabmap-ros # Uninstall again
cd ~/Libraries
git clone https://github.com/opencv/opencv # Master branch
cd opencv
mkdir build && cd build
cmake -D CATKIN_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install # Install to usr/local directory
These packages be cloned from https://github.com/ros-perception/vision_opencv
. However, they have to be modified to fit to our use, if not there will be compile errors. For ROS Melodic, use the noetic branch and change python dependencies in CMakeLists.txt, or use the melodic branch and change some function headers (https://cyaninfinite.com/ros-cv-bridge-with-python-3/).
cd ~/Libraries
git clone https://github.com/ros-perception/vision_opencv
cd vision_opencv/cv_bridge
mkdir build && cd build
cmake -D CATKIN_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install # Install to usr/local directory
cd ~/Libraries
cd vision_opencv/image_geometry
mkdir build && cd build
cmake -D CATKIN_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install # Install to usr/local directory
# Installing RTAB Library
cd ~/Libraries
git clone https://github.com/introlab/rtabmap # Master branch
cd rtabmap
mkdir build && cd build
cmake -D OpenCV_DIR=/usr/local/lib/cmake/opencv4 -D CATKIN_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install
# Installing RTAB ROS package
cd ~/unitree_a1_repo/catkin_ws/src
git clone https://github.com/introlab/rtabmap_ros
Add these 2 lines of code to specify where to link to the cv_bridge
and image_geometry
libraries, at the top of RTAB ROS's CMakeLists.txt. After this, you can compile the RTAB-Map package. It depends on where your cmake instruction files are located once these packages are installed.
set(cv_bridge_DIR /usr/local/share/cv_bridge/cmake)
set(image_geometry_DIR /usr/local/share/image_geometry/cmake)
#set(image_geometry_DIR /usr/local/lib/cmake/opencv4) # Not sure if needed
Hi @matlabbe,
Speaking of compilation from source, I've added the GTSAM and libpointmatcher functionality. While GTSAM is an option that we have to specify to use, how about libpointmatcher? Is it used by default if we build rtab-map with it? Thanks!
Yes, libpointmatcher is used by default if rtabmap is built with it.
$ rtabmap --params | grep Icp/PM
Param: Icp/PM = "true" [Use libpointmatcher for ICP registration instead of PCL's implementation.]
Hi @matlabbe,
Thank you so much for all these clarification. Appreciate it!
-Derek
Hi @matlabbe ,
I have a question about building this package from source, in order to use GTSAM optimizer and libpointmatcher.
I made sure to follow all your instructions in the README.md. By firstly installing and uninstalling the binaries, these libopencv libraries are installed. These libraries are installed.
I did not install opencv by source, as i did not need the SIFT or SURF features. I proceeded with installed rtabmap package in my root folder, with the INSTALL-PREFIX set to a default path. However, I faced these errors when i performed catkin_make in my main workspace with the rtabmap_ros folder in it.
Yet at the same time, these errors occured.
It seems like the installed libopencv files requires both version 3/4 shared object files, which are part of the initial installation Install and uninstall of rtabmap binaries. I wonder if this will cause issues along the way? Thanks!