Skip to content

ROS2 C++ VSCode setup

ROS / ros cpp

Config VScode for ROS2 cpp package using


Configuration

The c_cpp_properties.json file configures IntelliSense, code completion, and error checking for C/C++ projects in VS Code.

c_cpp_properties.json for gcc for gcc compiler
{
    "configurations": [
        {
            "name": "ros",
            "includePath": [
                "/opt/ros/jazzy/include/**",
                "${workspaceFolder}/src/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}
  • includePath: Directories for header file lookup. Includes ROS headers and your workspace’s src folder.
  • defines: Preprocessor macros (empty in this config).
  • cStandard and cppStandard: C and C++ language standards (c17 and c++17). ros jazzy build with this standard
  • intelliSenseMode: IntelliSense engine mode (linux-gcc-x64 for Linux GCC).

Build

Tasks

.vscode/tasks.json

Tests

1
2
3
4
colcon test --event-handlers console_direct+

# specific package
colcon test --packages-select loc_application  --event-handlers console_direct+