The goal for this project is to demonstrate the debugging ROS node implementation using VSCode, but of course, the underlying compiler is g++ and debugger is C++ debugger, the VSCode is IDE invoking these underlying tools. My blog post contains a bit more info.
This project contains an example project structure followed by the catkin workspace creation and it contains implementation for talker and listener.
- remove the "devel" and "build" folders, rebuild using "catkin_make -DCMAKE_BUILD_TYPE=Debug"
- run "talker" as rosnode
- find out the process id of the talker process
- modify the ".vscode/launch.json", by replacing "25159" with the id obtained from previous step
- set some break points in the "src/talker.cpp", start debugger from vscode and be happy
When you use catkin build
instead of catkin make
you can specify the build type by using the catkin config -DCMAKE_BUILD_TYPE=Debug
command.
When you want to debug a ROS package that was built inside a singularity container, you have to make sure that the working directory while executing the build
command and the working directory you opened inside vscode to debug are equal. This is because, in a singularity image, folders on the home
and root
folder can be accessed both by their absolute and relative paths. This can lead to path inconsistencies between the build package and the package scripts you are debugging.