当前位置:网站首页>ROS series (II): ROS quick experience, taking HelloWorld program as an example
ROS series (II): ROS quick experience, taking HelloWorld program as an example
2022-04-23 03:37:00 【Yi Lanjun】
We can achieve HelloWorld Program, for example , Brief introduction ROS How to use , The general flow is as follows :
- Create a workspace and initialize ;
- Create Feature Pack ;
- Edit source file ;
- Edit profile ;
- Compile and execute .
1 Create a workspace and initialize
First, you need to open the terminal , Enter the following command :
mkdir -p Custom workspace name /src
cd Custom workspace name
catkin_make
The above order , First, a workspace and a src subdirectories , Then enter the workspace and call catkin_make Command compilation .
2 Get into src establish ros Package and add dependencies
cd src
catkin_create_pkg Customize ROS Package name roscpp rospy std_msgs
The above order , The next workspace name will be generated “ Customize ROS Package name ” Function pack , The Feature Pack depends on roscpp、rospy And std_msgs, among roscpp It's using C++ Implementation of the library , and rospy Is the use python Implementation of the library ,std_msgs It's a standard message library , establish ROS Function pack time , Generally, we will rely on these three libraries to realize .
3 Get into ros Bag src Directory edit source file
cd Self defined ROS package
newly build C++ File and write execution code ( File name customization ):
#include "ros/ros.h"
int main(int argc, char *argv[])
{
// perform ros Node initialization
ros::init(argc,argv,"hello");
// establish ros inode handle ( Not necessary )
ros::NodeHandle n;
// Console output hello world
ROS_INFO("hello world!");
return 0;
}
4 edit ros The configuration file under the package : Cmakelist.txt file
take 136 Yes add_executable and 149 Yes target_link_libraries Change the code to :
add_executable( step 3 The source file name of src/ step 3 The source file name of .cpp)
target_link_libraries( step 3 The source file name of ${catkin_LIBRARIES})
5 Enter the workspace directory and compile
cd Custom workspace name
catkin_make
Generate build devel …
6 perform
Open the terminal 1 perform :
roscore
Open the terminal 2 perform :
cd working space
source ./devel/setup.bash
rosrun Package name C++ node
Command line output : HelloWorld!
版权声明
本文为[Yi Lanjun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220602231972.html
边栏推荐
- Variable definition and use
- PyMOL usage
- JS calculates the display date according to the time
- MySQL query specifies that a row is sorted to the first row
- 批量下載文件----壓縮後再下載
- Redis (17) -- redis cache related problem solving
- Using jsonserialize to realize data type conversion gracefully
- The art of concurrent programming (3): an in-depth understanding of the principle of synchronized
- Install PaddlePaddle on ARM
- Notes sur l'apprentissage profond (Ⅱ) - - Principe et mise en oeuvre de la fonction d'activation
猜你喜欢
Development record of primary sensitive word detection
Idea debug debugging tutorial
Design and implementation of redis (2): how to handle expired keys
Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
Unity Basics
Common net HP UNIX system FTP server listfiles returns null solution.
Visual programming - Experiment 1
【微服务】(十)—— 统一网关Gateway
对象和类的概念
随机推荐
C interface
Applet - WXS
C-11 problem h: treasure chest 2
【微服务】(十)—— 统一网关Gateway
Wechat payment iframe sub page has no response
On the principle of concurrent programming and the art of notify / Park
2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
QT dynamic translation of Chinese and English languages
Deep learning notes (II) -- principle and implementation of activation function
JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
Docker pulls MySQL and connects
L3-011 direct attack Huanglong (30 points)
Problem a: face recognition
According to the category information and coordinate information of the XML file, the category area corresponding to the image is pulled out and stored in the folder.
Unity basics 2
Unity Basics
Abstract classes, interfaces and common keywords
Design and implementation of redis (3): persistence strategy RDB, AOF
Oracle query foreign keys contain comma separated data
The query type of MySQL is very inefficient.