(笔记)ROS创建工作空间遇到问题解决 Depends: python-catkin-pkg but it is not going to be installed

 

(一)在创建创建工作空间

1、mkdir -p ~/catkin_ws/src //创建文件夹

2、cd ~/catkin_ws/src //定位到src

3、catkin_init_workspace //对工作空间进行初始化

在第三步对工作空间进行初始化时出现了以下的错误提示:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0OTExNjM2_size_16_color_FFFFFF_t_70

fairy@ubuntu:~$ sudo su [sudo]
password for fairy:
root@ubuntu:/home/fairy# cd ~
root@ubuntu:~# ls catkin-ws
root@ubuntu:~# cd catkin-ws/
root@ubuntu:~/catkin-ws# ls
src
root@ubuntu:~/catkin-ws# cd src/
root@ubuntu:~/catkin-ws/src# ls
root@ubuntu:~/catkin-ws/src# catkin_init_workspace
The program ‘catkin_init_workspace’ is currently not installed. You can install it by typing: apt install catkin
root@ubuntu:~/catkin-ws/src# sudo apt-get install catkin
Reading package lists… Done Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies: catkin :
Depends: python-catkin-pkg but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
root@ubuntu:~/catkin-ws/src#

在使用命令初始化catkin工程空间时出现以上等错误!从以上的错误中可以得出系统为安装catkin工具。需要先安装catkin工具,按照网络上别人的安装方法尝试采用sudo apt-get install catkin 根本没办法安装成功,所以本文提供一种解决方法可以安装catkin如下所示:

1、下载源码

sudo apt-get install git //先安装git命令

git clone https://github.com/ros/catkin //从github网站上下载catkin 安装包

2、安装依赖项,Catkin具有以下依赖性

CMake 一个跨平台的开源构建系统。
Python 一种通用的解释性高级编程语言,版本2.7。
catkin_pkg 一个用于catkin的Python运行库。
empy 一个Python模板库。
nose 一个Python测试框架。
GTest 一种Google的c++单元测试框架。
GNU C++编译器(g++)- GNU C++编译器

3、安装依赖项

sudo apt-get install cmake

sudo apt-get install python-catkin-pkg

sudo apt-get install python-empy

sudo apt-get install python-nose

sudo apt-get install python-setuptools

sudo apt-get install libgtest-dev

sudo apt-get install build-essential

或者使用一次性命令:

sudo apt-get install cmake python-catkin-pkg python-empy python-nose python-setuptools libgtest-dev build-essential

注:因为版本的原因,上述的python当前一般是python3,所以需注意安装名称的更改。

 

4、安装catkin

cd catkin/

mkdir build

cmake -DCMAKE_BUILD_TYPE=Release ../

make

sudo make install

或者使用一次性命令,先用cd命令切换到catkin目录下面(catkin目录为下载的安装包)接着在执行下面的命令

mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ../ && make && sudo make install

至此安装完成,即可重新构建工作空间

wiki.ros网站:http://wiki.ros.org/catkin#Installing_catkin

 

(二)在使用catkin_make命令编译工作空间时出现以下的错误提示:

20190821203451683.png

CMake Error at CMakeLists.txt:63 (message):
find_package(catkin) failed. catkin was neither found in the workspace nor
in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was
sourced before.

-- Configuring incomplete, errors occurred!
See also “/root/catkin_ws/build/CMakeFiles/CMakeOutput.log”.
Invoking “cmake” failed

从该错误中“ROS setup.sh was sourced before.”可以看出是没有设置好当前终端的环境变量

1、echo “source /opt/ros/kinetic/setup.bash” >> ~/.bashrc

2、source ~/.bashrc

3、source /opt/ros/ROS-RELEASE/setup.bash 其中ROS-RELEASE为希望的使用版本

如(lunar、kinetic、indigo、hydro、groovy等)如果是采用kinetic则命令为:

source /opt/ros/kinetic/setup.bash,重启系统在输入catkin_make命令就能正常编译

 

posted on 2022-09-15 15:27  tdyizhen1314  阅读(1470)  评论(0编辑  收藏  举报

导航