Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Creating a workspace for catkin
Description: This tutorial covers how to setup a catkin workspace in which one or more catkin packages can be built.Keywords: catkin workspace
Tutorial Level: BEGINNER
Next Tutorial: Creating catkin packages
Contents
Prerequisites
This tutorial assumes that you have installed catkin and sourced your environment. If you installed catkin via apt-get for ROS Hydro, your command would look like this:
$ source /opt/ros/hydro/setup.bash
下面我们开始创建和构建一个catkin工作空间:
$ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws/ $ catkin_make
catkin_make命令在catkin工作空间中是一个非常方便的工具。在你的工作空间中第一次运行它时,它会在src目录下创建一个CMakeLists.txt的链接。
对于ROS Melodic和早期版本的Python 3用户:注意,如果你从源代码构建ROS来实现Python 3的兼容性,并适当地设置您的系统(即:安装所有必需的ROS Python包的Python 3版本,例如catkin),那么在干净的catkin工作区中的第一个catkin_make命令必须是:
$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
这将会配置catkin_make使用Python 3,在以后的构建中可以只使用catkin_make。
另外,如果你查看一下当前目录应该能看到build和devel这两个目录。在devel文件夹里面你可以看到几个setup.*sh文件。source这些文件中的任何一个都可以将当前工作空间设置在环境的最顶层。想要了解更多,请参考catkin文档。接下来首先source一下新生成的setup.*sh文件:
$ source devel/setup.bash
要保证工作区被安装脚本正确覆盖,需确定ROS_PACKAGE_PATH环境变量包含你当前的工作空间目录:
$ echo $ROS_PACKAGE_PATH /home/<username>/catkin_ws/src:/opt/ros/<distro>/share
Next you should go ahead and learn how to use the workspace.
If you are following the ROS tutorials series instead of the catkin tutorials, please continue with Creating a ROS Package.