Ubantu20.04 安装rtabmap的ros版本时 catkin_make报错:could not find a package configuration

ROS版本:noetic

查询安装包的源网站:ROS Wiki http://wiki.ros.org/

 本次安装经常用到git clone 如果git clone 报错,或者速度很慢,可以想参考下其他回答,解决网速问题

1.本次报错代码如下:

CMake Error at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "cv_bridge" with
  any of the following names:

    cv_bridgeConfig.cmake
    cv_bridge-config.cmake

  Add the installation prefix of "cv_bridge" to CMAKE_PREFIX_PATH or set
  "cv_bridge_DIR" to a directory containing one of the above files.  If
  "cv_bridge" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  rtabmap_ros/CMakeLists.txt:18 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/chen/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/chen/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

2.分析过程:

报错的原因是:找不到某个包

    cv_bridgeConfig.cmake
    cv_bridge-config.cmake

cv_bridge是把openCV和ROS连接起来的桥。

解决方法是.设置在报错的.camke中添加环境变量的路径:

如这里缺失cv_bridge

就添加:

set(cv_bridge_DIR “缺失的文件的目录”)

在添加前要先判断电脑里是否有缺失的文件cmakeConfig.cmake,如果有,就找到cmakeConfig.cmake所在的文件目录,用set()添加到catkinConfig.cmake文件中;如果没有,就下载cv_bridge安装包。

用sudo find / -name "*cmakeConfig.cmake*" 找文件位置,如果没有返回值,说明没有这个文件

如果没有找到,就安装cv_bridge

1.安装 cv_bridge:git clone https://github.com/ros-perception/vision_opencv.git

2.如果安装cv_bridge时报错缺少sensor_msgs,再安装cv_bridge的依赖sensor_msgs:sudo apt-get install ros-noetic-tf2-sensor-msgs

3.成功安装cv_bridge后,把set(cv_bridge_DIR /usr/local/share/cv_bridge/cmake)

添加到opt/ros/noetic/share/catkin/cmake/cmakeConfig.cmake 中

 3.然后重新catkin_make又报错,缺少std_srvs,就安装std_srvs(被包含在ros_common_msgs中)

sudo git clone git https://github.com/ros/ros_comm_msgs.git 
cd ros_comm_msgs
cd std_srvs
mkdir build
cd build 
cmake ..
make 
sudo make install

4.然后使用

sudo find / -name "*std_srvsConfig.cmake*"

找到缺少的文件std_srvsConfig.cmake,在我的电脑上是/home/chen/ros_comm_msgs/std_srvs/build/devel/share/std_srvs/cmake

接着与之前一样,把找到的路径加到catkinConfig.cmake中

set(std_srvs_DIR /home/chen/ros_comm_msgs/std_srvs/build/devel/share/std_srvs/cmake)  

5.继续安装,又缺少 

nav_msgsConfig.cmake
nav_msgs-config.cmake

sudo git clone https://github.com.cnpmjs.org/ros/common_msgs.git
cd commom_msgs //下载下来的文件刚开始上锁了 ,要先解锁
cd nav_msgs 
mkdir build 
cd build
cmake ..
make 
sudo make install

用find / -name "*nav_msgsConfig.cmake*"找到路径:/home/chen/common_msgs/nav_msgs/build/devel/share/nav_msgs/cmake

set(nav_msgs_DIR /home/chen/common_msgs/nav_msgs/build/devel/share/nav_msgs/cmake)

 6.又继续安装,又双缺少:

visualization_msgsConfig.cmake
visualization_msgs-config.cmake

但是这次不用再下载,因为在第五步我们已经下载了common_msgs

cd /common_msgs/visualization_msgs
mkdir build
cd build
cmake ..
make 
sudo make install

然后一样的在catkinConfig.cmake中添加路径

set(visualization_msgs_DIR /home/chen/common_msgs/visualization_msgs/build/devel/share/visualization_msgs/cmake)

 7.果然,这一次又报错了:少

image_transportConfig.cmake
image_transport-config.cmake

这次要重新下载,在如下这个代码框里

安装好之后添加:

set(image_transport_DIR /home/chen/image_common/image_transport/build/devel/share/image_transport/cmake)

sudo git clone https://github.com.cnpmjs.org/ros-perception/image_common.git 
//先解锁文件
sudo chmod 777 '/home/chen/image_common'
cd '/home/chen/image_common/image_transport'
mkdir build
cd build
cmake ..
make 
sudo make install

 在这一步cmake .. 时,可能会缺少 pluginlib-config.cmake

那就多了一步安装,在如下这个代码框里

安装好之后添加:set(pluginlib_DIR /home/chen/pluginlib/pluginlib/build/devel/share/pluginlib/cmake) 

                      添加好之后返回上一步image_transport的cmake ..

//下载
sudo git clone https://github.com.cnpmjs.org/ros/pluginlib.git 
//解锁
sudo chmod 777 -R '/home/chen/pluginlib'
cd '/home/chen/pluginlib/pluginlib'
mkdir build
cd build
cmake .. //如果cmake .. 出错了就看别看这个代码,先往下看,安装另一个包
make 
sudo make install

上一个cmake ..时 如果报错:

cmake_modulesConfig.cmake
    cmake_modules-config.cmake

就安装下面的cmake_modules,方法和之前一样,就不详细说了

安装好之后在catkinConfig添加set(cmake_modules_DIR /home/chen/cmake_modules/build/devel/share/cmake_modules/cmake)

添加好之后返回上一步pluginlib的cmake ..

sudo git clone https://github.com.cnpmjs.org/ros/cmake_modules.git 
sudo chmod 777 -R '/home/chen/cmake_modules'
cd cd '/home/chen/cmake_modules'
mkdir build
cd build
cmake ..
make 
sudo make install

 8.又又又又报错,缺少

tfConfig.cmake
tf-config.cmake

下载地址:

git https://github.com/ros/geometry.git

你可能感兴趣的:(ubuntu)