标签:ROS catkin launch vscode json shell ros 调试
vscode调试ros工程
通过launch文件启动,并且加断点调试。
1.插件安装
- ROS
- c++ Intellisense 和c/c++
- Txt Syntax
- Msg Language Sopport
2.导入工作空间
用vscode打开相应的工程
3.环境配置
需要配置三个文件
- task.json配置,用于ctrl+shift+b编译
{
// 有关 tasks.json 格式的文档,请参见
// https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"label": "catkin_make:debug", //代表提示的描述性信息
"type": "shell", //可以选择shell或者process,如果是shell代码是在shell里面运行一个命令,如果是process代表作为一个进程来运行
"command": "catkin_make",//这个是我们需要运行的命令
"args": ["-DCMAKE_BUILD_TYPE=RelWithDebInfo","-j8"],//如果需要在命令后面加一些后缀,可以写在这里,比如-DCATKIN_WHITELIST_PACKAGES=“pac1;pac2”
"group": {"kind":"build","isDefault":true},
"presentation": {
"reveal": "always"//可选always或者silence,代表是否输出信息
},
"problemMatcher": "$msCompile"
}
]
}
- c_cpp_properties.json配置
{
"configurations": [
{
"name": "ROS",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/melodic/include/**",
"/usr/include/**",
"/home/gao/.../include/**",
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
- 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",
"request": "launch",
"target": "/home/gao/catkin_hy_ws/../launch/test.launch",
"type": "ros"
}
]
}
关于代码智能提示:
- 执行一下命令,在build中生成
compile_commands.json
catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes
- 添加
c_cpp_properties.json
文件中:
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
4.开始调试
添加环境变量:
source devel/setup.bash
vscode右侧工具栏Run and Debug,ROS:Launch,开始调试
有时候会报错,可以重启ROS插件试试。
标签:ROS,catkin,launch,vscode,json,shell,ros,调试 来源: https://www.cnblogs.com/gaowensheng/p/16155398.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。