ros-controls / ros2_controllers

Generic robotic controllers to accompany ros2_control
https://control.ros.org
Apache License 2.0
321 stars 290 forks source link

Using GDB with ROS2 Controllers #1179

Open aadi-mishra opened 2 weeks ago

aadi-mishra commented 2 weeks ago

Hi All!

I am working on developing custom controllers using Controller Interface and am currently looking for a way to attach gdb with the ros2 controllers in order to be able to debug. I have used gdb before with ROS2 nodes, However, in the case of ros2 controllers, the controllers are created as plugin and are initialized through spawner. Hence, I am not really sure how to achieve this. Any suggestions is appreciate.

@bmagyar @christophfroehlich

Thanks!

firesurfer commented 6 days ago

I always used it just like with all nodes started via ros2 launch:

In the entry where you create the Node for the controller manager just add:

prefix=['xterm -e gdb -ex run --args']

and make sure you have xterm installed.

The controllers are loaded as plugins into the controller manager process.

aadi-mishra commented 5 days ago

Hi @firesurfer ! You are right that this works for all other ROS2 nodes but this does not work with ROS2 Controller plugins as a spawner node is used to load them from my understanding and spawner is written in python.

firesurfer commented 5 days ago

Yes but the spawner just tells the node in which the controller manager runs what to load. So you want to attach the debugger (in your preferred way) to the controller manager.