系统环境
- ros --version == melodic
- ubuntu --version == 18.04LTS
- 安装vscode:ubuntu18.04已经可以再ubuntu software中找到并进行安装
- 在VSCode的插件处安装C/C++,python,ROS插件。其中ROS插件的作用是在识别到catkin_make等命令创建的ROS工作空间后会向工作空间中添加:launch.json、tasks.json,setting.json等配置文件。
- 如果没有生成这些文件请见此处手动进行添加
- 对tasks.json文件进行配置,这里参考的是一位up主的笔记
{
"version": "2.0.0",
"tasks": [
{
"label": "catkin_make:debug",
"type": "shell",
"command": "catkin_make",
"args": [],
"group": {"kind":"build","isDefault":true},
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
}
]
}
- 接下来是修改launch.json文件
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/devel/lib/beginner_tutorial/talker",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "catkin_make: build",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
关键在于program中的${workspaceFolder}/devel/lib/beginner_tutorial/talker,假如你需要调试不同的节点请修改此处的program值为该节点的可执行文件所在路径。
在调试的时候需要先在terminal中启动roscore再选择debug中左上角的绿色三角启动按钮 。
|