ROS——VScode编译ROS工程

末蓝、 2022-12-29 00:22 311阅读 0赞

文章目录

  • 1.配置环境
  • 2.编译

1.配置环境

1.1 在工程目录下创建文件夹.vscode
1.2 在文件夹.vscode中添加文件c_cpp_properties.json
将下面内容添加到文件c_cpp_properties.json

  1. {
  2. "configurations": [
  3. {
  4. "name": "Linux",
  5. "includePath": [
  6. "${workspaceFolder}/**"
  7. ],
  8. "defines": [],
  9. "compilerPath": "/usr/bin/gcc",
  10. "cStandard": "c11",
  11. "cppStandard": "c++17",
  12. "intelliSenseMode": "gcc-x64",
  13. "compileCommands": "${workspaceFolder}/build/compile_commands.json"
  14. }
  15. ],
  16. "version": 4
  17. }

1.3 在文件夹.vscode中添加文件settings.json
写入下面内容:

  1. {
  2. "files.associations": {
  3. "ostream": "cpp",
  4. "deque": "cpp",
  5. "forward_list": "cpp",
  6. "list": "cpp",
  7. "array": "cpp",
  8. "*.tcc": "cpp",
  9. "memory": "cpp",
  10. "future": "cpp",
  11. "istream": "cpp",
  12. "functional": "cpp",
  13. "tuple": "cpp",
  14. "utility": "cpp",
  15. "variant": "cpp",
  16. "string": "cpp",
  17. "cctype": "cpp",
  18. "clocale": "cpp",
  19. "cmath": "cpp",
  20. "csignal": "cpp",
  21. "cstdarg": "cpp",
  22. "cstddef": "cpp",
  23. "cstdio": "cpp",
  24. "cstdlib": "cpp",
  25. "cstring": "cpp",
  26. "ctime": "cpp",
  27. "cwchar": "cpp",
  28. "cwctype": "cpp",
  29. "any": "cpp",
  30. "atomic": "cpp",
  31. "hash_map": "cpp",
  32. "hash_set": "cpp",
  33. "strstream": "cpp",
  34. "bitset": "cpp",
  35. "chrono": "cpp",
  36. "codecvt": "cpp",
  37. "complex": "cpp",
  38. "condition_variable": "cpp",
  39. "cstdint": "cpp",
  40. "unordered_map": "cpp",
  41. "unordered_set": "cpp",
  42. "vector": "cpp",
  43. "exception": "cpp",
  44. "algorithm": "cpp",
  45. "filesystem": "cpp",
  46. "iterator": "cpp",
  47. "map": "cpp",
  48. "memory_resource": "cpp",
  49. "numeric": "cpp",
  50. "optional": "cpp",
  51. "random": "cpp",
  52. "ratio": "cpp",
  53. "set": "cpp",
  54. "string_view": "cpp",
  55. "system_error": "cpp",
  56. "type_traits": "cpp",
  57. "fstream": "cpp",
  58. "initializer_list": "cpp",
  59. "iomanip": "cpp",
  60. "iosfwd": "cpp",
  61. "iostream": "cpp",
  62. "limits": "cpp",
  63. "mutex": "cpp",
  64. "new": "cpp",
  65. "shared_mutex": "cpp",
  66. "sstream": "cpp",
  67. "stdexcept": "cpp",
  68. "streambuf": "cpp",
  69. "thread": "cpp",
  70. "cfenv": "cpp",
  71. "cinttypes": "cpp",
  72. "typeindex": "cpp",
  73. "typeinfo": "cpp",
  74. "bit": "cpp",
  75. "*.ipp": "cpp",
  76. "core": "cpp"
  77. },
  78. "python.autoComplete.extraPaths": [
  79. "/home/lanx/Program/UAVs/devel/lib/python3/dist-packages",
  80. "/opt/ros/noetic/lib/python3/dist-packages"
  81. ],
  82. "cmakeFormat.exePath": "/usr/local/bin/cmake-format"
  83. }

1.4 在文件夹.vscode中添加文件tasks.json
写入下面内容:

  1. {
  2. "version": "2.0.0",
  3. "tasks": [
  4. {
  5. "label": "catkin_make", //代表提示的描述性信息
  6. "type": "shell", //可以选择shell或者process,如果是shell代码是在shell里面运行一个命令,如果是process代表作为一个进程来运行
  7. "command": "catkin_make",//这个是我们需要运行的命令
  8. "args": [],//如果需要在命令后面加一些后缀,可以写在这里,比如-DCATKIN_WHITELIST_PACKAGES=“pac1;pac2”
  9. "group": { "kind":"build","isDefault":true},
  10. "presentation": {
  11. "reveal": "always"//可选always或者silence,代表是否输出信息
  12. },
  13. "problemMatcher": "$msCompile"
  14. },
  15. ]
  16. }

2.编译

  • 先在命令窗口中catkin_make工程;
  • 再依次点击点击左上角Terminal->Run Build Task即可;
  • 后面修改代码后只需执行步骤2.2即可;

发表评论

表情:
评论列表 (有 0 条评论,311人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ROS(一)工程搭建

    1、创建Catkin的WorkSpace catkin是ROS的一个官方的编译构建系统,是原本的ROS的编译构建系统rosbuild的替代者。一个Catkin WorkSp