亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場(chǎng) | 考試論壇  
        當(dāng)前位置:Linux認(rèn)證 > 綜合輔導(dǎo) > 文章內(nèi)容
        

      Linux教程:機(jī)器人操作系統(tǒng)ROS學(xué)習(xí)教程

      來源:robotos.net [ 2016年2月14日 ] 【

      描述:這篇教程主要介紹編譯功能包的工具鏈;

      1、編譯功能包

      只要功能包的依賴項(xiàng)都已經(jīng)安裝完畢,我們就可以編譯新的功能包了;

      在開始之前,務(wù)必通過source指令設(shè)置運(yùn)行的環(huán)境,在Ubuntu系統(tǒng)中可以執(zhí)行如下指令;

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

      1.1 使用catkin_make

      catkin_make是一個(gè)命令行工具,這個(gè)工具集成了一些標(biāo)準(zhǔn)catkin的工作流程;可以認(rèn)為catkin_make在Cmake執(zhí)行中聯(lián)合調(diào)用了cmake和make;

      用法:

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


      對(duì)于不很熟悉Cmake標(biāo)準(zhǔn)工作流程的朋友,可以參考如下所示,下面的代碼只是演示CMake的標(biāo)準(zhǔn)流程,不可執(zhí)行;

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


      每一個(gè)CMake工程是單獨(dú)編譯的,而在一個(gè)workspace里的catkin工程是可以一起編譯,一起編譯時(shí)可以參考如下流程進(jìn)行:

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

      上面的命令會(huì)編譯在src文件夾里的任何一個(gè)catkin工程,如果你的代碼在別的位置,比如my_src,則應(yīng)當(dāng)如下調(diào)用catkin_make命令(因?yàn)槭纠膍y_src可能不存在,下面的指令不一定能編譯成功):

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

      2、 編譯你自己的功能包

      我們已經(jīng)創(chuàng)建了一個(gè)catkin workspace和一個(gè)名字為beginner_tutorials的catkin功能包,改變路徑到catkin workspace中查看一下src文件夾:

      $cd~/catkin_ws/
      $lssrc

      •        beginner_tutorials/  CMakeLists.txt@ 

      你應(yīng)當(dāng)看到一個(gè)名字為beginner_tutorials的文件夾,現(xiàn)在我們利用catkin_make編譯這個(gè)功能包:

      $ catkin_make

      你應(yīng)當(dāng)看到源自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首先顯示出每個(gè)‘space’使用的路徑,因?yàn)椴捎玫哪J(rèn)參數(shù),編譯后會(huì)產(chǎn)生幾個(gè)文件夾,可以通過ls查看:

      $ls

      •        build
      •        devel
      •        src

      build文件夾是編譯時(shí)的默認(rèn)位置,這里保存有cmake和make配置及編譯信息的相關(guān)文件,devel文件夾是編譯后保存編譯結(jié)果的,編譯后的可執(zhí)行文件及依賴庫保存在這個(gè)位置;

      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動(dòng)訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請(qǐng)鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved