ROS Learning (III)-create a simple release node and subscription node, ros Node
Summer vacation at home is a little slack, no, very slack--|! My conscience hurts and I want to make up the progress. But I suddenly find that I have been interrupted for a while, and I have forgotten some of the most basic symbols.
This time, we made a very basic task, restoring the previous progress.
1. Create a workspace
$ mkdir -p ~/catkin_xi/src$ cd ~/catkin_xi/src
The corresponding folder has been created in the home folder. Of course, there is nothing empty in it.
Then, use the catkin_make command to create a folder in the catkin workspace. The current directory should be able to see the 'build 'and 'devel' folders. In the 'devel 'folder, you can see several setup. sh files.
$ cd ~/catkin_xi/$ catkin_make
Next, Run "source" and set the setup. sh file.
Switch the path to the src path,
$ cd ~/catkin_ws/src
$ catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
Use this command to create a new package named 'ininner _ tutorials ', which depends on std_msgs, roscpp, and rospy. Hosts file, both of which automatically contain information you provided when executing the catkin_create_pkg command.
Use the rospack command tool to view the first-level dependent package.
$ rospack depends1 beginner_tutorials
Of course, this may encounter a problem, that is, an error occurs. Enter this code to correct it.
$ source devel/setup.bash
Rospack lists the dependent packages that are used as parameters when running the catkin_create_pkg command. These dependent packages are then stored in the package. xml file. Open this file and paste it in it,
<?xml version="1.0"?><package>... <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend> <run_depend>roscpp</run_depend> <run_depend>rospy</run_depend> <run_depend>std_msgs</run_depend>...</package>
A package can also have several indirect dependent packages. Fortunately, using rospack can recursively detect all dependent packages.
Then, create a simple release node and subscription node.
$ roscd beginner_tutorials$ mkdir src$ touch src/talker.cpp
The same is true for creating subscription nodes.
$ cd beginner_tutorials$ touch src/listener.cpp