当前位置:网站首页>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
边栏推荐
- The art of concurrent programming (6): explain the principle of reentrantlock in detail
- Definition format of array
- (valid for personal testing) compilation guide of paddedetection on Jetson
- Paddlepaddle model to onnx
- 淺學一下I/O流和File類文件操作
- Instructions for fastmock
- 2022 团体程序设计天梯赛 模拟赛 1-8 均是素数 (20 分)
- Basic use of Charles
- C-11 problem I: find balloon
- Paddlepaddle does not support arm64 architecture.
猜你喜欢
Paddlepaddle model to onnx
Learn about I / O flow and file operations
抽象类、接口、常用关键字
Create virtual machine
对象和类的概念
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
Design and implementation of redis (2): how to handle expired keys
JS - accuracy issues
浅学一下I/O流和File类文件操作
MySQL query specifies that a row is sorted to the first row
随机推荐
2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
浅学一下I/O流和File类文件操作
PyMOL usage
VS Studio 修改C语言scanf等报错
List interface of collection
Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
Visual programming - Experiment 1
Design and implementation of redis (3): persistence strategy RDB, AOF
Using swagger in. Net5
抽象类、接口、常用关键字
Deep learning notes (II) -- principle and implementation of activation function
Now is the best time to empower industrial visual inspection with AI
Chapter VI, Section III pointer
Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
Install PaddlePaddle on ARM
Téléchargement en vrac de fichiers - téléchargement après compression
C-11 problem h: treasure chest 2
深度學習筆記(二)——激活函數原理與實現
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
Unity knowledge points (common core classes)