Setup Instructions¶
Sailbot Workspace can be run on Windows, Linux, or macOS, but is the easiest to set up and performs the best on Ubuntu and its derivatives. The workspace may not perform well on Windows computers with 8GB of memory or less; in this case, please check out our recommendations in the Performance Issues section.
1. Setup prerequisites¶
Docker¶
Docker is a platform that uses OS-level virtualization1 to develop, ship, and run applications.2 We use it to separate our applications from our infrastructure2 so that we can update and version control our infrastructure for every use case (software members, CI, deployment) in one place: this repository.
Docker Engine is a software used to run Docker. However, it can only be installed on Linux. Docker Desktop is a software used to run Docker in a VM,3 allowing it to be installed on Windows and macOS in addition to Linux.
-
Set up prerequisites, WSL and Ubuntu:
-
In PowerShell, run
wsl --install Ubuntu
, thenexit
,wsl --update
, andwsl --set-default Ubuntu
Ubuntu is already installed?
If Ubuntu is already installed, check that it is the right WSL version:
- Check the WSL versions of Linux distributions with
wsl -l -v
- If Ubuntu's
VERSION
is 1, upgrade it to WSL 2 withwsl --set-version Ubuntu 2
- Check the WSL versions of Linux distributions with
-
Open the Ubuntu app to set up or verify its configuration:
- If you are opening Ubuntu for the first time, a setup process will run; follow the prompts to finish setting it up
-
Run
whoami
to verify that it returns your Ubuntu usernamewhoami
returnsroot
If
whoami
returnsroot
:- Create a non-root user with sudo privileges
- Change the default Ubuntu user to this newly-created user: run
ubuntu config --default-user <username>
in PowerShell, replacing<username>
with the name of the newly-created user - Run
whoami
after closing and reopening Ubuntu, verifying that it returns your Ubuntu username
-
-
Install Docker Desktop with the WSL 2 backend
Docker Desktop - Unexpected WSL Error
If the above error shows when trying to start Docker Desktop on your laptop:
- For windows users navigate to
C:\Users\user_name
and delete the .Docker folder - Restart Docker Desktop
Docker Desktop can't start up and WSL hangs when restarting
If Ubuntu can't start up and WSL hangs when restarting:
- Open command prompt as administrator and run the command
netsh winsock reset
- Uninstall and reinstall Docker Desktop
- Restart your computer
More potential solutions can be found here: Link
- For windows users navigate to
Install Docker Desktop for your computer's CPU.
- Install Docker Engine
- As of February 2023, Sailbot Workspace (more specifically its use of VS Code Dev Containers) isn't compatible with Docker Desktop for Linux; if you have Docker Desktop installed, uninstall it and install Docker Engine instead.
- Manage Docker as a non-root user
- Configure Docker to start on boot
VS Code¶
Visual Studio Code is a powerful and customizable code editor for Windows, Linux, and macOS. We strongly recommend that you use this editor to develop our software so that you can use all the features of Sailbot Workspace.
- Install VS Code
- Install the Remote Development Extension Pack
Git¶
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.4
- Check if Git is installed with
git --version
(on Windows, run command in PowerShell)- If not installed, download and install it from Git Downloads
- Configure your name and email: Git config file setup (on Windows, run commands in Ubuntu)
-
Login to GitHub
-
Run the
git config
command for your Git version in Git Credential Manager setup (run command in Ubuntu)Which Git to check
Git is installed seperately in Windows and Ubuntu, so they could be at different versions. We want to check the version of Git on Windows, not Ubuntu: run
git --version
in PowerShell and not Ubuntu. However, thegit config
command itself is run in Ubuntu.
- Install the GitHub CLI: Installation
- Run
gh auth login
and select the first option for all choices
-
-
Verify that you have successfully logged in to GitHub by cloning a private GitHub repository (run command in Ubuntu)
- If you are a part of the UBCSailbot Software GitHub team,
you shouldn't see any errors running
git clone https://github.com/UBCSailbot/raye-ais.git
- You can delete this repository with
rm -rf raye-ais
- If you are a part of the UBCSailbot Software GitHub team,
you shouldn't see any errors running
2. Setup X11 forwarding¶
X11 forwarding is a mechanism that enables Sailbot Workspace to run GUI applications.
You can skip this step since we currently aren't running any GUI applications
Setup instructions for X11 forwarding
- Ensure that the versions of VS Code and its Dev Containers extension support X11 forwarding:
- VS Code version >= 1.75
- Dev Containers version >= 0.275.1
-
Verify that
echo $DISPLAY
returns something like:0
echo $DISPLAY
doesn't return anythingIf
echo $DISPLAY
doesn't return anything, set it to:0
on shell initialization:- Find out what shell you are using with
echo $SHELL
- Most Linux distributions use Bash by default, whose rc file path is
~/.bashrc
- macOS uses Zsh by default, whose rc file path is:
~/.zshrc
- Most Linux distributions use Bash by default, whose rc file path is
- Run
echo 'export DISPLAY=:0' >> <rc file path>
, replacing<rc file path>
with the path to your shell's rc file - Run
echo $DISPLAY
after closing and reopening your terminal, verifying it returns something like:0
- Find out what shell you are using with
-
Install a X11 server
WSL includes a X11 server.
- Set up XQuartz following this guide
- Copy the default xinitrc to your home directory:
cp /opt/X11/etc/X11/xinit/xinitrc ~/.xinitrc
- Add
xhost +localhost
to~/.xinitrc
after its first line
As of February 2023, almost all Linux distributions include a X11 server, Xorg. This may change in the future as Wayland matures.
- Install xhost:
sudo pacman -S xorg-xhost
- Copy the default xinitrc to your home directory:
cp /etc/X11/xinit/xinitrc ~/.xinitrc
- Add
xhost +local:docker
to~/.xinitrc
after its first line
-
Verify that X11 forwarding works:
-
Install
x11-apps
In Ubuntu,
sudo apt install x11-apps
.XQuartz includes
x11-apps
. Ensure that XQuartz is running.Install
x11-apps
using your desired package manager. -
Verify that running
xcalc
opens a calculator and that you can use it
-
3. Clone Sailbot Workspace¶
Where to clone on Windows
Run the command below in the Ubuntu app to clone it in the Ubuntu file system, otherwise sailbot workspace will not work. Windows has a native file system as well as file systems for each WSL distribution.
4. Open Sailbot Workspace in VS Code¶
-
Install
code
command inPATH
The
code
command is installed by default.The
code
command is installed by default. -
Open the
sailbot_workspace/
directory in VS Code: runcode <relative path to sailbot workspace>
- For example, if you just cloned the repository, the command would be
code sailbot_workspace
- For example, if you just cloned the repository, the command would be
5. Open the workspace file¶
Click the popup to Open Workspace
. If there isn't a popup:
- Open the file
sailbot.code-workspace
in VS Code - Click
Open Workspace
6. Open Sailbot Workspace in a Dev Container¶
- Ensure that Docker is running
- Click the popup to
Reopen in Container
. If there isn't a popup, run theDev Containers: Reopen in Container
VS Code command
7. Run the Build All
task¶
Wait before running
Ensure that the postCreateCommand from devcontainer.json
has completed before running this task.
The Build All
task builds all the ROS packages.
8. Reload the VS Code terminals and window¶
Delete all open terminals and run the Developer: Reload Window
VS Code command
to detect the files that were generated from building.
9. Start the system¶
Run the entire system to verify everything is working using the following command in the VS Code terminal:
Use Ctrl+C in the terminal to stop the system.
Setup Sailbot Workspace in a GitHub Codespace¶
A codespace is a development environment that's hosted in the cloud.5 Since Sailbot Workspace is resource intensive, it has high hardware requirements and power consumption, which aren't ideal for development on laptops. GitHub Codespaces provide a seamless experience to work on repositories off-device, especially if they specify a Dev Container like Sailbot Workspace. Codespaces can run in VS Code or even in a browser for times when you aren't on your programming computer.
- Create a GitHub Codespace following the steps in the relevant GitHub Docs page:
create a codespace for a repository.
A couple things to note:
- For the best Sailbot Workspace development experience, select the high-spec machine available
- There are usage limits if you don't want to pay:
monthly included storage and core hours for personal accounts
- Upgrade to a Pro account for increased usage limits (this is free for students): apply to GitHub Global Campus as a student
- Stop your codespace as soon as you are done using it: stopping a codespace
- Delete codespaces that you do not plan to use anymore: deleting a codespace
- Follow the local setup instructions starting from 5. Open the workspace file
Once you have a codespace set up:
- Open it by following the steps in the relevant GitHub Docs page: reopening a codespace
- Close it by running the
Codespaces: Stop Current Codespace
VS Code command
Known limitations of running Sailbot Workspace in a GitHub Codespace
- Does not support X11 forwarding to run GUI applications
- High-spec machines not available: as of March 2023, the highest-spec machine that is publically available has a 4-core CPU and 8GB of RAM