{"repo":"althack/vscode_ros2_workspace","free":true,"listed":false,"github":"https://github.com/althack/vscode_ros2_workspace","clone":"git clone https://github.com/althack/vscode_ros2_workspace.git","description":"A template for using VSCode as an IDE for ROS2 development.","language":"Python","stars":993,"topics":["docker","ros2","vscode","workspace"],"license":"Apache-2.0","category":"dev_tool","readme_excerpt":"# VSCode ROS2 Workspace Template\n\nThis template will get you set up using ROS2 with VSCode as your IDE.\n\nThe development environment is set up using a VSCode devcontainer, and the same configuration is also used in CI.\n\n## Features\n\n### Development environment\n\nThe devcontainer uses the Microsoft Ubuntu devcontainer image along with the ROS2 devcontainer feature.\n\nIf you want to change which version of ROS you're using, update the ROS2 feature in `.devcontainer/devcontainer.json`:\n\n```jsonc id=\"vozthd\"\n\"ghcr.io/althack/devcontainers/ros2:0\": {\n  \"distro\": \"lyrical\",\n  \"package\": \"desktop\"\n}\n```\n\nThis is also the ROS version used in CI, so you only need to change it in one place.\n\n### Style\n\nROS2-approved formatters are included in the IDE.\n\n* **c++** uncrustify; config from `ament_uncrustify`\n* **python** autopep8; vscode settings consistent with the [style guide](https://docs.ros.org/en/lyrical/The-ROS2-Project/Contributing/Code-Style-Language-Versions.html)\n\n### Tasks\n\nThere are many pre-defined tasks, see [`.vscode/tasks.json`](.vscode/tasks.json) for a complete listing. Feel free to adjust them to suit your needs.\n\nTake a look at [how I develop using tasks](https://www.allisonthackston.com/articles/vscode_tasks.html) for an idea of how I use tasks in my development.\n\n### Debugging\n\nThis template sets up debugging for python files, gdb for cpp programs, and ROS launch files.\n\nSee [`.vscode/launch.json`](.vscode/launch.json) for configuration details.\n\n### Continuous Integration\n\nThe template also comes with basic continuous integration set up. See [`.github/workflows/ros.yaml`](.github/workflows/ros.yaml).\n\nThe build, test, and lint jobs run using the same devcontainer configuration used for development. This means changing the ROS distro in `.devcontainer/devcontainer.json` also changes the version used by CI.\n\nTo remove a linter, just delete its name from the matrix:\n\n```yaml id=\"nxevf7\"\nmatrix:\n  linter:\n    - cppcheck\n    - cpplint\n    - uncrustify\n    - lint_cmake\n    - xmllint\n    - flake8\n    - pep257\n```\n\n## How to use this template\n\n### Prerequisites\n\nYou should already have Docker and VSCode with the Dev Containers extension installed on your system.\n\n* [docker](https://docs.docker.com/engine/install/)\n* [vscode](https://code.visualstudio.com/)\n* [vscode dev containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)\n\nIf you're using Windows, I recommend using WSL2 and opening the repository from your WSL distro before reopening it in the container.\n\n### Get the template\n\nClick on **Use this template**.\n\n![template_use](https://user-images.githubusercontent.com/6098197/91331899-43f23b80-e780-11ea-92c8-b4665ce126f1.png)\n\n### Create your repository\n\nOn the next dialog, name the repository you would like to start and choose its visibility.\n\n![template_new](https://user-images.githubusercontent.com/6098197/91332035-713ee980-e780-11ea-81d3-13b170f568b0.png)\n\nGithub will then create a new repository with the contents of this one in your account. It grabs the latest changes as the initial commit.\n\n### Clone your repo\n\nNow you can clone your repo as normal.\n\n![template_download](https://user-images.githubusercontent.com/6098197/91332342-e4e0f680-e780-11ea-9525-49b0afa0e4bb.png)\n\n### Open it in vscode\n\nNow that you've cloned your repo onto your computer, open it in VSCode (`File -> Open Folder`).\n\nWhen you open it for the first time, you should see a popup asking if you would like to reopen it in a container. Say yes!\n\n![template_vscode](https://user-images.githubusercontent.com/6098197/91332551-36898100-e781-11ea-9080-729964373719.png)\n\nIf you don't see the popup, open the command palette and select:\n\n```text id=\"fipghb\"\nDev Containers: Reopen in Container\n```\n\nVSCode will set up the container from `.devcontainer/devcontainer.json`, install ROS2 and the configured development tools, and install the recommended VSCode extensions.\n\nOnce that's finished, open a terminal inside VSCode and you're ready to go.\n\n## Update the template with your code\n\n1. Specify the repositories you want to include in your workspace in `src/ros2.repos`, or delete `src/ros2.repos` and develop directly within the workspace.\n2. If you are using a `ros2.repos` file, import the contents with `Terminal -> Run Task... -> import from workspace file`.\n3. Install dependencies with `Terminal -> Run Task... -> install dependencies`.\n4. Adjust the scripts to your liking. These scripts are used both within tasks and CI.\n\n   * `setup.sh` - setup commands for your code. By default this imports the workspace and installs dependencies.\n   * `build.sh` - build commands for your code. By default this uses `--merge-install` and `--symlink-install`.\n   * `test.sh` - test commands for your code.\n5. Develop!\n\n## Changing the ROS distro\n\nThe ROS distro is selected by the ROS2 feature in `.devcontainer/devcontainer.json`:\n\n```jsonc id=\"si9pp5\"\n\"ghcr.io/althack/devcontainers/ros2:0\": {\n  \"distro\": \"lyrical\",\n  \"package\": \"desktop\"\n}\n```\n\nChange `distro` to the version you want to use and rebuild the container.\n\nSince CI uses the same devcontainer configuration, you don't need to update the ROS distro anywhere else.\n\n## GUI applications\n\n### Windows / WSL2\n\nIf you're using Windows, open the repository from your WSL2 distro and then reopen it in the devcontainer.\n\nCurrent versions of VSCode Dev Containers and WSLg handle the display forwarding for you, so you shouldn't need to manually configure `DISPLAY`, Wayland, PulseAudio, or `/mnt/wslg` mounts.\n\n### Linux / X11\n\nIf you're using native Linux with X11, uncomment the X11 forwarding feature in `.devcontainer/devcontainer.json`:\n\n```jsonc id=\"mxugk2\"\n\"ghcr.io/althack/devcontainers/linux-x11-forwarding:0\": {},\n```\n\nSome GUI applications may also need the container to share the host IPC namespace. If you run into rendering problems, try uncommenting:\n\n```jsonc id=\"9b5wt2\"\n\"--ipc=host\"\n```\n\nin `runArgs`.\n\n## NVIDIA / CUDA\n\nCUDA support is optional.\n\nIf you want to use CUDA, uncomment the NVIDIA CUDA feature in `.devcontainer/devcontainer.json`:\n\n```jsonc id=\"w72s2s\"\n\"ghcr.io/devcontainers/features/nvidia-cuda:3\": {\n  \"installToolkit\": true\n}\n```\n\nand allow the container to access the host GPU:\n\n```jsonc id=\"xa78sc\"\n\"--gpus\",\n\"all\"\n```\n\nYou'll also need working NVIDIA drivers and the NVIDIA Container Toolkit installed on the host.\n\nSee the [NVIDIA Container Toolkit installation guide](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) for setup instructions.\n\nI don't test all of the possible NVIDIA/CUDA host configurations, so your mileage may vary here.\n\n## Repos are not showing up in VS Code source control\n\nVSCode doesn't necessarily know about repositories you've imported underneath the workspace.\n\nYou can add them directly using:\n\n```text id=\"jwb7ls\"\nFile -> Add Folder To Workspace\n```\n\n![Screenshot-26](https://github.com/althack/vscode_ros2_workspace/assets/6098197/d8711320-2c16-463b-9d67-5bd9314acc7f)\n\nOr you can add them as git submodules.\n\n![Screenshot-27](https://github.com/althack/vscode_ros2_workspace/assets/6098197/8ebc9aac-9d70-4b53-aa52-9b5b108dc935)\n\nTo add all of the repos in your `*.repos` file as submodules, run:\n\n```bash id=\"1pnpb2\"\npython3 .devcontainer/repos_to_submodules.py\n```\n\nor run the task titled:\n\n```text id=\"7do355\"\nadd submodules from .repos\n```\n","default_branch":"main","files":17,"tree":[".devcontainer/devcontainer.json",".devcontainer/repos_to_submodules.py",".github/dependabot.yml",".github/scripts/lint.sh",".github/workflows/docs.yaml",".github/workflows/ros.yaml",".gitignore",".vscode/c_cpp_properties.json",".vscode/launch.json",".vscode/settings.json",".vscode/tasks.json","LICENSE","README.md","build.sh","setup.sh","src/ros2.repos","test.sh"],"storefront":"/r/althack","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/althack/vscode_ros2_workspace/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}