ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

[SOLVED] ROS2 + VSCode IntelliSense + multiple ROS2 packages

asked 2023-01-17 03:30:46 -0500

LastStarDust gravatar image

updated 2023-02-01 02:04:06 -0500

Hello, I am trying to set up IntelliSense static analysis for ROS2 using VSCode.

To set up VSCode I followed this excellent guide from Allison Thackston.

SYMPTOMS

If I have a single package, everything works fine. But if I have two packages, one for interfaces and one for business logic, the VSCode static analysis tool (IntelliSense) gives me many errors (more about it later).

Please notice that when using the ROS2 command line interface everything compiles fine. I can run and debug the core package correctly. However, in the editor, IntelliSense reports many errors and I cannot get IntelliSense to do proper autocompletion, jump-to-definition, etc…

This is the structure of the project with two packages (interface and core)

test |-> src
    |-> interface
        |-> CMakeLists.txt
        |-> package.xml
        |-> msg
            |-> Interface1.msg
            |-> Interface2.msg
            ...
    |-> core
        |-> CMakeLists.txt
        |-> package.xml
        |-> src
            |-> node1.cpp
            |-> node2.cpp
            ...

where the core package depends on the interface package.

DIAGNOSIS

The root of the problem is this line in test/core/CMakeLists.txt:

find_package(interface REQUIRED)

because the “CMake Tools” extension cannot find the interface package.

INFO

I created the CMakeLists.txt file as explained in the ROS2 documentation here.

This is a part of my .vscode/settings.json:

{
    "cmake.sourceDirectory": [
        "${workspaceFolder}/src/interface",
        "${workspaceFolder}/src/core"
    ],
    "cmake.buildDirectory": "${sourceDirectory}/build/${buildType}",
}
  • ROS2 version: Humble
  • VSCode version: 1.75.3
  • CMake Tools version: v1.13.38 (Pre-Release)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-02-01 02:03:41 -0500

LastStarDust gravatar image

It seems that the problem fixed itself after rebooting the machine. If you experience something similar, try to close and reopen or reboot.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-01-17 03:28:03 -0500

Seen: 652 times

Last updated: Feb 01 '23