Updating the VS Code extension for ROS to 0.6.0

We are excited to introduce another update for the VS Code extension for ROS! This update enables ROS2 runtime monitor and adds support for ROS2 command line tools (ros2 run and ros2 launch)! This is how it looks!

Meantime, this update also enables a bootstrapped debugging experience for debugging a ROS (Python or C++) node by attaching to the process (works on both Windows and Ubuntu). See it in action!

To get started, create a ros-type debug configuration with an attach request:

Attaching to a ROS Python node:

Attaching to a ROS C++ node:

Note:

  1. Debugging functionality provided by vscode-ros has dependencies on VS Code’s C++ and Python extensions, and those have dependencies on the version of VS Code. To ensure everything works as expected, please make sure everything is up-to-date.
  2. To debug a C++ executable, please make sure the binary is built with debug symbols.
  3. To use VS Code’s C++ extension with MSVC on Windows, please make sure the VS Code instance is launched from a Visual Studio command prompt.

For feature requests and bug reports, please post in the ms-iot/vscode-ros repository. Let’s keep this project evolving just like ROS itself =)

For more details about this project and ROS on Windows, please check out http://aka.ms/ros.

17 Likes

@james

Nice work, we will give it a shot!!!

thanks,
tomoya

2 Likes

Is it in the plans (or already supported) to make this extension work for the case in which VSCode is on Windows but ROS is running inside WSL?

We do have aspirations to enable this. I’ve created a project on the vscode github to call this out: https://github.com/ms-iot/vscode-ros/projects/7. We haven’t spec’d it or tasked it out yet.

2 Likes

@james thanks for this. Do you guys happen to have any documentation on how to setup the ROS 2 workspace? I have installed ROS, CMake, C/C++ and Colcon Tasks plugins but still can not get the include paths of the dependent packages to be recognized correctly.

Any pointers to how to do autocompletion, declaration/definition jumps and building of ROS 2 packages would be appreciated.

D.

I‘m interested in this as well…

Is your vs code instance running on the same machine where you installed ros2?

The documentation of the plugin says it detects ROS(2) if you successfully build your workspace at least once from vs code. That’s how I got it working with ros1 so far.

But I‘m unsure how to setup colcon build correctly in vs code… probably that is missing for you aswell. Ros1 was a bare cmake command. Now we have colcon that has cmake integrated, afaik…

@flo @james
I am unable to build ws for ROS2 from inside vscode. Apparently, none include file (related to ros and in other packages) could be found. In c_cpp_properties.json in .vscode director for the workspace, only include directories of current workspace are listed.
I am started the VS Code from the terminal, inside the workspace directory. Automatic detection of workspace has failed.
Please list set of steps you followed.
Thank you

Independent of this ROS-specific extension when using the C/C++ extension you can generate a compile_commands.json file for your workspace and reference that in the VS Code config.

You need:

  • Build your workspace with --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    (I do this with a custom mixin file referenced in the defaults.yaml in order to always use it.)
  • Have colcon-cmake version 0.2.20 or higher (since colcon/colcon-cmake#69)
  • Configure the path to the workspace-level compile_commands.json, e.g. when opening the src directory with VS Code you want to set the config value C_Cpp.default.compileCommands to ${workspaceFolder}/../build/compile_commands.json
6 Likes

Thank you very much for this useful tool. I was looking for a long time a tool capable to debug a project in Ros2 based on C++ and python.

Bump. Good to hear there’s ROS2 support, but how do I get it? How is the ROS2 runtime monitor launched? I still don’t understand how to build a ROS2 workspace through the IDE. If I just use a shell task, it fails because Dashing isn’t sourced

1 Like