当前位置:网站首页>[ROS] (02) Create & compile ROS package Package
[ROS] (02) Create & compile ROS package Package
2022-08-02 14:21:00 【CynalFly】
文章只是个人学习过程中学习笔记,主要参考ROS教程1.
先阅读这篇文章:
[ROS](01)创建ROS工作空间:https://blog.csdn.net/CynalFly/article/details/125617470
1. 概述
packages是在ROSArrangement and organization of the main unit,是在ROSThe smallest unit that can be set up and share.
在编译时,catkinBuild system will recursive search and edit
srcEach file directorypackage.It can be a fewpackage放在同一个文件夹下.
2. package结构
ROS软件包packageFollow a common structure,如下图所示.packageDirectory of the file name is recklessly cast.其中只有 CMakeLists.txt 和 package.xml 是必需项,Everything else is determined according to the demand of.
CMakeLists.txt::包含CMake构建文件,定义package的包名、源文件、依赖、The target file compiling rules such as;package.xml:包含了 package Describe the relationship between information and rely on,And record version、维护者、Licenses and other relevant software package of information;scripts:可执行脚本,Python脚本(.py),shell脚本(.sh);src:源文件C++include:C++头文件msg:Store the message file(.msg)srv:存放服务文件(.srv)action:Where action files(.action)launch:存放launch文件(.launch或.xml),可一次运行多个节点;config:配置信息;
3. 创建软件包Package
创建一个package,需要在ROS(catkin)工作空间中的src文件夹目录下,使用catkin_create_pkg脚本来创建.命令格式:
catkin_create_pkg <package_name> [depend1] [depend2] [depend3][...][dependn]
package_name:包名,To create the name of the software(必须)depend:依赖,Other packages depend on,例如std_msgs、rospy、roscpp等(非必须)
举例:创建一个名为beginner_tutorials的新软件包,软件包依赖std_msgs、rospy、roscpp.在终端中输入如下命令:
cd ~/catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
std_msgs:是ROSGive us a defined some standard data structure.rospy:是ROSTo provide us with a series ofpython接口.roscpp:是ROS给我们提供的c++的编程接口.
成功后,将在src目录下创建一个名为beginner_tutorials的文件夹,在该文件夹下的package.xml文件和一个CMakeLists.txtThe file has been fill in.

4. 编译软件包Package
编译(build)一个package,需要在ROS(catkin)工作空间目录下,使用catkin_make编译.在终端中输入如下命令:
cd ~/catkin_ws
catkin_make
catkin_make install # (可选)

The above command can one-time compilingROSWorking space all packagespackages.If want to compile a specific packages,命令格式:
catkin_make -DCATKIN_WHITELIST_PACKAGES="package1;package2"
package1和package2为包名- Use this command after,在同一窗口下,直接使用catkin_makeOr will only compile a package
举例:编译软件包packagebeginner_tutorials.在终端中输入如下命令:
catkin_make -DCATKIN_WHITELIST_PACKAGES=”beginner_tutorials”
If you want to restore to compile all the packages,在终端中输入如下命令:
catkin_make -DCATKIN_WHITELIST_PACKAGES=""
5. package的命令行工具
随着ROSIncreasing the package,中使用Linux内置的命令行工具(如cd、ls等)When switching directories and search a file,Can be very complicated.因此ROSProvides a special command line tools(Command-line Tolls)来简化这些操作.
rospack:
rospackCommand can get packagepackage的有关信息.常见的命令包括:
rospack find [package]:返回package的绝对路径

rospack depends1 [package]:返回一个packageThe level of dependence on listrospack depends [package]:返回一个packageAll of the direct and indirect rely on listrospack depends-on [package]:返回依赖于指定package的所有packages list

rospack list | grep <package-name> <package-dir>:Returns the package or packages include pathpackage list

上述命令的package可以缺省,Is considered in the current directory of all rely on;But this has a premise is the current directory contains
package.xml.If does not include the return information:[rospack] Error:no package given.
roscd:
roscd可以直接切换到ROS软件包,它和Linux系统的cd的区别,请看:
[ROS]roscd和cd的区别:https://blog.csdn.net/CynalFly/article/details/125519428
rosls:
rosls可以直接lsROS软件包的内容.用法:rosls [package].
查看ROSAll of the command line tools:http://wiki.ros.org/ROS/CommandLineTools
ROS.otg. ROS教程[EB/OL]. 2020-12-22[2022-7-5].
http://wiki.ros.org/cn/ROS/Tutorials. ︎
边栏推荐
猜你喜欢
随机推荐
8580 Merge linked list
Unit 5 Hold Status
Network pruning (1)
MarkDown语法汇总
Deep learning framework pytorch rapid development and actual combat chapter3
8583 顺序栈的基本操作
网页设计(新手入门)[通俗易懂]
[ROS] (04) Detailed explanation of package.xml
ftp常用命令详解_iftop命令详解
Flask框架
【ROS】工控机的软件包不编译
MySQL数据库语法格式
run yolov5
verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第九章)
Unit 10 Continuous Tuning
Unit 6 meet ORM
Unit 14 Viewsets and Routing
Unit 8 Middleware
Raj delivery notes - separation 第08 speak, speaking, reading and writing
跑跑yolov5吧

![[ROS] The difference between roscd and cd](/img/a8/a1347568170821e8f186091b93e52a.png)





ROS通信 —— 话题(Topic)通信](/img/21/d79f2c4e246eb9ea39df9c7435bb36.png)

