当前位置:网站首页>vscode-打断点debug使用roslaunch启动的多节点ROS程序
vscode-打断点debug使用roslaunch启动的多节点ROS程序
2023-01-19 15:35:10【weixin_40826634】
1、生成compile_commands.json文件,解决部分头文件找不到问题
执行编译命令
catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
即可在ROS工作空间的build文件夹下面生成compile_commands.json,然后在c_cpp_properties.json文件添加
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
即可找到全部头文件,下面为添加后的c_cpp_properties.json文件
{
"configurations": [
{
"browse": {
"databaseFilename": "",
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"/home/mdj/catkin_ws/tiejian_lidar_perceive/devel/include/**",
"/opt/ros/melodic/include/**",
"/home/mdj/catkin_ws/tiejian_lidar_perceive/src/ivcommon/include/**",
"/home/mdj/catkin_ws/tiejian_lidar_perceive/src/lidar_object_detector/include/**",
"/home/mdj/catkin_ws/tiejian_lidar_perceive/src/points_preprocess/include/**",
"/usr/include/**",
"/home/mdj/catkin_ws/tiejian_lidar_perceive/src/sensor_driver/src/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++14",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
至此,可以实现代码的自动跳转了。
2、生成并修改task.json文件,作用是在每次debug之前预编译部分程序
按Ctrl+shift+P进入命令模式,键入tasks: Configure Task,选择 cmake:build 选项生成task.json文件。
修改完成后的task.json文件如下所示
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "catkin_make", //代表提示的描述性信息
"type": "shell", //可以选择shell或者process,如果是shell代码是在shell里面运行一个命令,如果是process代表作为一个进程来运行
"command": "catkin_make",//这个是我们需要运行的命令
"args": [],//如果需要在命令后面加一些后缀,可以写在这里,比如-DCATKIN_WHITELIST_PACKAGES=“pac1;pac2”
"group": {
"kind":"build","isDefault":true},
"presentation": {
"reveal": "always"//可选always或者silence,代表是否输出信息
},
"problemMatcher": "$msCompile"
}
]
}
其中,这行设置 “group”: {“kind”:“build”,“isDefault”:true},代表将我们定义的这个task添加到build组里面,这样就可以中Ctrl+Shift+B快捷键来找到编译命令,命令名称就是在label里面定义的,如果"isDefault":true那么就代表直接执行command,如果为false还需要在build下拉里面选一下,我们这里就是label名字:catkin_make
3、生成并修改launch.json文件,设置launch启动文件绝对路径
修改后的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": [
{
"name": "ROS: Launch", // 配置名称,将会在调试配置下拉列表中显示
"target": "/home/mdj/catkin_ws/tiejian_lidar_perceive/tiejian.launch",
"type": "ros", // 调试器类型 该值自动生成
"request": "launch" // 调试方式,还可以选择attach
}
]
}
4、待调试节点中CMakeLists.txt文件设置
待调试的节点程序还需要在CMakeLists.txt中添加
SET(CMAKE_BUILD_TYPE Debug)
之后继续执行
catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
5、打断点debug操作步骤
先打开一个roscore,然后在节点程序中需要的位置打断点,最后点击如图所示左侧ROS::Launch即可开始debug
参考
https://blog.csdn.net/ABC_ORANGE/article/details/102665792
https://blog.csdn.net/Kalenee/article/details/103828448
【ROS】 在VScode中 ROS Debug 配置方法非常详细版
边栏推荐
猜你喜欢
随机推荐
- 负电压是怎么产生的原理分析
- 迟滞比较器Hysteresiswindow和comparator(窗口比较器)原理
- 残留物与电子PCBA 的可靠性和三防漆涂敷前后可能导致电路板出现故障的变量
- 京东探索研究院 | 2023年十大科技趋势
- A variety of Chinese dialect voice landing applications, Microsoft's intelligent voice unlocks more interactive scenarios
- Is Alipay's annuity insurance worth buying?is it safe?
- Which is the top ten insurance for annuity insurance? Is it safe?
- Use MeterSphere beanshell global assertion reference JSONObject solution
- CNN+LSTM+Attention实现时间序列预测(PyTorch版)
- WebView加载heml代码简单应用
- CTA-Sensitive Behavior-AppOps Solution
- Beyond TensorFlow?Yann LeCun: "Why? PyTorch. That's why."
- 蜻蜓安全工作台程序编排简要说明
- WSL2安装systemd方法
- 安信证券开户安全吗?佣金是万几?
- 大智慧在上面开户安全吗?谁能告诉我一下
- 从合并石子学区间DP
- Golang的基本数据类型-基本使用
- 线扫相机DALSA--卡间同步
- 海康visionmaster-图像Bitmap和CmvdImage互转的方法
- 【threejs】根据点绘制直线
- 【threejs】threesjs 初学场景构建
- 第十三章 UML建模
- 为什么很多年轻人,都被 “伪自律” 给拖垮了?
- 小黑年前实习倒数第二天,又到了开心的疯狂星期四的leetcode之旅:剑指 Offer 27. 二叉树的镜像&&剑指 Offer 28. 对称的二叉树
- Servlet —— Servlet API
- 使用nvm管理node版本(window版)
- typescript学习笔记(三)
- vtkPolyData数据的空间变换
- 深入透析 类的 访问修饰符 public、 protected 、private
- C语言基础 — ( 函数——模块化设计)
- Wider Face+YOLOV8人脸检测
- Wider Face+YOLOV7人脸检测
- 【Android安全】Google Hardware-backed Keystore | SafetyNet | 远程证明Remote Attestation
- [转]SteamVR 1.x️一、实现手与物体交互——基于[CameraRig]
- PHP MySQL Where 子句
- PHP MySQL Order By 关键词
- 我理解的卓越工程
- 各种huggingface分词器对比
- PHP MySQL Order By keywords




