Skip to content

Latest commit

 

History

History
86 lines (81 loc) · 3.05 KB

README.md

File metadata and controls

86 lines (81 loc) · 3.05 KB

ROS2 Humble Examples

Install Ros2 Humble

Install Additional VSCode Extensions

  • sudo apt install clang-format
  • CMake
  • CMake Tools
  • Clang-Format
  • C/C++ Extension Pack
  • ROS
  • XML Tools

Setup VSCode

Inside of Settings/Open Settings (JSON) paste the following:

{
    "ros.distro": "humble",
    "editor.formatOnSave": true,
    "editor.minimap.enabled": false,
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    },
    "editor.tabSize": 4,
    "editor.detectIndentation": false,
    "clang-format.executable": "/usr/bin/clang-format",
    "clang-format.language.c.enable": true,
    "clang-format.language.cpp.enable": true,
    "clang-format.language.cuda.enable": true,
    "clang-format.style": "Microsoft",
    "[cpp]": {
        "editor.defaultFormatter": "xaver.clang-format",
        "editor.wordBasedSuggestions": false,
        "editor.suggest.insertMode": "replace",
        "editor.semanticHighlighting.enabled": true
    },
    "[c]": {
        "editor.defaultFormatter": "xaver.clang-format",
        "editor.wordBasedSuggestions": false,
        "editor.suggest.insertMode": "replace",
        "editor.semanticHighlighting.enabled": true
    },
    "[cuda-cpp]": {
        "editor.defaultFormatter": "xaver.clang-format",
        "editor.wordBasedSuggestions": false,
        "editor.suggest.insertMode": "replace",
        "editor.semanticHighlighting.enabled": true
    },
    "xmlTools.enableXmlTreeView": true,
    "xmlTools.xmlFormatterImplementation": "v2",
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.intelliSenseEngine": "Default",
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**",
        "/opt/ros/humble/include/**"
    ],
    "C_Cpp.maxConcurrentThreads": 4,
    "C_Cpp.commentContinuationPatterns": [
        {
            "begin": "/*",
            "continue": " *",
        },
        {
            "begin": " *",
            "continue": " *"
        }
    ],
    "C_Cpp.inlayHints.autoDeclarationTypes.enabled": true,
    "C_Cpp.inlayHints.autoDeclarationTypes.showOnLeft": true,
    "C_Cpp.inlayHints.parameterNames.enabled": true,
    "C_Cpp.inlayHints.referenceOperator.enabled": true,
    "telemetry.telemetryLevel": "crash"
}

How to set up this type of project

  • ros2 pkg create --build-type ament_cmake ${package_name} --dependencies ${list_of_dependencies} (replace ${package_name} with your own name, for example, cpp_publisher_subscriber, in my case, and ${list_of_dependencies} with your dependencies, separated by space, for example rclcpp example_interfaces)

How to build the package

  • cd cpp_publisher_subscriber
  • Check for missing dependencies before building the package rosdep install -i --from-path src --rosdistro humble -y
  • Build the package colcon build --packages-select publisher_subscriber