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:
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.
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.
@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.
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.)
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
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