网站开发可以学吗,如何建淘宝客网站,怎么做类似返利网的网站,丹东网站优化目录 使用VS Code调试Docker Container中的Autoware.ai代码第一种方法 -- 在VS Code中进行DebugStep1Step2Step3Step4c_cpp_properties.jsonlaunch.jsonsettings.jsontask.json Step5Step6Step7参考链接 第二种方法 -- cmake重新编译cmake使用方法#xff08;简介#xff09;… 目录 使用VS Code调试Docker Container中的Autoware.ai代码第一种方法 -- 在VS Code中进行DebugStep1Step2Step3Step4c_cpp_properties.jsonlaunch.jsonsettings.jsontask.json Step5Step6Step7参考链接 第二种方法 -- cmake重新编译cmake使用方法简介cmake常用目录结构buildbinlibsrc 教程 Autoware编译结构查看Autoware的编译类型 修改CMakeList.txt文件参考链接OpenPlanner项目独立的github链接colcon使用文档build Autoware from sourceHow to check if program was compiled with debug symbols? [duplicate]VSCode debug cpp ROS node - compile package with debug modeC/C: How do you set GDB debug flag (-g) with cmake? 使用VS Code调试Docker Container中的Autoware.ai代码
第一种方法 – 在VS Code中进行Debug
在用这个方法时踩到了一些坑一度搞得我很无奈。后面解决的方法也有点莫名其妙。下面详细叙述下。
Step1
首先创建docker container这里我是用命令行创建的。然后运行autoware提供的/docker/generic/下的run.sh即会自动创建docker container并进入到container中。此时docker --version为Docker version 20.10.18, build b40c2f6. 更新vs code到最新版本安装docker 插件
Step2
点击左侧任务栏的docker按钮 可以看到显示所有的container右击选择Attach Visual Studio Code 会弹出一个新的窗口可以在左侧任务栏看到DEV CONTAINERS已经连接如下图所示。 这里曾经遇到两个坑 第一个是在点击Attach Visual Studio Code后VS Code出现弹框报错内容为“Remote - Containers Docker version 17.12.0 or later required.” 但其实Docker的版本已经是20往上了搜到了这个解决办法但是貌似没啥用。。 第二个坑是把后面的都配置好之后点击Debug按钮调试cpp文件调用的竟然是python的debugger然后发现是在文档里面调试过python代码不知道为啥默认就用了那个选择gdb也不好使。把之前的目录删了以后发现可以了。。。 而且同时再点Attach Visual Studio Code就可以用了。。。所以不知道是不是因为这个影响了第一个问题。 总而言之解决的莫名其妙。 按理说VS Code这边的Docker插件都能检测到container里面的内容所有代码均可查看而且执行Attach to Shell命令也可以正常进入到docker container里面的命令行应该说vscode是连接到了container了不知道为啥会出现第一个问题。 总之解决了。
Step3
点击File按钮打开/home/autoware/Autoware/src/autoware目录作为工作目录。
Step4
在/home/autoware/Autoware/src/autoware/目录下创建文件夹.vscode 分别创建四个文件文件名和内容分别如下
c_cpp_properties.json
{configurations: [{browse: {databaseFilename: ,limitSymbolsToIncludedHeaders: true},includePath: [/opt/ros/melodic/include/**,/usr/include/**],name: ROS,intelliSenseMode: gcc-x64,compilerPath: /usr/bin/clang,cStandard: c11,cppStandard: c14//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/?linkid830387
// version: 0.2.0,
// configurations: []
// }
{version: 0.2.0,configurations: [{name: (gdb) Launch, // 配置名称将会在调试配置下拉列表中显示type: cppdbg, // 调试器类型 该值自动生成request: launch, // 调试方式,还可以选择attachprogram: /home/autoware/Autoware/build/gnss_localizer/devel/lib/gnss_localizer/fix2tfpose, //要调试的程序完整路径支持相对路径args: [], // 传递给上面程序的参数没有参数留空即可stopAtEntry: false, // 是否停在程序入口点停在main函数开始cwd: ${workspaceRoot}, // 调试程序时的工作目录environment: [], //针对调试的程序要添加到环境中的环境变量. 例如: [ { name: squid, value: clam } ]externalConsole: false, //如果设置为true则为应用程序启动外部控制台。 如果为false则不会启动控制台并使用VS Code的内置调试控制台。MIMode: gdb, // VSCode要使用的调试工具名称miDebuggerPath: /usr/bin/gdb,setupCommands: [{description: Enable pretty-printing for gdb,text: -enable-pretty-printing,ignoreFailures: true}]}]
}settings.json
{files.associations: {iostream: cpp}
}task.json
{version: 2.0.0,tasks: [{type: catkin_make,args: [--directory,/home/autoware/Autoware/src/autoware/,-j4,-DCMAKE_BUILD_TYPEDebug,-DCATKIN_WHITELIST_PACKAGESpackage_name],problemMatcher: [$catkin-gcc],group: {kind:build,isDefault:true},label: catkin_make: build}]}Step5
在docker container中安装gdb debugger
$ gdb -help
$ sudo apt-get install libc6-dbg gdb valgrind # to install确保gdb的地址是正确的。检查launch.json文件中包含miDebuggerPath的一行。
Step6
在launch.json文件中编辑program这一行指定在/build目录下比如
/home/autoware/Autoware/build/op_global_planner/devel/lib/op_global_planner/op_global_plannerStep7
在/src目录下找到对应的cpp文件比如
/home/autoware/Autoware/src/autoware/core_planning/op_global_planner/nodes/op_global_planner.cpp确保所有的必要topic信息都可以被订阅到点击debug按钮并选择(gdb)launch debugger
参考链接
Open container fails with “Docker version 17.12.0 or later is required” #5396 Attached container configuration reference VSCode代码调试器 【VSCode】调试器debugger详细使用手册
第二种方法 – cmake重新编译
Autoware默认编译的版本为release版本因此需要编译为debug模式来进行调试。 要完成这个任务需要做几个方面的工作。
学习cmake了解Autoware中的编译结构修改CMakeLists.txt文件并重新编译为debug模式
cmake
Autoware项目是用cmake编译的首先需要对cmake的用法有所了解。 众所周知C中cpp文件无法直接运行需要编译成.o或.obj这种object目标文件才能够执行。
使用gcc命令可以分别编译每个cpp文件但这样很麻烦cmake则提供了批量编译很多文件的简便方法。
使用方法简介
为一个项目建立CMakeLists.txt文件在文件里按照规定的语法编写然后执行
$ cmake ..
$ make命令会生成编译文件主要的应该也是最基础的文件包括
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile并可以用make clean命令来清楚生成的object文件
cmake常用目录结构
build
通常为项目创建build目录在这个目录下执行cmake和make命令生成的文件都在这下面除了目标文件将编译生成的文件都放在build目录下还有一个好处是重新编译需要删除这些编译文件时可以直接删除不会和其他需要的文件混在一起。
bin
通常用来存放生成的object文件但是也不一定比如Autoware就放在每个小模块的CMakeFiles文件夹下面
lib
通常用来存放库文件包括.a静态库和.so动态库。
src
用来存放cpp源文件。
教程
【C】Cmake使用教程看这一篇就够了 【C】静态库和动态库文件的生成和使用
Autoware编译结构
Autoware路径下的目录结构为
build/ install/ log/ src/其中: build文件夹存放了各个模块编译相关的文件模块目录下的CMakeFiles存放了生成的object文件。 src文件夹存放了CMakeLists.txt文件。比如/home/autoware/Autoware/src/autoware/core_planning/op_global_planner/路径
查看Autoware的编译类型
How to check if program was compiled with debug symbols?
修改CMakeList.txt文件
在CMakeLists.txt文件里增加两行
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE RelWithDebInfo)然后回到build目录执行以下命令进行编译
$ colcon build --cmake-args -DCMAKE_BUILD_TYPERelWithDebInfo如果要编译为Release版本则执行 Without CUDA Support
$ colcon build --cmake-args -DCMAKE_BUILD_TYPEReleaseWith CUDA support
$ AUTOWARE_COMPILE_WITH_CUDA1 colcon build --cmake-args -DCMAKE_BUILD_TYPERelease参考链接
OpenPlanner项目独立的github链接
https://github.com/hatem-darweesh/autoware.ai.openplanner/tree/dd9bda08e2bb13b0ad501514098f853a38be7732
colcon使用文档
https://colcon.readthedocs.io/en/released/user/quick-start.html
build Autoware from source
https://gitlab.com/autowarefoundation/autoware.ai/autoware/-/wikis/Source-Build?version_ida33764ab4b6e7a1798c9f79465c74d565e92904b
How to check if program was compiled with debug symbols? [duplicate]
https://stackoverflow.com/questions/3284112/how-to-check-if-program-was-compiled-with-debug-symbols
VSCode debug cpp ROS node - compile package with debug mode
https://answers.ros.org/question/313371/vscode-debug-cpp-ros-node/
C/C: How do you set GDB debug flag (-g) with cmake?
https://bytefreaks.net/programming-2/cc-how-do-you-set-gdb-debug-flag-g-with-cmake