当前位置:网站首页>[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
src
Each 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.txt
The 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可以直接ls
ROS软件包的内容.用法: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. ︎
边栏推荐
猜你喜欢
YOLOv7使用云GPU训练自己的数据集
[ROS]roscd和cd的区别
MarkDown语法汇总
Implementation of redis distributed lock and watchdog
What are the file encryption software?Keep your files safe
Hands-on OCR (1)
yolov5 improvement (1) Add attention focus mechanism
Raft协议图解,缺陷以及优化
MobileNet ShuffleNet & yolov5替换backbone
Unit 10 Continuous Tuning
随机推荐
Haystack的介绍和使用
第八单元 中间件
verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第九章)
网络剪枝(1)
8576 顺序线性表的基本操作
理解TCP长连接(Keepalive)
Flask框架的搭建及入门
使用云GPU+pycharm训练模型实现后台跑程序、自动保存训练结果、服务器自动关机
瑞吉外卖笔记——第08讲读写分离
EasyExcel 的使用
[ROS] The software package of the industrial computer does not compile
chapter6可视化(不想看版)
Camera Hal(Hal3)层修改Preview流
Flask contexts, blueprints and Flask-RESTful
LayoutParams的详解
第十单元 前后连调
Unit 13 Mixing in View Base Classes
如何自定义feign方法级别的超时时间
Creating seven NiuYun Flask project complete and let cloud
网页设计(新手入门)[通俗易懂]