手机版
你好,游客 登录 注册
背景:
阅读新闻

机器人操作系统ROS学习教程

编译ROS系统中的功能包

[日期:2016-01-17] 来源:robotos.net  作者:时飞 [字体:大 中 小]

描述:这篇教程主要介绍编译功能包的工具链;

1、编译功能包

只要功能包的依赖项都已经安装完毕,我们就可以编译新的功能包了;

在开始之前,务必通过source指令设置运行的环境,在Ubuntu系统中可以执行如下指令;

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

1.1 使用catkin_make

catkin_make是一个命令行工具,这个工具集成了一些标准catkin的工作流程;可以认为catkin_make在Cmake执行中联合调用了cmake和make;

用法:

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


对于不很熟悉Cmake标准工作流程的朋友,可以参考如下所示,下面的代码只是演示CMake的标准流程,不可执行;

# In a CMake project
$mkdirbuild
$cdbuild
$ cmake ..
$make
$makeinstall  # (optionally)


每一个CMake工程是单独编译的,而在一个workspace里的catkin工程是可以一起编译,一起编译时可以参考如下流程进行:

# In a catkin workspace
$ catkin_make
$ catkin_make install # (optionally)

上面的命令会编译在src文件夹里的任何一个catkin工程,如果你的代码在别的位置,比如my_src,则应当如下调用catkin_make命令(因为示例的my_src可能不存在,下面的指令不一定能编译成功):

# In a catkin workspace
$ catkin_make --sourcemy_src
$ catkin_make install--sourcemy_src  # (optionally)

2、 编译你自己的功能包

我们已经创建了一个catkin workspace和一个名字为beginner_tutorials的catkin功能包,改变路径到catkin workspace中查看一下src文件夹:

$cd~/catkin_ws/
$lssrc

•        beginner_tutorials/  CMakeLists.txt@ 

你应当看到一个名字为beginner_tutorials的文件夹,现在我们利用catkin_make编译这个功能包:

$ catkin_make

你应当看到源自cmake及make的输出信息,大致如下所示:
•        Base path: /home/user/catkin_ws
•        Source space: /home/user/catkin_ws/src
•        Build space: /home/user/catkin_ws/build
•        Devel space: /home/user/catkin_ws/devel
•        Install space: /home/user/catkin_ws/install
•        ####
•        #### Running command: "cmake /home/user/catkin_ws/src
•        -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel
•        -DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install" in "/home/user/catkin_ws/build"
•        ####
•        -- The C compiler identification is GNU 4.2.1
•        -- The CXX compiler identification is Clang 4.0.0
•        -- Checking whether C compiler has -isysroot
•        -- Checking whether C compiler has -isysroot - yes
•        -- Checking whether C compiler supports OSX deployment target flag
•        -- Checking whether C compiler supports OSX deployment target flag - yes
•        -- Check for working C compiler: /usr/bin/gcc
•        -- Check for working C compiler: /usr/bin/gcc -- works
•        -- Detecting C compiler ABI info
•        -- Detecting C compiler ABI info - done
•        -- Check for working CXX compiler: /usr/bin/c++
•        -- Check for working CXX compiler: /usr/bin/c++ -- works
•        -- Detecting CXX compiler ABI info
•        -- Detecting CXX compiler ABI info - done
•        -- Using CATKIN_DEVEL_PREFIX: /tmp/catkin_ws/devel
•        -- Using CMAKE_PREFIX_PATH: /opt/ros/groovy
•        -- This workspace overlays: /opt/ros/groovy
•        -- Found PythonInterp: /usr/bin/python (found version "2.7.1")
•        -- Found PY_em: /usr/lib/python2.7/dist-packages/em.pyc
•        -- Found gtest: gtests will be built
•        -- catkin 0.5.51
•        -- BUILD_SHARED_LIBS is on
•        -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
•        -- ~~  traversing packages in topological order:
•        -- ~~  - beginner_tutorials
•        -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
•        -- +++ add_subdirectory(beginner_tutorials)
•        -- Configuring done
•        -- Generating done
•        -- Build files have been written to: /home/user/catkin_ws/build
•        ####
•        #### Running command: "make -j4" in "/home/user/catkin_ws/build"
•        ####

注意catkin_make首先显示出每个‘space’使用的路径,因为采用的默认参数,编译后会产生几个文件夹,可以通过ls查看:

$ls

•        build
•        devel
•        src

build文件夹是编译时的默认位置,这里保存有cmake和make配置及编译信息的相关文件,devel文件夹是编译后保存编译结果的,编译后的可执行文件及依赖库保存在这个位置;

linux
【内容导航】
第1页:ROS系统介绍及安装 第2页:ROS系统中文件系统及命令工具介绍
第3页:创建ROS系统中的catkin功能包 第4页:编译ROS系统中的功能包
第5页:熟悉ROS系统中的节点 第6页:熟悉ROS系统中的话题
第7页:熟悉ROS系统中的服务和参数 第8页:rqt_console和roslaunch的用法
第9页:使用rosed编辑文件 第10页:生成ROS msg文件及srv文件
相关资讯       ROS  机器人操作系统 
本文评论   查看全部评论 (2)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 2 楼
* 匿名 发表于 2017/12/12 20:12:40
咋下rosGroovyGalapagos.ova 找不到啊!!
第 1 楼
* 匿名 发表于 2017/11/27 20:33:13
下载不出来rosGroovyGalapagos.ova