ORB_SLAM3: Solution to compilation errors in ROS (noetic) environment

My computer system is Ubuntu 20.04, and the version of ROS installed is noetic. When I use the ./build_ros.sh command to compile ORB_SLAM3, the following error occurs:

Failed to invoke rospack to get compile flags for package 'ORB_SLAM3'. Look above for errors from rospack itself. Aborting. Please fix the broken dependency!

If you look carefully above, there is actually another error like this:

ERROR: Rosdep experienced an error: The read operation timed out Please go to.........

At this time, the following statement has been added to .bashrc and source ~/.bashrc has been sourced, but the above error still occurs.

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:YOUR_PATH/ORB_SLAM3/Examples/ROS

After carefully looking at the problem, there are tips: sudo rosdep init and rosdep update to solve it, but after I sudo rosdep init, I still get the following error:

ERROR: cannot download default sources list from:
https : //raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list 
Website may be down.

At that time, I followed many methods on the Internet, but all failed in the end . This problem stuck with me for two days. I accidentally saw the book when I was learning ROS1, which was a tutorial by Teacher Zhao Xuzuo, and finally solved the above problem.

The solution is as follows:

1. Enter the "/usr/lib/python3/dist-packages/" directory and modify the relevant files, mainly including: ./rosdistro/__init__.py, ./rosdep2/gbpdistro_support.py, ./rosdep2/sources_list.py,. /rosdep2/rep3.py.

sudo gedit ./rosdistro/__init__.py
sudo gedit ./rosdep2/gbpdistro_support.py
sudo gedit ./rosdep2/sources_list.py
sudo gedit ./rosdep2/rep3.py

2. The URL content involved in the file, if it is: raw.githubusercontent.com/ros/rosdistro/master , replace it with the gitee.com/zhao-xuzuo/rosdistro/raw/master prepared in step 1. In step 1 The modified contents of the four files are as follows:

DEFAULT_INDEX_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/index-v4.yaml'
FUERTE_GBPDISTRO_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/releases/fuerte.yaml'
DEFAULT_SOURCES_LIST_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/sources.list.d/20-default.list'
REP3_TARGETS_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/releases/targets.yaml'

3. After the modification is completed, re-execute the command:

sudo rosdep init
rosdep update

Finally, delete the build folder under YOUR_PATH /ORB_SLAM3/Examples/ROS/ORB_SLAM3, re-execute the ./build_ros.sh command, and the compilation is successful.

最后说一下ORB_SLAM3为什么要在ROS环境运行,我认为是方便将其部署到机器人上,这样大大简化了后期实体机器人的开发周期,同时有些数据集也是rosbag的格式,在ROS环境下运行比较方便。但是目前的一些头部自动驾驶公司等,都会开发自己的框架,针对自己公司的产品做相应的优化,ROS环境还是相对冗余。学ROS1我非常推荐赵虚左老师的视频,讲的太棒了。

赵虚左老师ROS1视频:https://www.bilibili.com/video/BV1Ci4y1L7ZZ/?spm_id_from=333.999.0.0&vd_source=5d07f02a3545791b3e132f6da34124be

参考:http://www.autolabor.com.cn/book/ROSTutorials/chapter1/12-roskai-fa-gong-ju-an-zhuang/124-an-zhuang-ros.html

Guess you like

Origin blog.csdn.net/qq_44530706/article/details/129468790