Home

Awesome

Visual Studio Code Extension for ROS

The Visual Studio Code Extension for ROS1 provides support for Robot Operating System (ROS) development for ROS1 and ROS2 on Windows and Linux.

Features

Commands

You can access the following commands from the Visual Studio Code command pallet, typically accessed by pressing ctrl + shift + p and typing the command name you'd like to use from the table below.

NameDescription
ROS: Create Catkin PackageCreate a catkin package. You can right click on a folder in the explorer to create it in a specific location.
ROS: Create TerminalCreate a terminal with the ROS environment.
ROS: Show StatusOpen a detail view showing ROS core runtime status.
ROS: StartStart ROS1 core or ROS2 Daemon.
ROS: StopTerminate ROS core or ROS2 Daemon.
ROS: Update C++ PropertiesUpdate the C++ IntelliSense configuration to include ROS and your ROS components.
ROS: Update Python PathUpdate the Python IntelliSense configuration to include ROS.
ROS: Preview URDFPreview URDF and Xacro files. The display will update after the root URDF changes are saved.
ROS: Install ROS Dependencies for this workspace using rosdepShortcut for rosdep install --from-paths src --ignore-src -r -y.

Tutorials and Walkthroughs

NameDescription
Attaching to a running ROS NodeLearn how to attach VS Code to a running ROS node
Debugging all ROS Nodes in a launch file Learn how to set up VS Code to debug the nodes in a ROS Launch file
ROSCON 2019 ROS Extension Talk VideoWalkthrough of VS Code from ROSCon 2019
Deep Dive - Episode 0About the VS Code ROS extension @ a Polyhobbyist
Deep Dive - Episode 1Installing on Windows & WSL @ a Polyhobbyist
Deep Dive - Episode 2Installing on Linux @ a Polyhobbyist
Deep Dive - Episode 3General Usage with ROS1 @ a Polyhobbyist
Deep Dive - Episode 4General Usage with ROS2 @ a Polyhobbyist
Deep Dive - Episode 5Debugging Python @ a Polyhobbyist
Deep Dive - Episode 6Debugging C++ @ a Polyhobbyist
Deep Dive - Episode 7Using with SSH @ a Polyhobbyist
Deep Dive - Episode 8Using with with Containers @ a Polyhobbyist

Getting Started

The VS Code ROS extension will attempt to detect and automatically configure the workspace for the appropriate ROS Distro.

The extension will automatically start when you open a catkin or colcon workspace. The build system (e.g. catkin_make or catkin build) will automatically be confirmed from the hidden files associated with each system.

Launch Debugging

The Visual Studio Code extension for ROS supports launch debugging for ROS 1 and ROS 2 nodes, written in Python and C++. The ROS node or nodes to be debugged must be placed in a ROS launch file with the extension .launch for ROS1 or ROS2 or with the extension .py for ROS2.

Automatic creation of a launch.json with ROS Launch support

.vscode/launch.json is a file which defines a debug launch configuration within VS Code.

To create a .vscode/launch.json with ROS debugging support

  1. C++ or Python file is selected, vscode uses the selected file to seed the launch creation UI.
  2. Click the Run and Debug tab on the left sidebar
  3. Select the link to create a .vscode/launch.json file.
  4. VS Code will drop down from the command pallet with a list of options, which includes 'ROS'. Select this option.
  5. In the next dialog, type the name of the ROS package containing a launch file you'd like to debug.
  6. Then find the launch file.

Once this is created, you can use the play button in the title bar, or the "start debugging" accelerator key, or from the command palle (CTRL-SHIFT-P), select Debug: Start Debugging.

NOTE: Other VS Code extensions may interfere with the selection list. If you do not see ROS in the first drop down list, you'll need to create a new file called .vscode/launch.json, then use the manual option described below.

Other Notes:

Manually adding a launch file to an existing launch.json

If you have an existing launch.json file (or if there is an extension conflict as mentioned above), you can manually add a launch configuration by adding a new block like this.

{
    "version": "0.2.0",
    "configurations": [
      {
          "name": "ROS: Launch my file",
          "request": "launch",
          "target": "<full path to your launch.py or launch file>",
          "launch": ["rviz", "gz", "gzserver", "gzclient"],
          "type": "ros"
      }
    ]
}  

Be sure to include the full path to your launch file, including file extension.

ROS Launch Configuration options

The ROS Launch configuration block supports the following configuration:

OptionDescription
nameThe name which will be displayed in the VS Code UI launch configuration
requestlaunch or attach for launching a ROS launch file, or attaching using the attach UI for Pyton or C++
targetthe launch file path
typemust be ros to indicate to VS Code that this is a ROS launch configuration
argumentsArguments passed to roslaunch such as map:=/foo.yaml'
symbolSearchPathA semicolon delimited search path for Windows symbols, including ROS for Windows symbols downloaded from https://ros-win.visualstudio.com/ros-win/_build
additionalSOLibSearchPathA semicolon delimited search path for Linux symbols
sourceFileMapA mapping of Source files from where Symbols expect and the location you have on disk.
launchIf specified, a list of executables to just launch, attaching to everything else. e.g. "launch": ["rviz", "gz", "gzserver", "gzclient"] which prevents attaching a debugger to rviz and gazebo. NOTE: the debugger will ignore file extension: x.py is the same as x.exe.
attachDebuggerIf specified, a list of executables to debug. "attachDebugger": ["my_ros_node"] will only attach to my_ros_node.exe, my_ros_node.py or my_ros_node.

Workspace and Global Settings

The ROS extension supports the following global settings, which can be overridden in the workspace.

Json OptionSetting NameDescription
ros.distroROS installation distro to be sourcedThe Distribution to be sourced. On linux, this cause the extension to look for the ROS setup script in /opt/ros/{distro}/setup.bash. On Windows, c:\opt\ros\{distro}\setup.bat
ros.rosSetupScriptROS workspace setup script. Overrides ros.distro.If specified, this will cause the extension to source this script before generating the launch debugging or ROS terminal environment. This overrides the ros.distro, and can be used to specify user scripts or ROS installs in a different location.
ros.isolateEnvironmentSpecify if the extension should not capture the environment VS Code is running in to pass to child processes.Off by default, This setting will prevent the ROS extension from capturing it's hosting environment in case this would conflict with the ROS environment.

Workspace example:

└── .vscode
    ├── launch.json
    ├── settings.json
    └── tasks.json

settings.json

{
    "ros.distro": "foxy",
    "ros.rosSetupScript": "/opt/ros/foxy/install/setup.bash",
    "ros.isolateEnvironment": "false"
}

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.

Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Data and Telemetry

This extension collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more.

This extension respects the telemetry.enableTelemetry setting, learn more about this option.

Contribution

Contributions are always welcome! Please see our contributing guide for more details!

A big Thank you! to everyone that have helped make this extension better!

ROS Web Tools

This extension leverages ROS Web Tools for URDF Previewing.

Russell Toris, Julius Kammerl, David Lu, Jihoon Lee, Odest Chadwicke Jenkins, Sarah Osentoski, Mitchell Wills, and Sonia Chernova. Robot Web Tools: Efficient Messaging for Cloud Robotics. In Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 2015

<!-- link to files --> <!-- relative links in Visual Studio Marketplace page lead to 404 error, need to use absolute link --> <!-- feature documentation --> <!-- media --> <!-- link to external sites -->

Footnotes

  1. ROS is a trademark of Open Robotics.