The operation of rgbdslam_v2 on Ubuntu18.04+ROS_melodic and related problem solving

software and hardware

(1) Software: Ubuntu 18.04 system with ROS_melodic
(2) Hardware: desktop and kinectV1 camera

Download, install, run, and problems encountered

Main reference: https://blog.csdn.net/qq_29828623/article/details/60765043
and https://blog.csdn.net/zhuoyueljl/article/details/78536996?reload

Create a ROS workspace, download rgbdslam_v2, install

Note: If it is other version of ros, you can change melodic to the corresponding version

#Prepare Workspace
source /opt/ros/melodic/setup.bash 
mkdir -p ~/rgbdslam_catkin_ws/src
cd ~/rgbdslam_catkin_ws/src
catkin_init_workspace
cd ~/rgbdslam_catkin_ws/
catkin_make
source devel/setup.bash

#Get RGBDSLAM
cd ~/rgbdslam_catkin_ws/src
wget -q http://github.com/felixendres/rgbdslam_v2/archive/indigo.zip
unzip -q indigo.zip
cd ~/rgbdslam_catkin_ws/

#Install
rosdep update
rosdep install rgbdslam
catkin_make 

Problems encountered and solutions

Some problems and solutions encountered in catkin_make:


1. opencv版本问题,我一开始使用的是opencv4.1.0 
 (目前,这样修改可以编译通过,但是之后还会遇到一些问题,最后我是链接了opencv3.2.0才成功运行的)
 
openni_listener.cpp   ->     需要修改drawKeypoints()最后一个参数5为cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS
cv::drawKeypoints(visualization_img_, new_node->feature_locations_2d_, kp_img, cv::Scalar(0,255,0), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

graph_mgr_io.cpp ->	需要修改drawKeypoints()最后一个参数
cv::drawKeypoints(canvas, newernode->feature_locations_2d_, canvas, cv::Scalar(255), cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

2. g2o版本问题,graph_manager.cpp 和 transformation_estimation.cpp会出现问题
需要使用作者提供的g2o库(当然用自己下载的g2o库也可以,得修改相关代码)

3. misc.cpp ->  需要修改804行内联函数round()的函数名,我改成了ROUND(),880和881行函数调用也要一起修改

4. feature_adjuster.cpp  ->  ORB::create需要修改倒数第三个参数0为ORB::HARRIS_SCORE
detector = ORB::create(10000, 1.2, 8, 15, 0, 2, ORB::HARRIS_SCORE, 31, static_cast<int>(thresh_));

Explain in advance: It took me more than half a day to modify the above problem, and the problem of "required process[rgbdslam-1] has died"...Iinitiating down appeared after running . At first I thought it was the conflict between g2o and pcl mentioned in the blog of the second link. After spending most of the day uninstalling and installing g2o and pcl-1.8, this problem still occurred. This time, I took a closer look and found that the program was terminated due to cv::Exception. After deleting the build and delve folders catkin_make, I found that although the compilation was successful, the warning shown in the figure below will appear at the end, which probably means that the opencv version is not 3.2.0. (In the beginning, I changed 4.1.0 to 3.4.7 but it didn’t work. I could only download 3.2.0.)
opencv_conflictSo, I still used the g2o library provided by the author , pcl-1.8 , and opencv3.2.0 and opencv_contrib-3.2. .0 . Sure enough, only the third problem appeared in the above four problems, and finally it was able to run successfully (~the result of my own test, not for everyone)

For the installation of g2o and pcl-1.8, refer to the second blog linked above.

Problems and solutions encountered when installing opencv3.2.0:

Compilation of opencv: ItCMAKE_INSTALL_PREFIX is the directory to choose to install, when multiple versions need to be managed, install in the specified location. As shown in the figure below, choose to install in the ros workspace directory, and sudo make installthen bin, include, lib, share folders will appear. It is worth noting that the opencv cmake file is in the share/OpenCVfolder, which is the OpenCV_DIR that the CMakeLists file of rgbdslam_v2 needs to set.
Project_tree

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=~/rgbdslam_catkin_ws -D OPENCV_EXTRA_MODULES_PATH=~/rgbdslam_catkin_ws/install_lib/opencv_contrib-3.2.0/modules -DENABLE_PRECOMPILED_HEADERS=OFF ..

Another parameter OPENCV_EXTRA_MODULES_PATHis to set the path of the opencv add-on module, which is the modules folder in opencv_contrib-3.2.0. -DENABLE_PRECOMPILED_HEADERS=OFFPlus can solve the /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directoryproblem.
There is a problem ICV: Downloading ippicv_linux_20151201with downloading protobuf-cpp-3.1download timeout, download these two packages, and then put them in the specified location.
ippicv_linux_20151201 download address
protobuf-cpp-3.1 download address
Two compressed packages are placed under opencv-3.1.0/3rdparty/ippicv/downloads/linuxand respectively opencv_contrib-3.2.0/modules/dnn/.download/bd5e3eed635a8d32e2b99658633815ef/v3.1.0. (Note that if you are operating on the graphical interface, the .download file needs to be displayed in the hidden folder to see)

Management of g2o version:

Due to the use of the new version of g2o, I had to delete the old version and reinstall the new version. When running rgbd-slam-v2 again, the error shown in the figure below appears, and we can know that there is a problem with g2o.

Then the problem comes again, either change the source code or manage the old and new g2o versions. For the old version of g2o, you can choose the installation directory like OpenCV above. Choose to install it here ~/rgbdslam_catkin_ws, and the G2OConfig.cmake file of g2o is ~/rgbdslam_catkin_ws/lib/g2oin. Then set G2O_DIR, the g2o related code in the CMakeLists file is as follows.
Insert picture description here
There is a pit here: as shown in the figure below, the author has set up cmake-modulesto find the .cmake file in the folder under the project , so the FindG2O.cmake file is preferred in this folder (it has been pitted for a long time, so guess this priority is higher set() syntax), you need to delete this file to make the G2O_DIR set by yourself take effect.
Insert picture description here

Compile and run rgbdslam_v2 again

Next, you can finally compile rgbdslam_v2 again. Before restarting catkin_make, the CMakeLists file of rgbdslam_v2 needs to be set to OpenCV_DIR, plus the following setting code (mainly to find the path of the opencv cmake file, which can be set according to your own situation):

set(OpenCV_DIR ~/rgbdslam_catkin_ws/share/OpenCV)

set_opencv_dir
At the same time, change the setting of line 6 in CMakeLists to

set(USE_SIFT_GPU  0 CACHE BOOL "build with support for siftgpu") 

Ready to run

  1. Open a terminal and type
roscore
  1. Open the second terminal and enter
roslaunch openni_launch openni.launch device_id:=#2

You may encounter it primesense_Warning: USB events thread - failed to set priority. This might cause loss of data...when you execute the above script , you can run it before running openni_launch sudo -s. See here

  1. Open the third terminal input
source ~/rgbdslam_catkin_ws/devel/setup.bash
roslaunch rgbdslam rgbdslam.launch

Installation: openni + ros interface

sudo apt-get install ros-melodic-openni-camera ros-melodic-openni-launch

For more details, see here and here .

Problems encountered during operation and solutions

Error prompt :

[camera/camera_nodelet_manager-1] process has died [pid 5531, exit code -11, cmd /opt/ros/melodic/lib/nodelet/nodelet manager __name:=camera_nodelet_manager __log:=/home/xshen/.ros/log/5dfeecc6-ea97-11e9-8369-049226d630de/camera-camera_nodelet_manager-1.log].
log file: /home/xshen/.ros/log/5dfeecc6-ea97-11e9-8369-049226d630de/camera-camera_nodelet_manager-1*.log

解决
Now it is necessary to specify the device number to connect to. In my case:
roslaunch openni_launch openni.launch device_id:=#2
(就是在最后加上device_id)

Error prompt :

DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument

Solution :

sudo apt-get remove beignet
sudo apt purge beignet
sudo apt-get remove beignet-opencl-icd
sudo apt purge beignet-opencl-icd

Error prompt :

[ERROR] Failed to contact master at [localhost:11311]. Retrying...
[ERROR] [1446531999.044935824]: [registerPublisher] Failed to contact master at [localhost:11311]. Retrying...

Solution :
Please check whether roscore is open normally. Run roscore first every time you run a test.

Finally , finally , the results of the successful operation are as follows (I have been crying~~)

rgbdslam_v2_run

Test on the dataset

Download link: http://vision.in.tum.de/data/datasets/rgbd-dataset/download#freiburg1_xyz
Need to download data in ROS.bag format.

Ready to start running (unplug the kinect data cable)

  1. Open a terminal and type
roscore
  1. Open the second terminal and enter
source ~/rgbdslam_catkin_ws/devel/setup.bash
roslaunch rgbdslam rgbdslam.launch
  1. Open the third terminal (enter the directory where the .bag file is located) and input
rosbag play rgbd_dataset_freiburg1_xyz.bag (自己的数据集名字)

Press the space bar on the GUI interface of RGBDSLAM (if it is not displayed, press a few more times), the running result is as follows
Data_Set_result

Error prompt :

Warning: TF_OLD_DATA ignoring data from the past for frame kinect at time 1.30503e+09 according to authority unknown_publisher

Solution :

需要将 rgbdslam.launch 文件中
<param name="config/topic_image_depth"             value="/camera/depth_registered/sw_registered/image_rect_raw"/>
改为
<param name="config/topic_image_depth"             value="/camera/depth/image "/>

Guess you like

Origin blog.csdn.net/XindaBlack/article/details/102499364