当前位置:网站首页>Ros2 - function package (VI)
Ros2 - function package (VI)
2022-07-05 06:51:00 【Me and nano】
ROS2 Robot operating system
List of articles
Preface
Every robot may have many functions , For example, mobile control 、 Visual perception 、 Autonomous navigation, etc , If we put the source code of these functions together, of course, it is also possible , But when we want to share some of these functions with others , You will find that the code is mixed together , It's hard to separate .
One 、 What is the feature pack

for instance , We have a lot of red beans 、 Mung bean 、 soybean , Suppose they are all in a bag , If you just want to take out the soybeans , Do you have to find out one by one among the colorful beans , The more the number of , The more headache you get ; If we put beans of different colors in three different bags , When you need to take out some beans , You can find it immediately .
This is the principle of function package , We divide the code of different functions into different function packages , Try to reduce the coupling relationship between them , When need is in ROS When sharing with others in the community , Just explain how to use this function pack , Others can use it soon .
So the mechanism of the function package , Is to improve ROS One of the important methods of software reuse rate in .
Two 、 Specific use of function package
1. Create Feature Pack
We can use this instruction :
ros2 pkg create --build-type <build-type> <package_name>
ros2 In command :
**pkg:** Indicates the functions related to the function package ;
**create:** Means to create a function package ;
build-type: Indicates that the newly created function pack is C++ still Python Of , If you use C++ perhaps C, Then this is the same as ament_cmake, If you use Python, Just follow ament_python;
**package_name:** Name of the new function package .
For example, create in the terminal respectively C++ and Python Version of the Feature Pack :
cd ~/dev_ws/src
ros2 pkg create --build-type ament_cmake learning_pkg_c # C++
ros2 pkg create --build-type ament_python learning_pkg_python # Python

2. Compile function packs
In the created function package , We can continue to write the code , Then you need to compile and configure environment variables , In order to operate normally :
cd ~/dev_ws/src
colcon build # Compile all feature packs in the workspace
source install/local_setup.bash
3. Structure of function package
C++ Function pack
Take a look first C++ Type of function pack , There must be two files :package.xml and CMakerLists.txt.
package.xml The main contents of the document are as follows , Contains the copyright description of the Feature Pack , And various dependent declarations .
CMakeLists.txt Files are Compilation Rules ,C++ The code needs to be compiled to run , So you must set how to compile in this file , Use CMake grammar .
Python Function pack
C++ The function package needs to compile the source code into an executable , however Python Language is analytic , No compilation required , So there will be some differences , But there will also be these two files :package.xml and setup.py.
package.xml The main contents of the document and C++ Version function pack , Contains the copyright description of the Feature Pack , And various dependent declarations .
setup.py The file also contains some copyright information , besides , also “entry_points” Configured program entry 
边栏推荐
- Dameng database all
- ‘mongoexport‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
- Pycahrm reports an error: indentation error: unindent does not match any outer indentation
- 微信小程序路由再次跳轉不觸發onload
- 2022 winter vacation training game 5
- Page type
- 'mongoexport 'is not an internal or external command, nor is it a runnable program or batch file.
- Integer to 8-bit binary explanation (including positive and negative numbers) scope of application -127~+127
- 【软件测试】06 -- 软件测试的基本流程
- Vscode editor
猜你喜欢

Redis-01. First meet redis
![LSA Type Explanation - lsa-1 [type 1 LSA - router LSA] detailed explanation](/img/1f/30407bce35c324cc90f139b6f09fd1.jpg)
LSA Type Explanation - lsa-1 [type 1 LSA - router LSA] detailed explanation

confidential! Netease employee data analysis internal training course, white whoring! (attach a data package worth 399 yuan)
![[MySQL 8.0 does not support capitalization of table names - corresponding scheme]](/img/ea/a1e0722c43f56aff3e79f95c99ba8a.png)
[MySQL 8.0 does not support capitalization of table names - corresponding scheme]

Use ffmpeg to rotate, flip up and down, and flip horizontally

Orin two brushing methods

Orin 安装CUDA环境

Design specification for mobile folding screen

Instruction execution time

Volcano 资源预留特性
随机推荐
扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
Getting started with typescript
Cloud native related technology learning
Vscode creates its own code template
ROS2——topic话题(八)
Use the Paping tool to detect TCP port connectivity
C语言数组专题训练
【MySQL8.0不支持表名大写-对应方案】
Rehabilitation type force deduction brush question notes D1
Marvell 88e1515 PHY loopback mode test
【软件测试】05 -- 软件测试的原则
How to correctly ask questions in CSDN Q & A
The differences and connections among cookies, sessions, JWT, and tokens
2022年中纪实 -- 一个普通人的经历
vim
LSA Type Explanation - lsa-5 (type 5 LSA - autonomous system external LSA) and lsa-4 (type 4 LSA - ASBR summary LSA) explanation
testing framework
三体目标管理笔记
MySQL (UDF authorization)
MQClientException: No route info of this topic: type_ topic