Skip to content

2. Install ROS

Riley Bridges edited this page Sep 22, 2022 · 85 revisions

Operating Systems and Requirements

We highly recommend running Ubuntu 20.04 LTS natively. This will be by far the smoothest experience. There are many tutorials on dual booting out there if you are not comfortable with daily driving Linux. You will likely need 40-60 GB of space for your Linux partition.

Please note that we will only officially support Ubuntu 20.04 LTS running natively. All other options are not as thoroughly tested and we cannot provide the same level of support if you run into any issue. However, here are some other options you can try to explore:

  1. Ubuntu 20.04 LTS in a VM (Makes things like USB and GPU access difficult). Mac guide here
  2. Other Linux distro of choice with an Ubuntu Docker container
  3. Natively setup ROS on some other distro by compiling all packages from sources (some of our members have been successful in doing this for Arch)
  4. WSL on Windows 11 (has issues with RViz graphics)

Some other things to know:

  • WSL on Windows 10 is missing a lot of features and has proven to be much more trouble than its worth. WSL on Win11 still leaves a lot to be desired and does have strange issues from time to time, but seems to be much better. WSL is by far the worst option listed though in any case.

Dual-Booting Ubuntu 20.04 LTS from Windows

The following steps may or not be necessary prerequisites. If you find other important steps, have better tutorial links, or don't think something is necessary for certain Windows devices, please add your knowledge.

  1. Check if you have BitLocker by right clicking on the Windows icon on your taskbar and clicking on Disk Management. In the Disk Manager, check if any of your partitions (usually the largest one) say "BitLocker encrypted" on them. If so, you have BitLocker and should try to suspend it. If there is no option to suspend it, just make sure you can find your backup keys either on your Microsoft account or on a flash drive and you will be fine.
  2. Disable Fast Boot (You may need to enable or disable hibernate)
  3. Disable Secure Boot

For a tutorial on dual booting Ubuntu, read this page. Below is a summarized version of the tutorial:

Next, you should right click on your windows icon on your taskbar and then click on Disk Management. once the disk management window opens, you should look for the largest partition on your drive. Its size should also match up with the size of your C drive if you open File Explorer and go to My PC. Once you have identified this drive, right click on it and select Shrink Partition. This will open another window, that will allow you to select an amount to shrink the drive by. This will be the amount of space your Ubuntu install will have, so we recommend at least 50-60GB if possible. Enter your amount (in MB, so multiply GB by 1000) and then press Shrink Partition. Once this is complete, you should see a new partition at the end of your largest partition that is gray and says free space or unallocated.

Now you are ready to boot into your Ubuntu USB. Plug in your flash drive, then search "uefi" in the windows search bar. You should see an option pop up called "Change advanced startup options", click on this and then select Restart now. Once you see a blue screen labeled "Choose an option", select "Use a device" and then select the USB device corresponding to your flash drive (usually this will say something like UEFI and/or the brand name of your flashdrive, if it's not obvious which one to choose, just repeat this process and try them all). Your system should then reboot and you should see a black menu with a white selector bar, with various options relating to Ubuntu. Press enter to select the first option.

The Ubuntu installer will then boot up on your computer. When asked whether you'd like a trial or full version of Ubuntu, select the full version, then follow the prompts. Choose normal (not minimal) installation, do not connect to wifi, and do not select to install 3rd party software. Once you reach the page labeled "Installation Type" choose the "Something else" option. Then select the partition labeled "free space" that corresponds to about the same size that you freed up in the Windows Disk Manager. Right click on this partition and choose add (or press the plus button in the bottom left). Change the mount point to "/" and then choose Ok. Finally, click install now. It will warn you that some partition is going to be modified, double check that it's the correct one that you freed up in Windows. If you have any confusion about this part, read the tutorial linked above or feel free to ask a lead or other member who has done this before. Once this is done, follow the rest of the prompts until Ubuntu is installed.

Now that Ubuntu is installed, to switch between Ubuntu and Windows all you have to do is restart your computer. When it boots up, it should show the same black menu with the white selector bar. Use the arrow keys to select either Ubuntu or Windows Boot Manager, depending on which operating system you want to use.

If you need to make your own bootable flash drive, follow this link to download the desktop image of Ubuntu 20.04, and download Rufus (use the "Rufus 3.20" button in bold gray text).

After everything is set up and you're getting familiar with Ubuntu, you can update drivers like so:

  1. Search (by pressing the windows key) for "update manager" and select "software updater".
  2. When a box says your computer is up to date, click settings.
  3. Open the Additional Drivers tab.
  4. Look for a proprietary, tested driver. If one exists, select it and click "Apply changes".

If you can't get audio to work, open the terminal and enter sudo alsa force-reload.

Again, please update this section if you come across anything else that needs to be done for dual booting from Windows.

Install ROS Natively

This is the recommended way to install ROS, and the only one we will guarantee full support for.

Option 1 - Install Script (newer to Linux)

Run python3 -c "$(wget https://raw.githubusercontent.com/umrover/mrover-ros/master/install.py -O-)" from the Ubuntu terminal and follow along. Make sure to actually read what's happening so you can learn!

Once the script completes, run the following:

cd ~/catkin_ws/src/mrover
source /opt/ros/noetic/setup.bash
catkin build
source ~/catkin_ws/devel/setup.bash

To automatically run the source commands each terminal session run:

Global ROS environment: echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

MRover ROS environment: echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

Option 2 - Manual Install (familiar with Linux)

First, add ROS to your package repositories and install base ROS packages:

sudo apt install curl git git-lfs python3-pip -y
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update -y
sudo apt install ros-noetic-desktop python3-catkin-tools python3-rosdep -y

Add the latest versions of NodeJS and yarn to your package repositories as well

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update -y

Then create a catkin workspace directory called "catkin_ws" in your home directory, and clone the MRover repo into it (this doesn't have to be called "catkin_ws" and it doesn't have to be directly in your home directory, but these are the standards we use). Then you will have to rename the repo from "mrover-ros" to "mrover" to align with the package name:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/umrover/mrover-ros.git mrover

Next you need to initialize your catkin workspace:

cd ~/catkin_ws
source /opt/ros/noetic/setup.bash
catkin init

Note: If you are using zsh instead of bash (like a boss) source setup.zsh instead

Sourcing setup.bash gives your current terminal session access to ROS resources. If you want this done automatically for you add the following to your .bashrc file (which gets run every time you open a new bash terminal) by running this command:

echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

Now use rosdep to install all necessary dependencies:

sudo rosdep init
rosdep update
rosdep install --from-paths ~/catkin_ws/src/ --ignore-src -y --rosdistro=noetic

Now build:

cd ~/catkin_ws
catkin build

Now that your catkin workspace is ready, you need to source the ROS setup files:

source ~/catkin_ws/devel/setup.bash

This needs to be done every time you open a new terminal session.

You can also automatically source for this setup.bash as well, although this isn't necessarily recommended since it changes environment variables that could cause issues when you work on other things outside of rover. This only causes issues in some special cases, so if you aren't worried about it, feel free to add the second source to your bashrc file. If this is something you want to avoid, you can at least add a shorter command as an 'alias' to run when you open your terminal:

echo "alias source_mrover='source ~/catkin_ws/devel/setup.bash'" >> ~/.bashrc

Then you will only have to enter source_mrover each time you open a terminal for rover.

Docker (Alternative to native install)

View Instructions
Docker is a platform for containers. Containers are essentially a way to package the userspace of an operating system and ship it. By using containers, you can avoid having to manually install dependencies and set up the environment. Instead, you will essentially use a copy of our development environment.

Install ROS through Docker on Linux

First pull the auton Docker image from Docker Hub.

docker pull umrover1/ros:auton

Then create a catkin workspace directory called "catkin_ws" in your home directory, and clone the MRover repo into it (this doesn't have to be called "catkin_ws" and it doesn't have to be directly in your home directory, but these are the standards we use). Then you will have to rename the repo from "mrover-ros" to "mrover" to align with the package name.

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/umrover/mrover-ros.git mrover

If instead, you already have a catkin workspace with the MRover repo in it, you will need to effectively reset your catkin workspace by deleting everything but the src directory. This is necessary because the paths initialized by catkin when running catkin init locally will no longer work once your catkin workspace is mounted to the Docker container.

cd ~/catkin_ws
rm -rf devel/ build/ .catkin_tools/ logs/

Now you can run the Docker container with your catkin workspace mounted to it, and open a bash shell inside of it

docker run -it --name ros_auton --env="DISPLAY" --volume=/home/${USER}/catkin_ws/:/mnt/ --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --privileged umrover1/ros:auton bash

Once you are inside the Docker container, you will need to initialize (or reinitialize) and build your catkin workspace, which is now located in the /mnt folder

cd /mnt
catkin init
catkin build

Now that your catkin workspace is ready, you need to source the ROS setup files. you will need to do this every time you open a new terminal session inside the Docker container

source /opt/ros/noetic/setup.bash
source /mnt/devel/setup.bash

To open additional terminal sessions in the same Docker container, run

docker exec -it ros_auton bash

or use a terminal multiplexer like tmux.

Setup MRover codebase

To run a quick sanity test, try roslaunch mrover full.launch. RViz should pop up and no red errors should be present in console.

You can also run rosrun teleop_twist_keyboard teleop_twist_keyboard.py on a new terminal to move the robot around.

Clone this wiki locally