from:http://blog.sina.com.cn/s/blog_661159d50100ocj9.html
参考网址:
$ roscreate-pkg [package_name]
这里我直接引用官网提供的这个例子:---创建beginner_tutorialspackage,他依赖std_msgs, roscpp, rospy
(1) 利用 rorcreate-pkg 创建 package
$ roscreate-pkg beginner_tutorials std_msgs roscpp rospy
eg:
eg:
roscreate-pkg roscv sensor_msgs opencv2 cv_bridge roscpp std_msgs image_transport turtlesim ardrone_brown std_srvs
得到结果:
Created package directory/opt/ros/cturtle/ros/beginner_tutorials
Created include directory/opt/ros/cturtle/ros/beginner_tutorials/include/beginner_tutorials
Created cpp source directory/opt/ros/cturtle/ros/beginner_tutorials/src
Created package file/opt/ros/cturtle/ros/beginner_tutorials/Makefile
Created package file/opt/ros/cturtle/ros/beginner_tutorials/manifest.xml
Created package file/opt/ros/cturtle/ros/beginner_tutorials/CMakeLists.txt
Created package file/opt/ros/cturtle/ros/beginner_tutorials/mainpage.dox
Please editbeginner_tutorials/manifest.xml and mainpage.dox to finish creatingyour package
这里我们需要仔细阅读manifest.xml,所以这里我把生成的manifest.xml贴于下面:
<package>
<descriptionbrief="beginner_tutorials"> beginner_tutorials </description>
<author>root</author>
<license>BSD</license>
<reviewstatus="unreviewed" notes=""/>
<url>http://ros.org/wiki/beginner_tutorials</url>
<dependpackage="std_msgs"/>
<dependpackage="rospy"/>
<dependpackage="roscpp"/>
</package>
(2) 将该路径添加到rox系统中(即更新ros查找路径)
$ exportROS_PACKAGE_PATH=YOUR_BEGINNER_TUTORIALS_PATH:$ROS_PACKAGE_PATH
对于我机子而已,是这样添加:
$ exportROS_PACKAGE_PATH=./:$ROS_PACKAGE_PATH
然后我确认是否在ROS可以找到:
$ rospackfind beginner_tutorials
结果如下:
/opt/ros/cturtle/ros/beginner_tutorials
(3) 我们可以查看package相关第一层依赖项
$ rospack depends1 beginner_tutorials ----package第一层依赖项查询
结果如下:
std_msgs
rospy
roscpp
$ rospack depends1 rospy----package依赖项rospy的第一层依赖项查询
结果如下:
roslib
roslang
$ rospack depends beginner_tutorials ---package所有依赖项查询
genmsg_cpp
rospack
roslib
rosconsole
std_msgs
roslang
rospy
xmlrpcpp
roscpp
//
参考网址:http://www.ros.org/wiki/ROS/Tutorials/BuildingPackages
1,系统关联
$ roscdturtlesim
$ catmanifest.xml
得到结果:
<package>
</package>-----得到turtlesim需要exwidgets
rosdep命令 ----根据ROS packages来安装系统变量
用法:
$ rosdepinstall [package]
例子:
$ rosdepinstall turtlesim
得到结果:
executing this script: -----如果已经安装
#No Packages to install
set -o errexit -----如果没有安装
set -o verbose
if [ ! -f /opt/ros/lib/libboost_date_time-gcc42-mt*-1_37.a ] ;then
fi
if [ ! -f /opt/ros/lib/liblog4cxx.so.10 ] ; then
fi
if [ ! -f /opt/ros/lib/libboost_date_time-gcc42-mt*-1_37.a ] ;then
fi
if [ ! -f /opt/ros/lib/liblog4cxx.so.10 ] ; then
fi
2,编译packages
rosmake命令 ---编译package
(1)编译单个package
用法:
$ rosmake[package]
例子:
$ rosmakebeginner_tutorials
得到结果:
[ rosmake ] Packages requested are: ['beginner_tutorials']
[ rosmake ] Logging todirectory/home/jason/.ros/rosmake/rosmake_output-20110110-092837
[ rosmake ] Expanded args ['beginner_tutorials'] to:
['beginner_tutorials']
[ rosmake ] Checking rosdeps compliance for packagesbeginner_tutorials. This may take a fewseconds.
[ rosmake ] rosdep check passed all system dependencies inpackages
[rosmake-0] Starting>>> roslib [ make ]
[rosmake-0] Finished<<< roslib ROS_NOBUILDin package roslib
[rosmake-1] Starting>>> roslang [ make ]
[rosmake-0] Starting>>> rosconsole [ make]
[rosmake-0] Finished<<< rosconsoleROS_NOBUILD in package rosconsole
[rosmake-0] Starting>>> std_msgs [ make ]
[rosmake-1] Finished<<< roslangROS_NOBUILD in package roslang
[rosmake-0] Finished<<< std_msgsROS_NOBUILD in package std_msgs
[rosmake-0] Starting>>> xmlrpcpp [ make ]
[rosmake-1] Starting>>> rospy [ make ]
[rosmake-1] Finished<<< rospy ROS_NOBUILDin package rospy
[rosmake-0] Finished<<< xmlrpcppROS_NOBUILD in package xmlrpcpp
[rosmake-0] Starting>>> roscpp [ make ]
[rosmake-0] Finished<<< roscpp ROS_NOBUILDin package roscpp
[rosmake-0] Starting>>> beginner_tutorials[ make ]
[rosmake-1] Starting>>> rosout [ make ]
[rosmake-1] Finished<<< rosout ROS_NOBUILDin package rosout
[ rosmake ] All 2 linesbeginner_tutorials: 0.1 sec ] [ 1Active 10/11 Complete ]
{-------------------------------------------------------------------------------
-------------------------------------------------------------------------------}
[ rosmake ] Output from build of package beginner_tutorialswritten to:
[ rosmake ] /home/jason/.ros/rosmake/rosmake_output-20110110-092837/beginner_tutorials/build_output.log
[rosmake-0] Finished<<< beginner_tutorials[FAIL] [ 0.09 seconds ]
[ rosmake ] Halting due to failure in packagebeginner_tutorials.
[ rosmake ] Waiting for other threads to complete.
[ rosmake ] Results:
[ rosmake ] Built 11 packages with 1 failures.
[ rosmake ] Summary output to directory
[ rosmake ]/home/jason/.ros/rosmake/rosmake_output-20110110-092837
(2)编译多个packages
用法:
$ rosmake[package1] [package2] [package3]
例子:
$ rosdepinstall turtle_teleop rxtools
$ rosmaketurtle_teleop roscpp_tutorials rospy_tutorials rxtools