Attaching a node to GDB while launching ROS

In many cases, we might get a launch file that takes care of starting the node, as you can see in the following example:

<launch> 
  <node pkg="chapter3_tutorials" type="example1" name="example1"/> 
</launch> 

In order to attach it to gdb, we must add launch-prefix="xterm -e gdb --args" as follows:

<launch> 
  <node pkg="chapter3_tutorials" type="example1" name="example1" 
  launch-prefix="xterm -e gdb --args"/> 
</launch> 

Similarly, you can also add output="screen" to make the node output appear on the terminal. With this launch prefix, a new xterm terminal will be created with the node attached to gdb. Set breakpoints if needed, and then press the C or R key to run the node and debug it. One of the common ...

Get ROS Programming: Building Powerful Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.