How to debug ROS package
Hi!
I'm new to C++ and ROS.
Recently, I want to add some breakpoints and debug these ROS libraries step by step to learn how these member functions are called and run.
However, I found that all the functions of these ROS libraries are linked to .h
files and I cannot see what is inside these functions.
Are there any available ways?
Thanks in advance!
Asked by JohnDoe on 2023-07-13 21:02:44 UTC
Comments
This is a generic c++ question about debugging not about ROS or robotics. I recommend that you read up on gdb and search for some tutorials on c++ debugging with gdb. Header based implementations are still debuggable.
Asked by tfoote on 2023-07-14 15:01:29 UTC
Hi! @tfoote As far as I know, installing via
sudo apt-get install
only installs some necessary binaries files, and hence I can only retrieve the header file. In contrast,source install
can keep somecpp
files and I can add breakpoints or modify these ROS packages. Am I right?Asked by JohnDoe on 2023-07-14 22:28:29 UTC
You're right about the default debs not installing the source files by default. But you're talking about linking to headers and the debug symbols are what you want mostly. I would suggest that you learn how to use a debugger on a much smaller program before trying to jump right into a full ROS system. The use of debuggers is a skill that you will want to develop incrementally. There's a lot of documentation of that elsewhere that's not ROS specific. You'll be much better off learning it there. And then in that context ROS is just like any other c++ library when you know how to setup and use your choice of debugger.
Asked by tfoote on 2023-07-14 23:18:31 UTC
Thanks for your instruction!
Asked by JohnDoe on 2023-07-15 00:30:18 UTC