Creation of ros function package (detailed version)

The creation process of this ros function package is suitable for beginners

1: Find a suitable directory to create a folder. In this article, a folder named ac is selected to create a function package. The name of the newly created folder can be named at will. It is recommended to use English, or compile other files Sometimes errors may occur.

Enter the command to create the folder of the function package under the folder where the function package is to be created. The entered command and the command displayed on the terminal after the input is successful are shown in the following figure:

mkdir de_ws

After the creation is successful, it will look like this in the file:

 

2. Create the src function package under the de_ws folder just created. Note: this name can only be src, and cannot be replaced with other names . The commands entered in the terminal and the screenshots displayed are shown in the following figure:

 ls
cd de_ws
mkdir src

 After the folder is successfully created, the folder will appear as shown in the following figure:

 

Open the src file and you will find that it is empty and there is nothing, as shown in the following figure:

3Use catkin_init_workspace to initialize the current folder, change the properties, and become the workspace of ros. The command and terminal screenshot are shown in the following figure:

cd de_ws
cd src
catkin_init_workspace

 Open the src folder and you will see a cmakelist.txt file, as shown below:

4: Then you can use catkin_make to compile the newly created function package, and check whether the compilation is successful. Please note  : when compiling the ros function package, it must be compiled in the file of the function package (for example, the text is the de_ws folder), do not Compile under the src folder. The compiled commands and terminal screenshots are shown in the following figure:

cd ..
catkin_make

start section:

 Compile to the last part:

 What it looks like under the de_ws folder:

5 As can be seen from the figure above, there is still a lack of install workspace, so create the install space next, and the commands and terminal screenshots are shown in the figure below:

catkin_make install

 The screenshots under the folder are as shown in the following figure:

 6 Create a function package for writing code. The function package for writing code needs to be written under src, in the form of catkin_creat_pkg package name dependency. The command and terminal screenshots are shown in the following figure:

 cd src
catkin_create_pkg test_pkg std_msgs rospy roscpp

 The form of the folder is shown in the figure below:

 7: Let's compile it:

cd ..
catkin_make

start part

 to the last part:

 8 Set environment variables

source devel/setup.bash

9 Make sure the workspace is properly overwritten by the install script:

echo $ROS_PACKAGE_PATH

 The above is the detailed process of creating a feature package, the hard work pays off, come on, hurry up.

Guess you like

Origin blog.csdn.net/qq_45677875/article/details/127820470