-
make sure you have pulled the latest main
-
Install the
clangd (LLVM)vscode extension (you may be prompted to install clangd if you don't have it installed on your system) -
Turn off intellisense from default C/C++ microsoft vscode extension
- Add the following to your user settings
ctrl + shift + pand selectPreferences: Open User Settings (JSON) - add:
"C_Cpp.intelliSenseEngine": "disabled",
- Add the following to your user settings
-
If you are setting up clangd for a different repository (such as a TR autonomy training) you should copy the
colcon_defaults.yamlfrom the root of this repository and place it into the root of your other repository. If you are setting up clangd for this TR-Autonomy repository, this is already done for you.] -
you will need to
colcon buildand confirm there is acompile_commands.jsonfile inside thebuild/directory
NOTE Clangd only works if you generate a compile_commands.json. The colcon_defaults.yaml file in the root of this project automatically adds the cmake flag to generate this when you run colcon build. If you are setting up clangd for a different repository you should create a colcon_defaults.yaml file in the root of that project.
If you are having issues with clangd try running colcon build again.
you can also try running clangd: Restart Language Server
Add the following to your user settings.json (ctrl + shift + p and select Preferences: Open User Settings (JSON))
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},optionally also add the following to save on format
"editor.formatOnSave": true,-
Install the
PythonandPylanceextensions by microsoft -
install
Robot Developer Extensions for Ros2byRanch Hand Robotics LLC
-
run
ROS2: Update Python Path(you may need to run this periodically when you add new files or make major changes) -
you can verify it worked by checking
.vscode/settings.jsonand seeing it has added python auto complete and analysis extra paths. -
you should now have type hints for ros msg definitions and custom msg definitions like tr_messages inside python!
-
there is a
colcon_defaults.yamlthat passes the cmake arg-DCMAKE_EXPORT_COMPILE_COMMANDS=ONby default if you runcolcon build -
formatting style guide can be found inside the
.clang-formatfile