Learning ROS: Creating a ROS package by catkin_create_pkg & hand

 本文主要部分来源于ROS官网的Tutorials.

Creating a ROS Package by catkin_create_pkg

cd ~/catkin_ws/src
# catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp #  create a new package called 'beginner_tutorials' which depends on std_msgs, roscpp, and rospy # build the packages in the catkin workspace cd ~/catkin_ws catkin_make # To add the workspace to your ROS environment you need to source the generated setup file . ~/catkin_ws/devel/setup.bash rospack depends1 beginner_tutorials # First-order dependencies roscd beginner_tutorials cat package.xml # These dependencies for a package are stored in the package.xml file rospack depends beginner_tutorials # Indirect dependencies, rospack can recursively determine all nested dependencies

Building a ROS Package

cd ~/catkin_ws/
ls src
catkin_make # build all catkin projects found in the src folder.
catkin_make install # (optionally) ls

Creating a ROS Package by Hand

cd ~/catkin_ws
mkdir -p src/foobar
cd src/foobar
gedit package.xml # The very first thing we'll do is add our manifest file

pakage.xml中输入以下内容:

<package>
  <name>foobar</name>
  <version>1.2.4</version>
  <description>
  This package provides foo capability.
  </description>
  <maintainer email="foobar@foo.bar.willowgarage.com">PR-foobar</maintainer>
  <license>BSD</license>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>

  <run_depend>roscpp</run_depend>
  <run_depend>std_msgs</run_depend>
</package>

Now that your package has a manifest, Test it:

rospack find foobar

创建CMakeLists.txt:

cd ~/catkin_ws
cd src/foobar
gedit CMakeLists.txt

在CmakeLists.txt中输入:

cmake_minimum_required(VERSION 2.8.3)
project(foobar)
find_package(catkin REQUIRED roscpp std_msgs)
catkin_package()

 

转载于:https://www.cnblogs.com/xbit/p/8530557.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值