ROS Learning (III)-create a simple release node and subscription node, ros Node

Source: Internet
Author: User

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

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.