ROS-1 Hello Word in ROS
This article was original written by Jin Tian, welcome re-post, first come with https://jinfagang.github.io . but please keep this copyright info, thanks, any question could be asked via wechat:
jintianiloveu
0. ROS WorkSpace
ok, before we get started, we should know how to start a workspace, simply using:
|
|
these command will start a ws, and generate a workspace.
1. ROS IDE
I think the most convenient IDE is roboware-studio, this can be downloaded and install from official site. Run it in terminal after you source your ros enviroment. roboware-studio based on vscode, it’s very simple to use.
After you install roboware and you have your workspace, you should right run it after this:
|
|
So you will see a beautiful interface of vscode, you haven’t add any packages right? Using this to create a ros package:
|
|
this command will create a new package named: tutor
, and the rest package are dependencies, std_msgs contains all message type of many languages, and rospy are the essential support of your package, you will have both python and C++ program in one package.
2. ROS Hello World
ok, once you have your package created, you should add a new main.cpp
to your src/ folder, add there codes into it:
|
|
this will implement a message publisher, it will publish a message of : Hello, this is me ...
in very 0.1 seconds which is in frequency of 10 Hz.
ok, back to your workspace root folder, and run:
|
|
this will make the whole workspace, include all your packages. After that you could run your node like this:
|
|
the tutor
is your package name and of-course this is your node name, after that is the executable program name of your package, be caution that the executable program maybe Python and C++, so every package could have multiple executable program.