当前位置:网站首页>Helloword routine for ROS
Helloword routine for ROS
2022-06-28 07:40:00 【youbin2013】
ROS Of helloword routine
ROS The general flow of the program implementation in is as follows :
- First create a workspace ;
- Create another function package ;
- Edit source file ;
- Edit profile ;
- Compile and execute .
Create a workspace :
Create a new folder to represent the workspace , for example workspace01:
mkdir -p workspace01/src
cd workspace01
catkin_make
Create a folder workspace01, And create subfolders src Used to store source files , call catkin_make command , Compile the initial workspace , Generate directories for the workspace .
Create a toolkit :
cd src
catkin_create_pkg workspace01 roscpp rospy std_msgs
Get into workspace01/src Next , Use catkin_create_pkg Command generation toolkit . This command A function package will be generated in the workspace , 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 .
Edit source file :
cd workspace01/src/helloworld/src
vim helloworld_c.cpp
Edit code :
#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;
}
edit ros Under bag Cmakelist.txt file :
cd workspace01/src/helloworld
vim Cmakelist.txt
find add_executable Location :
add_executable( step 3 The source file name of
src/ step 3 The source file name of .cpp
)
add_executable(hello src/helloworld_c.cpp)
The first parameter is the name of the target to be generated , The second is the source file path ;
target_link_libraries( step 3 The source file name of
${catkin_LIBRARIES}
)
target_link_libraries(hello
${catkin_LIBRARIES}
)
The first parameter is changed to the target name .
Enter the workspace directory and compile :
cd workspace01
catkin_make
Execute compile command , Generate target file .
Execute the generated object file :
Start command terminal 1, Input ros Core startup command :
roscore
Start command terminal 2, Start the environment variable , Then start the node program :
cd workspace01
source ./devel/setup.bash
rosrun helloworld hello
边栏推荐
猜你喜欢

vite2.9 中指定路径别名

Jetpack - defects of livedata component and Countermeasures

本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献

Modifying MySQL port number under Linux

异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
![[thanos source code analysis series]thanos query component source code analysis](/img/e4/2a87ef0d5cee0cc1c1e1b91b6fd4af.png)
[thanos source code analysis series]thanos query component source code analysis

Tencent continued to lay off staff in the second half of the year, and all business groups reduced by at least 10%. What do you think of this? Followers

Mysql57 zip file installation

linux下修改mysql用户名root

Kubernetes theoretical basis
随机推荐
Open62541 import nodeset file directly
Leetcode learning records
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
Evaluation of inverse Polish expression < difficulty coefficient >
云原生(待更新)
QT -- communication protocol
NDK cross compilation
HJ base conversion
HJ delete the character with the least number of occurrences in the string
vite2.9 中指定路径别名
ACM笔记
Practice of traffic recording and playback in vivo
How to configure DDR3 of dm8148
Understanding of OPC protocol
Install haproxy
What is EC blower fan?
HJ prime factor
"Three routines" of digital collection market
安全培训是员工最大的福利!2022新员工入职安全培训全员篇
Update pip to the latest version