First Commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
[[ROS2]] is a bit tedious to debug, because it is inherently asynchronous and multi threaded.
|
||||
|
||||
A good way is to use VSCode for example like this:
|
||||
https://gist.github.com/JADC362/a4425c2d05cdaadaaa71b697b674425f
|
||||
|
||||
As always the nav2 library is a good place for resources: [get backtrace explanation](https://navigation.ros.org/tutorials/docs/get_backtrace.html).
|
||||
## Requirements
|
||||
In order to run this we need to install gdbserver: `sudo apt install gdbserver`
|
||||
## Launch Files
|
||||
In the launch file, when adding a Node, add a `prefix="gdbserver localhost:3000"`:
|
||||
```python
|
||||
Node(
|
||||
package='nav3_controller',
|
||||
executable='controller_server',
|
||||
output='screen',
|
||||
respawn=use_respawn,
|
||||
respawn_delay=2.0,
|
||||
parameters=[configured_params],
|
||||
prefix='gdbserver localhost:3000',
|
||||
arguments=['--ros-args', '--log-level', log_level],
|
||||
remappings=remappings + [('offboard_cmd', 'offboard_velocity_cmd')]
|
||||
)
|
||||
```
|
||||
|
||||
This will create gdb as a server. Now we need to configure VSCode to attach to this debug session (as explained [here](https://answers.ros.org/question/267261/how-can-i-run-ros2-nodes-in-a-debugger-eg-gdb/)) add a new launch configuration like this:
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C++ Debugger",
|
||||
"request": "launch",
|
||||
"type": "cppdbg",
|
||||
"miDebuggerServerAddress": "localhost:3000",
|
||||
"cwd": "/",
|
||||
"program": "[build-path-executable]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user