当前位置:网站首页>Programming implementation of ROS learning 2 publisher node
Programming implementation of ROS learning 2 publisher node
2022-07-05 08:45:00 【m0_ forty-six million ninety-three thousand eight hundred and t】
One . Overview of the topic release process :
1. Create topic file .cpp/.py
2. compile .cpp The file needs to be compiled ,.py File is not required
3. Configure environment variables
4. Execute the release topic file
Two 、 The specific process is as follows :
2.1 Create topic file
In the function package of the corresponding workspace Src Next , Create topic file , If you use c++ Write , Namely .cpp file , use py Writing is .py file .
The document consists of at least four parts :
1. initialization ROS node
2. towards Ros Master Register node information , Including the topic name and topic message type (ROS Official or customized messages , How to view ros The message structure provided by the system is detailed in the document :ROS Study 3 Custom message _m0_46093829 The blog of -CSDN Blog )
3. Create message data ( Whether it's official or customized , In the message type file (.msg file ) Only variables and their data types are declared in , So you need to wait for variables here ......)
4. Circulate messages at a certain frequency
See the following for specific examples , This routine is Gu Yueju ROS21 Tell me an example .
2.2 compile
After saving the file , It's time to compile , Be careful cpp The file needs to be compiled ,py File is not required . The specific compilation method is :
2.2.1 Set Compilation Rules
Go back to the function package directory , find CMakeLists.txt( Set Compilation Rules ), Then copy the following two lines of code to Install above
add_executable( File name src/ File name .cpp)# Set the name of the code file to be compiled and the generated executable , That is, which program file is compiled into an executable file
target_link_libraries(velocity_publisher${catkin_LIBRARIES})# Set up link library , Put your executable file and ROS Make a link to the library in .
2.2.2 catkin_make
After modification, you can return to the root directory of the workspace to compile .catkin_make
2.3 Configure environment variables
Compile and then use source Configure an environment variable OK 了 .source devel/setup.bash
The specific compilation and configuration environment variables are in ROS Learning notes 1 In the introduction .
3、 ... and 、 Execute the topic file to publish the topic :
rosrun Folder name file name
边栏推荐
- 【日常训练】1200. 最小绝对差
- Halcon wood texture recognition
- Halcon color recognition_ fuses. hdev:classify fuses by color
- Apaas platform of TOP10 abroad
- 2022.7.4-----leetcode. one thousand and two hundred
- Guess riddles (142)
- Esp8266 interrupt configuration
- Warning: retrying occurs during PIP installation
- Guess riddles (7)
- Daily question - input a date and output the day of the year
猜你喜欢
我从技术到产品经理的几点体会
猜谜语啦(8)
猜谜语啦(142)
Halcon: check of blob analysis_ Blister capsule detection
Low code platform | apaas platform construction analysis
猜谜语啦(6)
资源变现小程序添加折扣充值和折扣影票插件
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
随机推荐
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
Illustration of eight classic pointer written test questions
Halcon snap, get the area and position of coins
GEO数据库中搜索数据
容易混淆的基本概念 成员变量 局部变量 全局变量
Program error record 1:valueerror: invalid literal for int() with base 10: '2.3‘
Arduino burning program and Arduino burning bootloader
2022.7.4-----leetcode.1200
Bluebridge cup internet of things basic graphic tutorial - GPIO input key control LD5 on and off
Classification of plastic surgery: short in long long long
猜谜语啦(7)
多元线性回归(sklearn法)
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?
【日常训练--腾讯精选50】557. 反转字符串中的单词 III
Cmder of win artifact
U8g2 drawing
Meta标签详解
L298N module use
[daily training] 1200 Minimum absolute difference
Redis实现高性能的全文搜索引擎---RediSearch