ROS 2 VS Code Workspace Configuration
This section explains the VS Code workspace configuration used for deploying, running, and debugging ROS 2 applications on the Renesas RZ/V2H RDK platform.
Prerequisites
Complete the Cross compilation environment setup section.
Access the Docker container using VS Code and the Dev Containers extension.
Open the
/home/ubuntu/ros2_ws/directory in the Docker container.
Expected Workspace Structure
The following workspace structure is expected after cross-building the ROS 2 application:
ros2_ws/
├── build
├── .clang-format
├── install # Installation directory generated by the ``cross-colcon-build`` command
├── log
├── src
└── .vscode # VS Code workspace configuration files
If your workspace does not contain the .vscode/ directory, you can copy it manually from the $TOOLCHAIN_WS directory.
Install Recommended VS Code Extensions
Install the extra VS Code extensions recommended for ROS 2 development:
Open the Command Palette in VS Code (
Ctrl+Shift+P).Run
Extensions: Show Recommended Extensions.Install the workspace-recommended extensions, including the C/C++ Extension Pack and Task Buttons.
VS Code Configuration Files
VS Code configuration files are located in the .vscode/ directory of your ROS 2 workspace:
.vscode/
├── c_cpp_properties.json # C/C++ extension configuration file
├── deploy.sh # Deployment script to copy files to target
├── launch.json # Debugger launch configuration file
├── run_program.sh # Script to run the program on target
├── settings.json # VS Code workspace settings file
├── start_target_gdbserver.sh # Script to start gdbserver on target
└── tasks.json # Task runner configuration file
By default, the Dockerfile creates these configuration files when the Docker container is built.
Workspace Settings
Open the settings.json file and edit the following variables to match your development environment.
Attention
These variables are essential for the remote debugging and deployment workflow.
Please ensure they are set correctly before using the VS Code tasks.
Variable |
Required |
Description |
|
|
|---|---|---|---|---|
|
No |
Path to the GDB executable on the host machine. |
No |
No |
|
No |
Path to the target device sysroot on the host machine. |
No |
No |
|
Yes |
IP address of the target device. |
Yes |
Yes |
|
No |
GDB server port on the target device. |
No |
No |
|
No |
Username for connecting to the target device. |
No |
No |
|
No |
Password for authenticating to the target device. |
No |
No |
|
No |
ROS 2 workspace path on the target device. |
No |
No |
|
Yes |
ROS 2 package name that contains the executable. |
Yes |
Debug only |
|
Yes |
Name of the executable to start. |
Yes |
Debug only |
|
Yes |
ROS 2 package name that contains the launch file. |
No |
Yes |
|
Yes |
Launch file name used to start the ROS 2 application. |
No |
Yes |
Note
Variables marked as No should be modified only if your development environment differs from the default environment provided by the Docker image.
Variables marked as Yes must be set correctly each time you run the workflow.
Supported VS Code Tasks
The following VS Code tasks are available in the workspace.
These tasks are defined in the tasks.json file and can be executed from the Command Palette (Ctrl+Shift+P) by searching for Run Task and selecting the desired task.
Task |
Description |
|---|---|
ROS2: SSH to Target |
Starts an SSH session to the target board. |
ROS2: Debug Run (GDB) |
Starts remote debugging for a ROS 2 node by using the |
ROS2: Debug Launch (GDB) |
Starts remote debugging for a ROS 2 node in a launch file by using the |
ROS2: Run Package Executable |
Runs a ROS 2 node by using the |
ROS2: Launch Package LaunchFile |
Runs ROS 2 nodes by using the |
ROS2: Deploy to Target |
Deploys the |
ROS2: Build Debug |
Builds the workspace with the |
ROS2: Build Release |
Builds the workspace with the |
ROS2: Clean All |
Cleans all build artifacts, including the |