当前位置:网站首页>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
边栏推荐
猜你喜欢
Redis实现高性能的全文搜索引擎---RediSearch
Example 005: three numbers sorting input three integers x, y, Z, please output these three numbers from small to large.
Xrosstools tool installation for X-Series
猜谜语啦(8)
Halcon: check of blob analysis_ Blister capsule detection
猜谜语啦(2)
Digital analog 1: linear programming
An enterprise information integration system
Illustration of eight classic pointer written test questions
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
随机推荐
[noi simulation] juice tree (tree DP)
location search 属性获取登录用户名
js异步错误处理
12、动态链接库,dll
Halcon color recognition_ fuses. hdev:classify fuses by color
猜谜语啦(9)
Digital analog 2: integer programming
C# LINQ源码分析之Count
Task failed task_ 1641530057069_ 0002_ m_ 000000
Guess riddles (6)
图解网络:什么是网关负载均衡协议GLBP?
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
Program error record 1:valueerror: invalid literal for int() with base 10: '2.3‘
[daily training -- Tencent selected 50] 557 Reverse word III in string
Guess riddles (4)
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
Guess riddles (11)
L298N module use
Pytorch entry record