In this post, we will get started with ROS, the Robot Operating System. ROS is the most popular robot programming platform. The reason it is so popular is that it is free, open-source, and has a ton of pre-written code that you can use for your robotics project. Sure you could write everything from scratch, but why reinvent the wheel? ROS saves you time from having to write code for common robot capabilities like navigation, motion planning, path planning, perception, control, and manipulation. It also has a huge worldwide community.
You Will Need
In order to complete this tutorial, you will need:
- Ubuntu installed and running properly (I’m running my Ubuntu in a VirtualBox on Windows 10)
Directions
The official steps for installing ROS are at this link at ROS.org, but I will walk you through the process below so that you can see what each step should look like.
As of the time of this writing, the latest version with long term support (LTS) of ROS is ROS Melodic Morenia. Select that option.
I am using Ubuntu, so I will click on the Ubuntu option, which will land me on this page.
Click the 9 white dots at the bottom left of your screen.
Search for Software & Updates. Then click on it.
Make sure main, universe, restricted, and multiverse are all checked. Then click Close.
Now open up a new terminal window, and type (or copy and paste) the following command:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
The command above sets your computer up to accept software from packages.ros.org.
Now we need to set up the secure keys so that our system accepts what we are going to download.
For the next step, update the package list on your system.
sudo apt update
Now type:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Now do a full desktop install of ROS. At the time of this writing, the latest version is ROS Melodic Morenia. The command below installs all the software, tools, algorithms, and robot simulators for ROS. After you type the command and press Enter, press Y and hit Enter when asked if you want to continue. It will take a while to download all this stuff, so feel free to take a break while ROS downloads to your system.
sudo apt install ros-melodic-desktop-full
Now initialize rosdep. This is a tool that is required before you can use ROS.
sudo rosdep init
rosdep update
Set up the environment variables.
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Note that anytime you want to see what environment variables ROS is using, you can type the following command:
export | grep ROS
This command will show you the ROS distribution you are using, the version of Python ROS is using, and a bunch of other stuff.
The two key variables are as follows:
- ROS_MASTER_URI: Shows the URL where the roscore is in execution. This is often your own local computer.
- ROS_PACKAGE_PATH: Shows the path on your computer where the ROS packages are.
Install some other tools that you will work with in ROS. After you type the command below, press Y and Enter to complete the download process.
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Here is the last step of the installation process. Check which version of ROS you have installed. If you see your ROS version as the output, congratulations you have successfully installed ROS!
rosversion -d
ROS has a lot of new vocabulary (e.g nodes, bags, topics). So before you start working with ROS, I recommend you bookmark (no need to read in detail) this page at the ROS Wiki which covers the new vocabulary associated with ROS. That way, when I mention a term you might not understand, you know where to look it up.