ROS2 CPP 功能包使用 VScode/clion 进行 debug
开启 debug
在 CMakeLists.txt 添加 target 之前中添加
1
| set(CMAKE_BUILD_TYPE Debug)
|
或者编译选项
1
| -DCMAKE_BUILD_TYPE=Debug
|
编译
1
| colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
先 source install/setup.bash
后打开 IDE 进行调试
vscode 配置
task.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| { "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/install/${input:package_name}/lib/${input:package_name}/${input:package_executable}", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, ] } ], "inputs": [ { "id": "package_name", "type": "promptString", "description": "ros2 package name", "default": "cpp_primer_pubsub" }, { "id": "package_executable", "type": "promptString", "description": "ros2 package executable", "default": "talker" } ] }
|
Clion 配置
参考
https://blog.csdn.net/weixin_41312228/article/details/129847328
https://gist.github.com/JADC362/a4425c2d05cdaadaaa71b697b674425f
https://zhuanlan.zhihu.com/p/364972107