当前位置:网站首页>Programming implementation of subscriber node of ROS learning 3 subscriber
Programming implementation of subscriber node of ROS learning 3 subscriber
2022-07-05 08:45:00 【m0_ forty-six million ninety-three thousand eight hundred and t】
One 、 Overview of topic subscription process
The general idea of subscribing to topics and publishing topics is the same
1. Subscriber creation
2. compile
3. Configure environment variables
4. Execute the subscription topic file
Two 、 The specific process
2.1 Subscriber creation
In the corresponding workspace Src Create .cpp or .py file
The document consists of at least four parts
1. initialization ROS node
2. Subscribe to required topics , Register callback function ( Subscribing to a topic is like responding to an interruption , You don't know when the topic you subscribe to will come , So it needs to be like a response terminal , Wait until the topic comes , Call the callback function immediately after the topic comes , Therefore, the callback function should be written as short as possible . It is mainly about printing messages or simply processing messages )
3. Loop waiting for topic messages , Once the message is received, it enters the callback function
4. Complete the message processing in the callback function
Pay attention to this , Callback functions cannot be too complex , Otherwise, just run your functions when the program is running , Don't respond until the next topic message .

2.2 compile
If it is .cpp Files need to be compiled , If it is .py Files don't need to be , The specific compilation process can be seen ROS Study 2 Post topics (ROS Study 2- Post topics _m0_46093829 The blog of -CSDN Blog )
1. Set Compilation Rules
2. In the workspace catkin_make
3、 ... and 、 Configure environment variables
source devel/setup.bash
Four 、 Execute the subscription topic file
rosrun Folder name Topic name
边栏推荐
- 深度学习模型与湿实验的结合,有望用于代谢通量分析
- 特征工程
- Affected tree (tree DP)
- 【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
- One question per day - replace spaces
- Digital analog 2: integer programming
- Shift operation of complement
- Esphone retrofits old fans
- Some pitfalls of win10 network sharing
- Example 005: three numbers sorting input three integers x, y, Z, please output these three numbers from small to large.
猜你喜欢

猜谜语啦(4)

Digital analog 1: linear programming

深度学习模型与湿实验的结合,有望用于代谢通量分析

Example 006: Fibonacci series

Bluebridge cup internet of things competition basic graphic tutorial - clock selection

每日一题——输入一个日期,输出它是该年的第几天

图解八道经典指针笔试题

Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?

Run menu analysis

猜谜语啦(5)
随机推荐
皮尔森相关系数
C语言标准函数scanf不安全的原因
Guess riddles (4)
第十八章 使用工作队列管理器(一)
Example 005: three numbers sorting input three integers x, y, Z, please output these three numbers from small to large.
287. Looking for repeats - fast and slow pointer
Meta标签详解
Guess riddles (5)
Is the security account given by Yixue school safe? Where can I open an account
Some pitfalls of win10 network sharing
696. Count binary substring
Chapter 18 using work queue manager (1)
容易混淆的基本概念 成员变量 局部变量 全局变量
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
Run menu analysis
MATLAB小技巧(28)模糊綜合評價
location search 属性获取登录用户名
L298N module use
Affected tree (tree DP)
猜谜语啦(142)