ROS创建工作空间遇到问题解决

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

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

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

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

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

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

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命令编译工作空间时出现以下的错误提示:

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命令就能正常编译

  • 6
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值