1、首先需要在VSCode中下载ROS插件
2、编写Tasks.json文件
{
"version": "2.0.0",
"tasks":
[
{
"type": "shell",
"command": "catkin_make -DCMAKE_BUILD_TYPE=Debug",
"problemMatcher": [
"$catkin-gcc"
],
"group": {
"kind": "test",
"isDefault": true
},
"label": "catkin_make: build"
},
{
"type": "shell",
"command": "catkin_make clean",
"problemMatcher": [
"$catkin-gcc"
],
"group": "build",
"label": "catkin_make: clean"
},
{
"type": "shell",
"command":"catkin_make -DCMAKE_TYPE=Release",
"problemMatcher": [
"$catkin-gcc"
],
"group": "build",
"label": "catkin_make: release"
}
]
}
3、编写launch.json文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "catkin_make: build",
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/devel/lib/vins_estimator/vins_estimator",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
4、启动gdb调试
以上为针对单个ROS节点的调试方法。