- Follow https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
- Instead of
ros-humble-desktop
useros-humble-desktop-full
- Inside of
~/.bashrc
addsource /opt/ros/humble/setup.bash
after installation of ros2
sudo apt install clang-format
- CMake
- CMake Tools
- Clang-Format
- C/C++ Extension Pack
- ROS
- XML Tools
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"
}
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 examplerclcpp example_interfaces
)
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