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 uses you will find of this simple workflow is to obtain a backtrace (bt) if the node crashes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.9.237