Unlocking Enhanced Development Experience: Creating Custom Configurations for VS Code Extensions

In the previous blog, I shared my experience of using VS Code Extensions for ROS development. I also discussed some missing functionalities in the VS Code ROS extension, especially the lack of rosbag interface. Well, I dig deeper and figured out the process of creating custom configurations to perform various tasks, including playing rosbags.

Foremost, you need to ensure that you have installed the ROS Extension for VS Code. After you have installed the ROS extension, and restarted your VS Code, you will see a .vscode folder in your ROS workspace. This folder primarily consists of the following files: article image 1

Now that you have understood the file system, the following Table of Content provides you with a list of custom configurations. You can copy-paste the configuration inside the specified tasks.json or launch.json files.

For ease of understanding, I am going to demonstrate each configuration using an example of a workspace. I am also providing a GitHub repository containing the example for you to clone and try out various custom functionalities.




In ROS 2, you can create packages using two different build types, i.e., ament_cmake and ament_python. You need to specify the build type and additional dependencies while creating a package. After your package is created, you need to build and source the workspace. Instead of typing a bunch of commands one after another in the terminal, you can save yourself some time by copy-pasting the below configurations inside the tasks key, separated by commas in the tasks.json file.

Change the <your_active_ros2_distro> to your active ROS 2 distro while creating your tasks.
Now each time, you want to create a new package, change the <your_new_package_name> to the name of the new package you want to create.
Also, you can add more dependencies like std_msgs after --dependencies , if required.
To run the tasks for package creation, use (CTRL + Shift + P), select Tasks: Run Task and then select the task from the labels. This will create a new package inside your src folder and then build and source the workspace. article image 1


One of the major shortcomings of the VS Code extension for ROS is that it does not provide any interface for rosbag. A seasoned ROS developer knows how often they need to play rosbag to tune their algorithms.
But there is a way out. You can create a task by copy-pasting the below configuration inside the tasks key, in your tasks.json file to play rosbag. Just set the path of the bag file at <set-bag-file-path>.

Change the <your_active_ros2_distro> to your active ROS 2 distro while creating your tasks.
To run the task for playing the rosbag, use (CTRL + Shift + P), select Tasks: Run Task and then select the ros-bag-play task. This will start playing the rosbag. article image 1


While building a ROS 2 workspace using colcon build, you might be using a combination of arguments. You can add the most commonly used colcon build commands as configurations inside the tasks key in your tasks.json file and execute the build using VS Code.

To run the different colcon build tasks, use (CTRL + Shift + P), select Tasks: Run Task and then select the build task from the available options. article image 1


Debugging the code you have written is one of the toughest places to be, especially when there is a segmentation fault. While the initial stage of debugging will begin with using ROS Loggers and RViz, using debuggers like GDB for C++ and PDB for Python is essential during code crashes or while dealing with an unknown error.
By using a debugger, you can control the flow of execution line by line and have a peek at variables of interest.


I can’t stress enough on the importance of unit testing for a stable software release process and code maintenance.
ROS 2 provides gtest for testing C++ nodes and pytest for testing Python nodes. colcon provides macros for test-aware compilation and verbs dedicated to testing the project in its entirety. You can execute colcon test to run your unit tests. The test files are generally stored inside a tests folder.
To execute the unit tests for a particular package using colcon test command, give the test folder name and the name of the package at <specify_package_name_here> after --packages-select argument.

Testing with pytest framework, you can specify the name of the test function at <specify_name_of_ specific_test_function> you created with the colcon test command to test for that specific test function after --pytest-args argument.

To run the different colcon test tasks, use (CTRL + Shift + P), select Tasks: Run Task and then select the test task from the available options. article image 1

Using a debugger with ROS 2 launch_test using the ROS Extension for VS Code is an active problem and has an open issue at the official GitHub repository.


By leveraging the power of VS Code and ROS extension, developers can streamline their coding process, improve productivity, and gain more control over their ROS projects. Whether it's setting up a ROS workspace, configuring build tasks, or utilizing ROS-specific features, understanding these configurations opens up new possibilities for efficient and effective ROS development.
As mentioned previously, you can find the entire configurations from my GitHub repository.
If you want to create a custom configuration, feel free to open a pull request in the GitHub repository. You can also create a Feature Request if you want me to implement your ideas.
Embracing these configurations will undoubtedly empower ROS developers to unleash their full potential and embark on successful robotics projects using the VS Code ecosystem.

If you liked the article, please buy me a ☕️ coffee