{"id":13719179,"url":"https://github.com/athackst/vscode_ros2_workspace","last_synced_at":"2025-05-14T23:07:29.115Z","repository":{"id":38322471,"uuid":"286613754","full_name":"athackst/vscode_ros2_workspace","owner":"athackst","description":"A template for using VSCode as an IDE for ROS2 development.","archived":false,"fork":false,"pushed_at":"2025-03-26T23:02:47.000Z","size":903,"stargazers_count":912,"open_issues_count":3,"forks_count":184,"subscribers_count":22,"default_branch":"humble","last_synced_at":"2025-04-13T20:39:14.340Z","etag":null,"topics":["docker","ros2","vscode","workspace"],"latest_commit_sha":null,"homepage":"https://althack.dev/vscode_ros2_workspace","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athackst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-11T01:15:04.000Z","updated_at":"2025-04-08T12:25:18.000Z","dependencies_parsed_at":"2023-12-10T08:24:40.125Z","dependency_job_id":"29cbc1de-2431-4722-950c-71ca4937ecc1","html_url":"https://github.com/athackst/vscode_ros2_workspace","commit_stats":null,"previous_names":[],"tags_count":2,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athackst%2Fvscode_ros2_workspace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athackst%2Fvscode_ros2_workspace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athackst%2Fvscode_ros2_workspace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athackst%2Fvscode_ros2_workspace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athackst","download_url":"https://codeload.github.com/athackst/vscode_ros2_workspace/tar.gz/refs/heads/humble","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243362,"owners_count":22038046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","ros2","vscode","workspace"],"created_at":"2024-08-03T01:00:43.866Z","updated_at":"2025-05-14T23:07:24.106Z","avatar_url":"https://github.com/athackst.png","language":"Python","funding_links":[],"categories":["Development Environment","ROS2"],"sub_categories":["Template","Dev Tools"],"readme":"# VSCode ROS2 Workspace Template\n\nThis template will get you set up using ROS2 with VSCode as your IDE.\n\nSee [how I develop with vscode and ros2](https://www.allisonthackston.com/articles/vscode_docker_ros2.html) for a more in-depth look on how to use this workspace.\n\n## Features\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/humble/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 on 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.  See [`.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\nTo remove a linter just delete it's name from this line:\n\n```yaml\n      matrix:\n          linter: [cppcheck, cpplint, uncrustify, lint_cmake, xmllint, flake8, pep257]\n```\n\n## How to use this template\n\n### Prerequisites\n\nYou should already have Docker and VSCode with the remote containers plugin installed on your system.\n\n* [docker](https://docs.docker.com/engine/install/)\n* [vscode](https://code.visualstudio.com/)\n* [vscode remote containers plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)\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 decide if you want all of the branches, or just the latest LTS: humble.\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 \"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, you can open it in VSCode (File-\u003eOpen Folder). \n\nWhen you open it for the first time, you should see a little popup that asks you if you would like to open 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 pop-up, click on the little green square in the bottom left corner, which should bring up the container dialog\n\n![template_vscode_bottom](https://user-images.githubusercontent.com/6098197/91332638-5d47b780-e781-11ea-9fb6-4d134dbfc464.png)\n\nIn the dialog, select \"Remote Containers: Reopen in container\"\n\nVSCode will build the dockerfile inside of `.devcontainer` for you.  If you open a terminal inside VSCode (Terminal-\u003eNew Terminal), you should see that your username has been changed to `ros`, and the bottom left green corner should say \"Dev Container\"\n\n![template_container](https://user-images.githubusercontent.com/6098197/91332895-adbf1500-e781-11ea-8afc-7a22a5340d4a.png)\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 `Terminal-\u003eRun Task..-\u003eimport from workspace file`\n3. Install dependencies `Terminal-\u003eRun Task..-\u003einstall dependencies`\n4. (optional) Adjust scripts to your liking.  These scripts are used both within tasks and CI.\n   * `setup.sh` The setup commands for your code.  Default to import workspace and install dependencies.\n   * `build.sh` The build commands for your code.  Default to `--merge-install` and `--symlink-install`\n   * `test.sh` The test commands for your code.\n5. Develop!\n\n\n## FAQ\n\n### WSL2\n\n#### The gui doesn't show up\n\nThis is likely because the DISPLAY environment variable is not getting set properly.\n\n1. Find out what your DISPLAY variable should be\n\n      In your WSL2 Ubuntu instance\n\n      ```\n      echo $DISPLAY\n      ```\n\n2. Copy that value into the `.devcontainer/devcontainer.json` file\n\n      ```jsonc\n      \t\"containerEnv\": {\n\t\t      \"DISPLAY\": \":0\",\n         }\n      ```\n\n#### I want to use vGPU\n\nIf you want to access the vGPU through WSL2, you'll need to add additional components to the `.devcontainer/devcontainer.json` file in accordance to [these directions](https://github.com/microsoft/wslg/blob/main/samples/container/Containers.md)\n\n```jsonc\n\t\"runArgs\": [\n\t\t\"--network=host\",\n\t\t\"--cap-add=SYS_PTRACE\",\n\t\t\"--security-opt=seccomp:unconfined\",\n\t\t\"--security-opt=apparmor:unconfined\",\n\t\t\"--volume=/tmp/.X11-unix:/tmp/.X11-unix\",\n\t\t\"--volume=/mnt/wslg:/mnt/wslg\",\n\t\t\"--volume=/usr/lib/wsl:/usr/lib/wsl\",\n\t\t\"--device=/dev/dxg\",\n      \t\t\"--gpus=all\"\n\t],\n\t\"containerEnv\": {\n\t\t\"DISPLAY\": \"${localEnv:DISPLAY}\", // Needed for GUI try \":0\" for windows\n\t\t\"WAYLAND_DISPLAY\": \"${localEnv:WAYLAND_DISPLAY}\",\n\t\t\"XDG_RUNTIME_DIR\": \"${localEnv:XDG_RUNTIME_DIR}\",\n\t\t\"PULSE_SERVER\": \"${localEnv:PULSE_SERVER}\",\n\t\t\"LD_LIBRARY_PATH\": \"/usr/lib/wsl/lib\",\n\t\t\"LIBGL_ALWAYS_SOFTWARE\": \"1\" // Needed for software rendering of opengl\n\t},\n```\n\n### Repos are not showing up in VS Code source control\n\nThis is likely because vscode doesn't necessarily know about other repositories unless you've added them directly. \n\n```\nFile-\u003eAdd Folder To Workspace\n```\n\n![Screenshot-26](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/d8711320-2c16-463b-9d67-5bd9314acc7f)\n\n\nOr you've added them as a git submodule.\n\n![Screenshot-27](https://github.com/athackst/vscode_ros2_workspace/assets/6098197/8ebc9aac-9d70-4b53-aa52-9b5b108dc935)\n\nTo add all of the repos in your *.repos file, run the script\n\n```bash\npython3 .devcontainer/repos_to_submodules.py\n```\n\nor run the task titled `add submodules from .repos`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathackst%2Fvscode_ros2_workspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathackst%2Fvscode_ros2_workspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathackst%2Fvscode_ros2_workspace/lists"}