在pcDuino上学习ROS系统初级开发(四)编译ROS软件包

雨后的彩虹桥 发布于 2014/03/09 14:49
阅读 717
收藏 0

【Gopher China万字分享】华为云的Go语言云原生实战经验!>>>

groovygalapagos-320w

这一节的教程教你使用编译工具编译package,在编译之前先初始化一下环境

1,使用catkin_make

catkin_make是一个命令行工具可以很方便的添加一些其他的make。

用法:

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

如果你不熟悉标准的 CMake 下面可以分解一下:

# In a CMake project
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install  # (optionally)

这个过程会cmake每个project,如此相反,catkin projects 会一起编译,从0开始在工作空间里面开始编译。

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

上面的命令会编译每个在src里面的工程,如果你src在其他地方,你可以使用 catkin_make的参数。

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

2,编译你的工程

你现在已经有了 catkin workspace新的软件包名字叫beginner_tutorials 。进入这个文件夹

$ cd ~/catkin_ws/
$ ls src
  • beginner_tutorials/  CMakeLists.txt@

你会看到一个文件夹叫做beginner_tutorials ,这是 beginner_tutorials建立的,我们现在可以用catkin_make来编译。

$ catkin_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"
    ####

编译完了之后查看一下:

$ ls
  • build
    devel
    src

build文件夹是默认的存放编译文件的地方,现在你已经编译了ROS package ,下一章会讲解关于 ROS Nodes的知识。




linksprite学习中心

加载中
返回顶部
顶部