当前位置:网站首页>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
边栏推荐
- mui. Plusready does not take effect
- The fourth operation
- Paddlepaddle model to onnx
- Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
- 深度学习笔记(二)——激活函数原理与实现
- 【微服务】(十)—— 统一网关Gateway
- Section 2 map and structure in Chapter 6
- JS - accuracy issues
- Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
- 標識符、關鍵字、數據類型
猜你喜欢

Wechat applet cloud database value assignment to array error

Build websocket server in. Net5 webapi

Design and implementation of redis (1): understand data structures and objects

深度学习笔记(二)——激活函数原理与实现

Openvino only supports Intel CPUs of generation 6 and above

浅学一下I/O流和File类文件操作

JS - accuracy issues

Using swagger in. Net5

STM32 advanced timer com event

C abstract class
随机推荐
PYMOL-note
JS changes the words separated by dashes into camel style
【微服务】(十)—— 统一网关Gateway
Common auxiliary classes
Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
QT learning summary
Téléchargement en vrac de fichiers - téléchargement après compression
Visual programming -- how to customize the mouse cursor
浅学一下I/O流和File类文件操作
Instructions for fastmock
AWS from entry to actual combat: creating accounts
Use the thread factory to set the thread name in the thread pool
Unity knowledge points (common core classes)
On the principle of concurrent programming and the art of notify / Park
QT dynamic translation of Chinese and English languages
The art of concurrent programming (5): the use of reentrantlock
SQL learning record
7-2 Tushare
C set
Visual programming - Experiment 1