当前位置:网站首页>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
边栏推荐
猜你喜欢
Count of C # LINQ source code analysis
Example 010: time to show
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
Yolov4 target detection backbone
Guess riddles (4)
Apaas platform of TOP10 abroad
每日一题——替换空格
MATLAB小技巧(28)模糊綜合評價
Lori remote control commissioning record
Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
随机推荐
PIP installation
猜谜语啦(6)
It cold knowledge (updating ing~)
猜谜语啦(4)
Business modeling of software model | stakeholders
asp.net(c#)的货币格式化
Meta标签详解
Numpy 小坑:维度 (n, 1) 和 维度 (n, ) 数组相加运算后维度变为 (n, n)
Guess riddles (9)
Lori remote control commissioning record
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Esp8266 interrupt configuration
696. Count binary substring
Speech recognition learning summary
Arduino burning program and Arduino burning bootloader
Guess riddles (4)
特征工程
猜谜语啦(2)
JS asynchronous error handling
ABC#237 C