After learning the ORB_SLAM2 source code, I want to use a small project to consolidate the knowledge I have learned. After thinking for a long time, I decided to add a dense mapping thread on the basis of the ORB_SLAM2 source code, and use the kinect2 camera to realize the 3D reconstruction of my bedroom.
Not much to say, first on the renderings.
Dense map reconstruction with loop closure
Dense map reconstruction without loop closure
In the process of completing this small project, whenever compiling and running links are encountered, there is a high probability that red warnings and errors will appear on the screen. At the beginning, I was able to stabilize my mentality and google when encountering problems, but later found that many issues on blogs or github did not explain the principle of modifying the code clearly, and some answers themselves were wrong, which was not very friendly to novice Xiaobai. If you don't understand and believe in blogs blindly, it may also cause irreversible consequences, such as me. . . Changing the permissions by mistake caused the ubuntu system to crash, and I am heartbroken! Can't wait to drop the mouse and keyboard on the spot!
For this reason, I recorded the pits I stepped on during the actual combat of ORB_SLAM2+kinect2 dense map construction, and pointed out those places where mistakes are easy to make, and reminded myself that I must really understand the problem! Say important things three times to really understand the problem! Really figure things out! Really figure things out!
So first, let's let the code run~
Dr. Gao Xiang open sourced the dense map without closed loop, the address is as follows:
https://github.com/gaoxiang12/ORBSLAM2_with_pointcloud_map
On this basis, the big guys open source another dense map with closed loop, the address is as follows: https://github.com/tiantiandabaojian/ORB-SLAM2_RGBD_DENSE_MAP
Based on the dense map with closed loop, we will build the environment and modify some of the bugs in it, so that everyone can quickly run out of the rendering.
For the specific installation process, please refer to the following blog. Here I mainly record the possible problems, analyze the reasons and give solutions (experiments on this machine have proved feasible)
ORB SLAM 2 + build point cloud map reproduction - short book
Problem record:
1. Install the Kinect open source driver iai_kinect2 and libfreenect2 (why are two drivers installed here?)
iai_kinect2 is the driver of ros, and libfreenect2 is the driver of kinect2. iai_kinect2 can be built on libfreenect or OpenNI. If there is a compilation error here, it is generally easier to solve it by copying and pasting the error into the search box.
2. The yaml file generated when using kinect2_calibration in iai_kinect2 for calibration is incomplete
After experiments, it was found that the number of photos for color/depth/synchronization must be at least 50 to generate a yaml file normally.
3. There are many warnings related to eigen3 when compiling ORB-SLAM2_RGBD_DENSE_MAP-master, and a segment error occurs after ignoring the warnings and running.
The corresponding ros version under ubuntu18 is melodic, which is above 3.3 by default, and the highest version for running ORB-SLAM2_RGBD_DENSE_MAP-master is 3.2.
Check the version of eigen3
pkg-config --modversion eigen3
To delete and install eigen, you can refer to the following link: ubuntu16.04 uninstall, install eigen_TB81266's blog-CSDN blog_ubuntu uninstall eigen3
4. ORBvoc.txt.tar.gz is missing when compiling ORB-SLAM2_RGBD_DENSE_MAP-master, and there are warnings related to pcl1.7
There is no ORBvoc.txt.tar.gz in the Vocabulary in the original ORB-SLAM2_RGBD_DENSE_MAP-master, it needs to be copied from other places, and the warnings related to pcl1.7 can be ignored. It should be noted that when the first compilation fails, it is best to delete all generated build files, so as not to affect the second compilation.
5. Successfully compiled ORB-SLAM2_RGBD_DENSE_MAP-master, but the point cloud map is not displayed at the last run
After consulting a lot of information, it is said that it is a problem with the pcl library, but in fact it is not. Change the pointcloudmapping.h file bool loopbusy;
tobool loopbusy=false即可。
参考博客:
ORBSLAM2_Dense Map + Loop Closure__YAO Ayao's Blog-CSDN Blog_orbslam dense map
6. The image can be displayed after running ORB-SLAM2+kinect, but the map image is very narrow, which looks a little strange
The kinect2 resolution setting is unreasonable. There are three kinds of topics in Kinect2, corresponding to different resolutions. Among them, hd is 1920, qhd is a quarter of 960, and sd is the smallest. It is more appropriate to choose qhd, the corresponding Camera.width: 960; Camera.height: 540
Visual SLAM Combat (2): ORB-SLAM2 with Kinect2
7. The map is distorted when running ORB-SLAM2+kinect,
The internal parameters and distortion parameters are set incorrectly and need to be set according to the calibration results. It is worth noting that the internal parameters set in the yaml file are half of the camera calibration results.
Replenish:
build.sh and build_ros.sh are script files. Running the script file can make the compilation process run automatically, but please note that you need to chmod +x build_ros.sh before running to increase the permissions, otherwise the script file may not be found.
Since I set up two ros workspaces personally, I thought that different workspaces would not affect each other, but in fact, if the same node name appears, there will be many unexpected consequences. For example, I wanted to run a node with a dense map, but ros has been executing a node without a dense map, and it wasted a lot of time to find the reason. . .