【ROS】创建ROS功能包(ROS package)

创建功能包(ROS package)


参考(http://wiki.ros.org/ROS/Tutorials/CreatingPackage)

1 常用工具

  • roscreate-pkg
  • catkin

推荐使用catkin (参考: http://wiki.ros.org/catkin/conceptual_overview)

2 catkin package组成

  • 命名规则

    只允许使用小写字母,数字,下划线三种元素组成,并且首字母必须是小写字母

  • 主要组成
    • package.xml(package的meta信息)
    • CMakeLists.txt(catkin 编译使用文件)
  • 结构示例
    my_package/
      CMakeLists.txt
      package.xml
    

    注意: 每个package要有独立的文件夹(package不能嵌套和公用)

3 catkin Workspace(工作空间)

catkin package可以单独创建, 但是推荐使用工作空间

3.1 工作空间结构

workspace_folder/    	-- WORKSPACE
  src/                  -- SOURCE SPACE
    CMakeLists.txt      -- 'Toplevel' CMake file, provided by catkin
    package_1/
      CMakeLists.txt    -- CMakeLists.txt file for package_1
      package.xml       -- Package manifest for package_1
    ...
    package_n/
      CMakeLists.txt    -- CMakeLists.txt file for package_n
      package.xml  

3.2 工作空间创建方法

参考(http://wiki.ros.org/catkin/Tutorials/create_a_workspace)

$ source /opt/ros/lunar/setup.bash
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ source devel/setup.bash
$ echo $ROS_PACKAGE_PATH

4 创建catkin package

4.1 步骤

$ cd ~/catkin_ws/src
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
# catkin_create_pkg  [depend1] [depend2] [depend3]

5 编译catkin workspace并source

$ cd ~/catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash

6 包依赖

未完待续

你可能感兴趣的:(ROS,机器人)