Using Duckietown Workspaces (Beta)
Contents
Warning
This feature is currently under development and is released in Beta mode. Most functionalities are currently working and have been extensively tested on macOS, but not on Windows. Please report all bugs in the Duckietown Slack community channel #beta-devcontainer or by email at info@duckietown.com.
Using Duckietown Workspaces (Beta)#
This page describes how to run Duckietown code inside a Development (Dev) Container, providing a functional environment inside of Visual Studio Code.
Note
This is the only workflow for running Duckietown code on an Apple Silicon (M-series) Mac and on Windows.
Host System Container Runtime Installation#
In order to run Duckietown in a Dev Container, you need to install the following software on your host system, depending on your operating system:
Host System Container Installation#
In order to run Duckietown in a Dev Container, you need to install the following software on your host system, depending on your operating system:
On macOS we will be installing Orbstack, a lightweight container runtime that supports Apple Silicon (M-series) Macs.
Attention
If you have Docker Desktop installed, uninstall it and reboot.
To install Orbstack:
Navigate to your
Downloadsfolder.Double-click the
.dmgfile.Move the application to your
Applicationsfolder.
Tip
If your Mac refuses to open an application because it is not trusted, hold down the option key and right-click it, then select Open. Your Mac will inform you that the application is not trusted but will allow you to open it.
On Windows we will be installing WSL with Ubuntu and Docker Desktop.
Attention
The following instructions use Windows Terminal, which comes preinstalled with Windows 11 version 22H2 and later. If you do not have it installed, you can download it from the Microsoft Store.
To install WSL and Ubuntu on Windows:
Install WSL by opening up the Windows Terminal and running
wsl --install
Reboot your computer after the installation is complete.
Install Ubuntu by running
wsl --install ubuntu
Follow onscreen instructions to setup an account in Ubuntu on WSL.
Installing Docker Desktop
Install docker desktop from https://www.docker.com/
Start ubuntu by running
wslin the Windows Terminal
Important
From now on cloning and running the devcontainer should be done from the wsl terminal, except when otherwise specified.
Installing Visual Studio Code#
To install Visual Studio Code:
Navigate to your
Downloadsfolder.Double-click the
.zipfile.(On Mac) Move the application to your
Applicationsfolder.
Installing the necessary VS Code extensions#
To install the Remote - Containers extension in VS Code:
Open VS Code.
Click on the
Extensionsicon in the left sidebar (or pressCtrl+Shift+Xon Windows orCmd+Shift+Xon macOS).In the search bar, type
Remote - Containers.Click on the
Installbutton next to theRemote - Containersextension by Microsoft.(Windows only) Follow the same instructions to install also the
WSLextension (see next section).
Cloning the dt-env-developer repository#
Clone the dt-env-developer repository, run:
git clone [email protected]:duckietown/dt-env-developer.git
Attention
Ignore the instructions in the README of this repository.
(Windows) If you are on Windows, make sure to run the above command from the wsl terminal.
Running the Dev Container in VS Code#
To run the Dev Container in VS Code:
Open VS Code and navigate to the
dt-env-developerfolder (File->Open Folder...->/path/to/dt-env-developer). You should see a popup appear in the bottom-right corner of your screen containing the message “Folder contains a Dev Container configuration file. Reopen folder to develop in a container (learn more).”.Click the
Reopen in Containerbutton.(Optional) Click the
Reading Dev Container Configuration (show log)link.
Note
The first time you load the Dev Container it may take some time as it is building the environment.
Setting up the Duckietown Shell#
To set up the Duckietown Shell, proceed as if you were setting up an Ubuntu system: Configure the Duckietown token in the Duckietown Shell.
Attention
If a popup asking you to input your credentials appears, you should do so and then click Always Allow.
Running the Duckiematrix#
The procedure for running the Duckiematrix will be slightly different in this workflow. In short, you
will run the Engine and Renderer inside and outside the Dev Container, respectively.
To start the Engine, run the following command in the Dev Container:
dts matrix engine run --sandbox --verbose
If you are using the Duckiematrix in the context of an LX, [launch the engine with dts code instead](caveat-devcontainer-lx).
To install the Renderer:
Navigate to your
Downloadsfolder.Double-click the
.zipfile.Move the application to your
Applicationsfolder.
To start the Renderer and connect it to the Engine running in the Dev Container, run the following commands, where TOKEN is your Duckietown Token (do not forget the double quotes):
cd /Applications
open duckiematrix.app --args -e localhost --token "TOKEN"
Caveats#
Accessing a Virtual Robot’s Dashboard#
To access a Virtual Robot’s Dashboard, open the noVNC virtual desktop by navigating to localhost:6080. After connecting to the desktop, click on the little triangular icon in the bottom left corner, and then on Web Browser. Once the browser is up, proceed as if you were using a physical Duckiebot (i.e., start the virtual Duckiebot, then navigate to robotname.local.)
Fig. 2 Connecting to a virtual Duckiebot Dashboard inside a workspace requires a few extra steps.#
Fig. 3 Accessing the Dashboard of a virtual Duckiebot inside a devcontainer.#
Accessing the Duckietown Viewer Apps#
Note
Duckietown Viewer applications (i.e., Image Viewer, Keyboard Controller, etc.) may not work as expected, due to limitations with GUI applications in Docker containers.
To open the Image Viewer in your browser, run the following command, where ROBOT_NAME is the name of your robot:
dts duckiebot image_viewer ROBOT_NAME --browser
To open the Image Viewer in the noVNC virtual desktop, run the following command after navigating to localhost:6080, where ROBOT_NAME is the name of your robot:
dts duckiebot image_viewer ROBOT_NAME
Attaching a Duckietown robot to the Duckiematrix#
To attach a Duckietown robot to the Duckiematrix, run the following command, where ROBOT_NAME is the name of your robot and ENGINE_LOCAL_NETWORK_ADDRESS is the LAN IP address of the Engine (not localhost):
dts matrix attach ROBOT_NAME -e ENGINE_LOCAL_NETWORK_ADDRESS ENTITY_NAME
The ENGINE_LOCAL_NETWORK_ADDRESS will be shown in the terminal after starting the engine. The ENTITY_NAME default is map_0/vehicle_0. A working example could be therefore:
dts matrix attach vargo -e 192.168.139.2 map_0/vehicle_0
Running dts code editor#
To be able to run dts code editor, you need to install mkcert on your host system:
Run
brew install mkcertor download thedarwinbinary for your system’s architecture.Run
mkcert -install(to install the local CA in your system).
Download mkcert for windows from this link, saving it to your Downloads folder.
Then, open the Windows Terminal and run:
.\Downloads\mkcert-v1.4.4-windows-amd64.exe --install
Select
Yesin the promptIn the Ubuntu terminal, open the
~/.bashrcfile with a text editor, e.g., by runningnano ~/.bashrcand append the following lines at the end of the file:WINUSER=$(powershell.exe '$env:USERNAME' | tr -d '\r') export MKCERT_PATH="/mnt/c/Users/$WINUSER/AppData/Local/mkcert"
Save and exit the text editor (in
nano, pressCtrl+X,Enter, thenEnter).Finally, run
source ~/.bashrcto update the current shell or open a newwslterminal window.
Learning Experiences in the Duckiematrix#
To run the Duckiematrix for LXs, run the following command to start the Engine:
dts code start_matrix --no-renderer
and then attach the Renderer launching it from the host machine.