Before starting ROS application development, there are some necessary preparations to do, that is, to establish a workspace.
The way to build a workspace is:
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
The first line is the command to create a directory under linux. -p means mandatory. If there is no ~/catkin_ws, first create a ~/catkin_ws directory. Here ~/catkin_ws can be another name, but src is dedicated and cannot be changed.
The third line is the initial workspace command. After execution, there is a CMakeLists.txt file in the ~/catkin_ws/src directory.
The second line is to ensure the execution directory of the initialization command, and the initialization is the ~/catkin_ws/src directory.
After the workspace is established, you can start creating feature packages.
The command to create a feature package is:
cd ~/catkin_ws/src
catkin_create_pkg test_pkg std_msgs roscpp rospy
This command must be cd ~/catkin_ws/src first to execute it in the src directory of the workspace.
The first parameter is the name of the function package, followed by its dependent libraries.
Compile function package command
cd ~/catkin_ws
catkin_make
The execution of this command must first cd ~/catkin_ws This requires a directory
Set environment variables
source devel/setup.bash
After compiling, there will be more work space devel build 2 directories
The intermediate files are stored in the build directory, and the result files are stored in the devel directory
This setting environment directory is a relative path, my full path is /home/leon/catkin_ws/devel
There are four directories at the end of the workspace directory: src, devel, build, install, respectively, code space, development space (development results), compilation space (intermediate files), installation space (installation files)
This article introduces this, the specific function package creation, compilation, or learning in examples, here is just an introduction, make preparations before development.