linux ros查看功能包,编译ROS系统中的功能包

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

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文件夹是编译后保存编译结果的,编译后的可执行文件及依赖库保存在这个位置;0b1331709591d260c1c78e86d0c51c18.png

你可能感兴趣的:(linux,ros查看功能包)