ros create workspace + function package

Learn how to create a feature pack today.

Following the tutorial, first create a catkin_ws folder, and then create a src folder below.

1. Pass: mkdir -p ~/catkin_ws/src. This order.

If you use the mkdir command to create the src folder directly, if there is no catkin_ws folder, then an error will occur, saying that it cannot be created without the folder.

Using the mkdir -p command, you can create a directory recursively. Even if the parent directory does not exist, the directory will be created automatically according to the directory hierarchy.

2. Continue. Switch to this folder and use the command cd ~/catkin_ws.

3. Continue. Compile by catkin_make command. (Compilation is the process of generating executable files from source code)

carry on. After the compilation is complete, the bulid and devel folders appear in the catkin_ws directory, and there are different files in the src, build and devel folders.

4. Then configure the environment variables. (Why configure environment variables? For easy access)

Go back to the main folder ctrl+h to show hidden folders. Then find the .bashrc file. Enter at the bottom of the file: source /home/zcfly/catkin_ws02/devel/setup.bash command.

Like below, add a line.

For the specific path, find your own setup.bash file, view the properties, and look at your own path.

Then source it. The source command is mainly to find files, and find the setup.sh file through this.

The source command is to configure the workspace, which is used to refresh the environment. It is essential to configure the current workspace. After each compilation, execute the following source command.

Regarding this command, here is an article by a netizen who is very detailed.

https://blog.csdn.net/u012686154/article/details/81978348

At this point, our catkin_ws workspace is created, and then a function package is created. The function package is in the src folder. The package we often say refers to the function package.

The package is where the code is written.

Use the command catkin_create_pkg to create a new feature package.

Let's create the first feature pack.

命令:catkin_create_pkg demo0 roscpp rospy std_msgs

The meaning of this command is to create a new feature package named'demo0', which depends on std_msgs, roscpp and rospy.

std_msgs, roscpp, and rospy are libraries that the ros program depends on.

Here is an article that summarizes the commonly used dependency libraries under ros: https://www.cnblogs.com/lovebay/p/11119524.html

According to this blog post: https://blog.csdn.net/gxuphf123/article/details/81128989

Go ahead.

Paste.

carry on

Then, I found that looking at the code is tired, install a qt. Here is a tutorial:

https://blog.csdn.net/qq_33838170/article/details/84346986

Then after the installation is complete, create a new qt project in the following folder, and then copy the code in my_demo.cpp above in the main function to the main function, and then debug.

Found the following error message:

Here is a solution:
https://blog.csdn.net/weixin_43948162/article/details/90238393

Yes, keep trying. Or not.

To be continued.

Guess you like

Origin blog.csdn.net/qqliuzhitong/article/details/112582850