【ROS】建立功能包(ROS package)
阿新 • • 發佈:2018-12-22
建立功能包(ROS package)
1 常用工具
- roscreate-pkg
- catkin
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 工作空間建立方法
$ 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 <package_name> [depend1] [depend2] [depend3]
5 編譯catkin workspace並source
$ cd ~/catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
6 包依賴
未完待續