Ubuntu18.04+vscode调试SLAM系统
0.引言
主要为参考博客进行实现的过程记录。简单工程的调试可以参考这篇博客。SLAM系统的主要特点,多线程,依赖库多。
1.VSCODE插件
- CMake Tools 、 CMake 、 C\C++ 、 C++ Intellisense
2.DeBug配置
2.1.VSCODE环境配置
将SLAM系统在VSCODE中打开,crtl+shift+p 打开vscode控制台输入C/C++: Edit configurations(JSON) ,将自动生成一个c_cpp_properties.json文件,可以在该文件中编写环境参数、依赖项等。
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
2.2.自定义编译(编译设置)
参考博客中介绍了两种编译方式选择,本文还是选择自定义编译。
crtl+shift+p 打开vscode控制台输入Tasks: Configure Task ,再选择Create tasks.json file from templates,选择Others模板,将自动生成一个tasks.json文件。
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "./build.sh"
}
]
}
如果是down的别人的代码调试,可能需要将两个地方的Realease模式改为Debug模式:
2.3.调试设置(运行设置)
点击左侧边栏的Debug图标或者Ctrl+Shirft+D,然后点击create a launch.json file,选择C++(GDB/LLDB)将自动生成launch.json文件。可以在该文件中编写参数调整调试过程中的参数,如main函数参数输入。-
- launch.json,以运行cubemap为例。
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${cwd}/bin/cubemap_lafida",
"args": ["${cwd}/Vocabulary/ORBvoc.txt",
"${cwd}/Config/lafida_cam0_params.yaml",
"${cwd}/../../dataset/Lafida/outdoor_static2/imgs/cam0",
"${cwd}/../../dataset/Lafida/outdoor_static2/images_and_timestamps.txt",
"${cwd}/Masks/gray_lafida_cubemap_mask_650.png",
"${cwd}/bin/trajs/lafida_outdoor_static2.txt",
"${cwd}/bin/trajs/lafida_outdoor_static2_perf.txt"],
"stopAtEntry": false,
"preLaunchTask": "build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3.实践
配置完后,'Ctrl+Shift+B’编译,完成后就打断点开始调试。目前配置没出现什么问题,如图:
|