ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes it is possible, however the tricky part is selecting the correct process when you are attaching your debugger.

As an example, I can show you how I set a breakpoint in the talker node of the composition demo.

  1. Follow the instructions here. You should simply add the following to your launch.json

    { "configurations": [ { "name": "ROS: Attach", "type": "ros", "request": "attach" } ] }

  2. Launch your component container, in this case ros2 launch composition ./composition_demo.launch.py

  3. Launch the ROS: Attach debug target in vscode. Pick c++; when you get the drop down menu to choose a process, look for the one running the component container, not the launch file. As illustrated in the screenshot below

debug component container

  1. Place a breakpoint somewhere to stop the program

image description

Yes it is possible, however the tricky part is selecting the correct process when you are attaching your debugger.

As an example, I can show you how I set a breakpoint in the talker node of the composition demo.

  1. Follow the instructions here. You should simply add the following to your launch.json

    { "configurations": [ { "name": "ROS: Attach", "type": "ros", "request": "attach" } ] }

  2. Launch your component container, in this case ros2 launch composition ./composition_demo.launch.py

  3. Launch the ROS: Attach debug target in vscode. Pick c++; when you get the drop down menu to choose a process, look for the one running the component container, not the launch file. As illustrated in the screenshot belowbelow. You might get a prompt asking for admin priveleges in the console during this process.

debug component container

  1. Place

    Finally, place a breakpoint somewhere to stop the program

image description