We recently got an email from our reader about ROS and how to get started with ROS. So we decided to blog on this query by bringing an easy guide to install ROS along with a small introduction to ROS.
What is ROS?
According to the website for ROS, "The Robot Operating System (ROS) is a flexible framework for writing robot software.
It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behaviour across a wide variety of robotic platforms".
ROS supports various robots and a complete list of supported robots is at the site http://robots.ros.org/
ROS is open source and you can build your own robot using ROS. ROS supported hardware. ROS supports simulators like the Gabezo.
Accoring to ROS site , Gazebo is a 3D indoor and outdoor multi-robot simulator, complete with dynamic and kinematic physics, and a pluggable physics engine. Integration between ROS and Gazebo is provided by a set of Gazebo plugins that support many existing robots and sensors.
ROS also supports computer vision with OpenCV integration as well.
Why we need ROS apart from a Single board computer or a microcontroller?
There can be many reasons for this depending on the use case of the robot you are making. But if we take a very general approach then we can state that after a certain stage integration becomes very tough with just a combination of microcontroller and Single Board computer.
The Robot Operating System (ROS) is a flexible framework for writing robot software
ROS provides many advantages when it comes to complicated robots like modularity, message passing, publish and subscribe system, robot specific libraries and tools, URDF and much more.
In case you are interested in reading more about ROS then we suggest the below links for the ROS site.
Installation approach in this blog:
We would use a Windows Laptop to create a Ubuntu virtual environment and then install ROS in the Ubuntu environment.
Prerequisites for installation:
1. You would need a Windows laptop with at least 40 GB free, Core i5 and with a 4 GB RAM. Just to benchmark, this blog uses an Acer Laptop with Intel Core i5, 4 GB Video RAM, 8 GB DDR4 memory. You may struggle with lower RAM or processor.
Please note if you already have a Ubuntu laptop then there is no need for the Oracle VM installation. Move directly into the ROS installation section.
2. You would need to install Oracle Virtual Machine.
we can state that after a certain stage integration becomes very tough with just a combination of microcontroller and Single Board computer
3. Have a decent unlimited internet connection. This blog to implement would need an internet connection.
4. Loads of patience and some background in Unix commands. If you are totally new to Unix commands please do not attempt this installation.
5. Keep a time of 4-6 hours for this work and you may need troubleshooting so please do not do this installation when you don't have enough time in hand. If you are used to Ubuntu Opensource installation you would take less time.
6. This blog uses Ubuntu 14.04 to install ROS Indigo. Please note a lot of steps may change if you change the ROS/ Ubuntu version. This blog may not work for other version combination.
Please read this link on Ubuntu ROS version if you are not sure.
Please note that unix commands are shown in Green in this blog for easy copy paste and identification.
Once the installation is completed we will test this by running the ROS core and also running the famous Gazebo simulator.
Installation of the Oracle Virtual Box side: (not shown in details):
1. Download Oracle Virtual Box setup from this link.
2. Create a new Linux VM and choose 64 bit
3. Allocate at least 20 GB hard drive space, we allocated 40 GB in this blog
4. Allocate 2 GB virtual memory size, you may do higher as well
5. In hard disk file type choose the first option which says VDI virtual box disk image
6. Storage on physical hard drive select as 'dynamically allocated'
7. Download the Ubuntu disk image which would be used for installation and first-time boot from the link http://releases.ubuntu.com/14.04/
Choose the one that is right for your laptop as shown in RED circles above.
Please note that we used a 64-bit laptop. If you have a 32-bit machine then download the 32-bit machine and make sure your Oracle VM box is 32 bit as well (step 2).
The below image is the installation we did for this blog. The red highlights are the key parameters we talked above.
8. Click start and follow the instruction. Please select the installation option and not 'Try Ubuntu'
9. Follow the onscreen instruction to set language, password and time zone and wait for the installation to complete.
Depending on your laptop and internet speed this may take some time. For our case, it took 30 minutes.
10. Restart the Ubuntu set up and log in with your password provided. Please make sure you do a 'normal start' and not headless.
11. Move to Ubuntu software centre and click the tab called as Ubuntu software and make sure all checkboxes are checked as per the image below.
This allows different software repositories to be allowed to be installed. If all the check boxes are already check then click ok and come out of the software center dialog.
For further guidance refer the link at the end of the blog. There is a good Wiki how as well in the below link for Ubuntu installations.
You are done with the Ubuntu installation now and as mentioned in the installation approach we will install ROS over this Ubuntu environment.
ROS installation over Ubuntu:
In this section, we would install ROS over the Ubuntu version installed. Please make sure you have unlimited internet plan as you proceed to the next step.
1. Set up source list and keys by copy paste the below two commands from the command line.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu
$(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
get http://packages.ros.org/ros.key -O - | sudo apt-key add -
In case there is a password asked used the password provided for login/Sudo command. (Admin).
2. Update the software with a sudo update. DONOT SKIP THIS STEP.
sudo apt-get update
3. ROS provides 3 types of installation and in this blog we will use the full version as we need all features of ROS.
sudo apt-get install ros-indigo-desktop-full
4. We would need to take care of any dependencies and hence we will use rosedep.
sudo rosdep init
If you get any warnings in this step please ignore and move to the next step of the update. You should update even if you don't get any warnings.
5. We now need to set up environment variables and we need two commands as below.
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
sudo apt-get install python-rosinstall
We are now done with ROS installation but we need to complete the work scope.
Workscape creation with catkin:
catkin is the Official build system for ROS. A build system is responsible for generating 'targets' from raw source code that can be used by an end user.
These targets may be in the form of libraries, executable programs, generated scripts, exported interfaces (e.g. C++ header files) or anything else that is not static code. In ROS terminology, the source code is organised into 'packages' where each package typically consists of one or more targets when built.
You can read more about catkin at the below link.
1. Ok now let us see how can we get the catkin done by below commands.
mkdir -p ~/catkin_ws/src
You can type ls now in the catkin path and check the below to confirm. You would see build, devel and src as shown below.
2. We then complete the below commands to add catkin on top of our ROS package.
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
3. We finally check the ROS environment variables as below.
export | grep ROS
If you get any errors make sure you have taken care of dependencies. Please ensure catkin is deployed else you will face problems in later steps and using ROS.
Well done! we are done with all installations and now we need to test it.
1. Type roscore and see if you can see the core session as shown in the below image. Press CRTL + c to log off from roscore
2. To test gazebo simply type gazebo. This would call the Gazebo as shown below.
Please wait for some time as Gazebo may take some time to load and you should see something as below called as a 'scene'.
Congratulations you have installed ROS over Ubuntu and also tested the core and gazebo. You are now good to start learning ROS. Also, our 'mantras' for ROS in this podcast.
If you face problems the good thing is ROS has an answers and wiki at the below links.