您的位置:首页 > 产品设计 > UI/UE

ROS学习手记 - 2 Build Package 生成包

2015-07-05 20:05 507 查看
=== 在上一篇的基础上,Create并Customize了Package之后,要Build Package ===

来源:http://wiki.ros.org/ROS/Tutorials/BuildingPackages

1. 确认source有没有完成 (版本: hydro):

$ source /opt/ros/hydro/setup.bash


2. Using catkin_make

使用方法:

# In a catkin workspace
   $ catkin_make [make_targets] [-DCMAKE_VARIABLES=...]

这里catkin_make使用了CMake 的workflow来操作,科普一下这个workflow:




3. 如何写ROS的Publisher and Subscriber(C++)

因为要涉及到对CMakeLists.txt的写法,需要先了解这个文章:http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

具体关于CMakeLists.txt文件,请看http://wiki.ros.org/catkin/CMakeLists.txt

4. 关于workspace下的build devel src文件夹

The build folder is the default location of thebuild space and is wherecmake and
make are called to configure and build your packages.

The devel folder is the default location of thedevel space, which is where your executables and libraries go
before you install your packages.

5. Build the package

catkin_make命令执行情况如下:

exbot@ubuntu:~/catkin_ws$ ls
build  devel  src
exbot@ubuntu:~/catkin_ws$ catkin_make
Base path: /home/exbot/catkin_ws
Source space: /home/exbot/catkin_ws/src
Build space: /home/exbot/catkin_ws/build
Devel space: /home/exbot/catkin_ws/devel
Install space: /home/exbot/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/exbot/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/exbot/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/hydro
-- This workspace overlays: /opt/ros/hydro
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Python version: 2.7
-- Using Debian Python package layout
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/exbot/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- catkin 0.5.86
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 7 packages in topological order:
-- ~~  - beginner_tutorials
-- ~~  - exbotxi_bringup
-- ~~  - exbotxi_description
-- ~~  - exbotxi_example
-- ~~  - exbotxi_nav
-- ~~  - exbotxi_rviz
-- ~~  - exbotxi_teleop
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- +++ processing catkin package: 'exbotxi_bringup'
-- ==> add_subdirectory(exbot_xi/exbotxi_bringup)
-- +++ processing catkin package: 'exbotxi_description'
-- ==> add_subdirectory(exbot_xi/exbotxi_description)
-- +++ processing catkin package: 'exbotxi_example'
-- ==> add_subdirectory(exbot_xi/exbotxi_example)
-- +++ processing catkin package: 'exbotxi_nav'
-- ==> add_subdirectory(exbot_xi/exbotxi_nav)
-- +++ processing catkin package: 'exbotxi_rviz'
-- ==> add_subdirectory(exbot_xi/exbotxi_rviz)
-- +++ processing catkin package: 'exbotxi_teleop'
-- ==> add_subdirectory(exbot_xi/exbotxi_teleop)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/exbot/catkin_ws/build
####
#### Running command: "make -j1 -l1" in "/home/exbot/catkin_ws/build"
####
[100%] Built target move
exbot@ubuntu:~/catkin_ws$



虽然跟教程上有点不同,但没遇到错误,就这样吧。。

====== 【总结】 ======

【建立一个catkin Package的步骤】

了解Package的基本概念

1. 相对ROS的角色和地位。

2. Package文件夹至少要包含的文件:package.xml & CMakeLists.txt &

3. 拒绝嵌套

4. Packages 在catkin workspace中的文件分布结构

建立一个catkin Package的步骤

1. 可用的创建命令:roscreate-pkg or catkin

2. 创建的命令

# cd $YOUR ROS WORKSPACE$/src

# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]

3. 编译catkin workspace 和 source the setup file

# cd $YOUR ROS WORKSPACE$

# catkin_make

add the workspace to ROS env., source the generated setup file

$ . ~/catkin_ws/devel/setup.bash

4. 定制化你的Package

这一部分就比较细了,参考ROS_Tutorials_CreatingPackage - ROS Wiki
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: