Ask Your Question

Include path for custom interface files in ROS2

asked 2021-02-04 02:23:44 -0600

NotMyRealName gravatar image

Hi there,

I am currently using ROS2 Dashing for a small project. I have a workspace with two packages. In the one package I only have custom interface files (.msg). In the second package I have two nodes, a simple publisher and a subscriber. Those exchange the custom message defined in the other package. When compiling the packages with colcon there are no errors, but VS-Code can not find the header-file for the custom message. Because of that I always get include errors and intellisense does not work, which is very inconvenient. As far as I know, the headerfiles are generated dynamically so I have no idea to include those with VS-Code. Is there a way to make VS-Code include these custom messages?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2021-11-16 08:09:57 -0600

morten gravatar image

updated 2021-11-17 02:10:12 -0600

Be sure you've installed the ros extension for one. Aside from this, if you open the ros_ws folder (i.e. the one which holds the install, build, and src folders) then it should configure itself automatically.

If it doesn't, open the .vscode/c_cpp_properties.json file and check that it contains the correct includePath (the most important for this being ${workspaceFolder}/** and /opt/ros/foxy/include/**). Mine for example:

  "configurations": [
      "browse": {
        "databaseFilename": "",
        "limitSymbolsToIncludedHeaders": true
      "includePath": [
      "name": "ROS"
  "version": 4

Again, for this to work vscode has to open in your ros_ws directory, such that it can walk through the install and src folders. Otherwise you can add them by manually backstepping in the include.

I've inspired my setup a bit by, she provides a docker for a vscode setup. I've taken some inspiration here regarding figuring out some of the slightly more obscure settings.

edit flag offensive delete link more

answered 2021-11-16 07:58:35 -0600

updated 2021-11-16 07:59:48 -0600

Hello there,

Have you tried configuring your compilers properties on VSCode (the c_cpp_properties.json file for example) by editing the IncludePath variable and adding the include file of your interfaces package (your_ros2_worspace_dir/install/your_interface_package_dir/include).

This should tell VSCode where your header files are.

edit flag offensive delete link more

answered 2021-04-11 14:35:40 -0600

cap10 gravatar image

Hey there, did you ever figure out this issue? I'm also seeing this issue.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-02-04 02:23:44 -0600

Seen: 137 times

Last updated: Nov 17 '21