0. 首先需要安装ROS插件(Microsoft),已经建立建立ros项目工程, 在功能包CMakeLists.txt目录下打开终端, 执行: code . 打开ros项目
1. 点击F5, 启动debug(Start Debugging), 弹出对话框, 点击打开launch.json.
2. 将configurations里面的东西删掉如下:
{
// 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": [
]
}
3. 然后点击右下角的Add Configuration, 选择: ROS: Launch, 如下:
{
"name": "ROS: Launch",
"type": "ros",
"request": "launch",
"target": "absolute path to launch file"
}
4. 将launch文件的绝对路径加到target里面即可.
5. 注意在CMakeLists.txt里面添加:
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
6. 然后catkin_make编译项目
7. 最后点击F5即可设置断点debug了.
详情参考: vscode-ros/debug-support.md at master · ms-iot/vscode-ros · GitHub