...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
View file name devcontainer.json height 250
Ubuntu 20.04 Install (Preferred)
name | devcontainer.json |
---|---|
height | 250 |
On the software team, the operating system we use is Ubuntu 20.04. Ubuntu is a popular Linux distribution that supports ROS2, a robotics framework that is at the core of our architecture. There is also the option of using ROS on WSL (Windows Subsystem for Linux) without any gui compatibility(rviz, rqt, etc). We will not provide any support to you using ROS2 on anything other than an Ubuntu 20.04 installation (maybe windows).
...
- Install WSL2 on your computer. This is Windows Subsystem for Linux, which allows developers to run a Linux environment without a separate virtual machine or dual booting. It's used by Docker to run its backend. If you're on Windows 10 version 2004 and higher (Build 19041 and higher), visit this page; all you have to do is run one command in Windows Powershell! If you're on an older build, see these manual steps.
- Install Docker Desktop via the instructions.
- Install VcXsrv, an application for the X Window System Display server. The X Window System Display server used by various operating systems for running their graphical applications. We'll VcXserv on Windows, and then we'll send all the graphical application traffic from our Docker container to our X server running on Windows, allowing us to run our graphical applications straight out of the box.
- We'll need to change the display number on VcXsrv to 0 so Docker knows where to find our server. Navigate to `C:\Program Files\VcXsrv`, or wherever you installed VcXsrv, and launch
xlaunch.exe
. In the display settings window, navigate to the bottom and change Display Number from -1 to 0, and hit next until you can closexlaunch
. - Make sure Docker Desktop is running before we continue. It usually runs in the background, so check your hidden icons (the up arrow in the bottom right of the Windows taskbar) to make sure you see the Docker icon in there.
- From here, we're going to migrate to VSCode so you can develop properly. If you haven't already, install VSCode, then install the Dev Containers Extension.
- Create a folder on your computer for your UW Robotics team development–doesn't matter where it is, as long as you can access it quickly.
- Open up that folder in VSCode. Download and add our "Dockerfile.dev" file to that folder.
- Now, use Ctrl+Shift+P to open the Command Palette. In the Command Palette, search for and run "Dev Containers: Open Folder in Container".
- VSCode will then ask you to open a folder–open the folder you created earlier for your UW Robotics team development. Then, it will ask you which Dockerfile you'd like to use for the container–choose the Dockerfile.dev file you downloaded before, which is in that folder.
- It will then create a "devcontainer.json" for you inside a ".devcontainer" folder, as well as build and open the container. The devcontainer.json file tells Docker how to build and run your container.
- We need to add a specific line to your newly created
devcontainer.json
. On the next available line, add the following data. Make sure to add any commas required (before or after the data) so the JSON is valid."containerEnv": { "DISPLAY": "host.docker.internal:0.0" } - Here is a completed devcontainer.json.
- You'll need to save the file and restart your container for the change to your devcontainer.json. You can close the container by going in the bottom left in VSCode to the green icons/text, and clicking Close Remote Session. Then, do the same, but Rebuild Container.
- You are officially done! Let's go ahead and recap the instructions anytime you want to start coding in your container:
- Open Docker Desktop.
- Open VcXsrv (you may want to add the C:\Program Files\VcXsrv\xlaunch.exe file as a shortcut to your Start Menu or Desktop).
- Once you've opened VcXsrv's Xlasunch, change the display number to 0, then hit next until you see Finish, and click that.
- Open VSCode.
- Use Ctrl+Shift+P to open the VSCode Command Palette.
- In the Command Palette, search for and run "Dev Containers: Open Folder in Container".
- When prompted, open your UW Robotics team development folder.
- When prompted, use Dockerfile.dev as your development container. This container contains ROS2 Galactic running on Ubuntu 20.04!
- Done! When you want to run commands in your container, use Ctrl+` to open a terminal to your container. Anything you do inside the container will be reflected in your folder on your local machine.
...