Welcome to RDK S600 Developer Kit repository
4.ROS2 workspace
4. ROS2 Workspace
Note: The accompanying reference video uses the ROS Humble version, for reference only
1. Workspace Overview
In ROS robot development, when developing specific functions for a robot, all your code, parameters, scripts, and other files need to be placed in a folder for management. This folder is called the workspace in the ROS system. A workspace is a folder that stores project development-related files, serving as the base camp for storing all materials during the development process.
2. Creating a Workspace
Create a folder as the workspace for storing project files. yahboomcar_ws is the folder name, you can name it arbitrarily.
mkdir -p yahboomcar_ws/srcNavigate to the workspace folder:
xxxxxxxxxxcd ~/yahboomcar_ws
3. Building the Workspace
xxxxxxxxxxcolcon buildAfter the build completes, you should see the build, install, and log directories:

A typical workspace structure in ROS is shown above. yahboomcar_ws is the root directory of the workspace, containing four subdirectories, also called four subspaces.
src, Source Space: Where future code and scripts you write are manually placed;
build, Build Space: Stores intermediate files generated during the build process;
install, Install Space: Contains compiled executables and scripts;
log, Log Space: Stores various warnings, errors, and information logs during build and runtime.
Generally speaking, most of our operations are performed in the src directory. After successful build, the results in the install directory are executed. The build and log directories are rarely used.
It should also be emphasized that the workspace name can be defined by ourselves, and the number of workspaces is not limited. For example:
xxxxxxxxxxWorkspace 1: ros2_ws_a, for Robot A developmentWorkspace 2: ros2_ws_b, for Robot B developmentWorkspace 3: ros2_ws_c, for Robot C developmentThe above is completely acceptable, just like creating multiple new projects in an integrated development environment. They coexist as并列关系.
4. Setting Up Environment Variables
After successful build, to enable the system to find your packages and executables, you need to set environment variables:
xxxxxxxxxx# Only takes effect in current terminalsource install/setup.bash# Takes effect in all terminalsecho "source ~/yahboomcar_ws/install/setup.bash" >> ~/.bashrcAt this point, the creation, building, and configuration of the workspace is complete.