The ros workspace is a folder used to store ros function packages. It usually ends with ws. Let's create a space named ros_ws as an example to explain how to create a ros workspace.
Take creating the ros_ws space in the ~ directory as an example, and enter in the terminal,
cd
mkdir ros_ws
We create a src folder in the src directory of the workspace to store the function package created later, and enter it in the terminal.
xxxxxxxxxx
cd ~/ros_ws
mkdir src
Terminal input,
xxxxxxxxxx
cd ~/ros_ws/src
catkin_init_workspace
Use the catkin_make command to compile the functions in the entire workspace. You need to compile in the workspace directory,
xxxxxxxxxx
cd ~/ros_ws
catkin_make
Add the workspace to the environment variable so that you can find the function package when you open the terminal. Otherwise, you need to source the workspace every time to find the function package and related programs. Enter in the terminal.
xxxxxxxxxx
echo "source ~/ros_ws/devel/setup.bash" >> ~/.bashrc
Enter the following command to refresh the environment variables or reopen the terminal to take effect. Enter in the terminal,
xxxxxxxxxx
source ~/.bashrc