Skip to content

Environment Setup

Benjamin Poulin edited this page Sep 11, 2023 · 6 revisions

General Setup

Editor

The majority of MATE ROV software is written in Python, with a dollop of C++ for added flavor. Most of us use Visual Studio Code or PyCharm for editing. VSCode is a general-purpose editor, so go with that if you don't have either.

OS

Our surface computer runs on Ubuntu 22.04 (Jammy Jellyfish). If you already have Ubuntu Jammy, skip this section. If you're on a Mac, much badness; talk to your friendly neighborhood software lead about setting up an Ubuntu USB stick or installing an Ubuntu VM.

If you're on Windows, consider making a dual boot. Dual boots are a little harder to set up than VMs or WSL, but they make things easier later on. We have a bootable thumb drive you can use for dual booting if you can't make one. If you don't want to dual boot, you can either install a virtual machine or do the following to install the Windows Subsystem for Linux:

Open PowerShell with admin permissions (⊞ Win + s > type powershell > Run as Administrator)

Run wsl --install

Restart your machine

See the official installation instructions for more info.

Download Ubuntu 22.04

Go to the Microsoft store and download Ubuntu 22.04

ROS 2 Humble

Automatic installation

Open a new Ubuntu terminal (on Windows: ⊞ Win + s > type ubuntu > Ubuntu on Windows)

First, install curl to be able to download our install script

sudo apt install curl

Download the install script

curl -o install.sh https://raw.githubusercontent.com/cwruRobotics/rov-24/main/src/surface/surface_main/scripts/ROS2-Install-Humble.sh

Run the install script

source install.sh

If there are failures, try the manual installation.

Manual Installation

Open a new Ubuntu terminal (on WSL: ⊞ Win + s > type ubuntu > Ubuntu on Windows)

Run the following one at a time to install dependencies:

sudo apt upgrade

sudo apt install git
sudo apt install curl
sudo apt install python3-pip

pip install pyserial
pip install wiringpi
pip install PyQt6
pip install pyqtdarktheme
pip install numpy
pip install numpy --upgrade
pip install opencv-python

Run locale and make sure the output includes a LANG= line with UTF-8 at the end

Run apt-cache policy | grep universe and make sure the output includes something like

500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64

If it doesn't or you aren't sure (make sure the word focal is in there!), run sudo apt install software-properties-common and sudo add-apt-repository universe

Now run the following:

sudo apt update && sudo apt install curl gnupg lsb-release

lsb_release -a.

sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

sudo apt update

sudo apt upgrade

sudo apt install ros-humble-desktop

Add an automatic setup script to your startup file if you don't have it already:

grep "source /opt/ros/humble/setup.bash" ~/.bashrc

If the previous command did not return source /opt/ros/humble/setup.bash, then run echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc.

Test the Installation

Open a terminal and run

ros2 run demo_nodes_cpp talker

You should see messages being published.

Open a second terminal and run

ros2 run demo_nodes_py listener

You should see messages being received from the talker.