Welcome to the first chapter of this section, where you will learn how to install ROS, the new standard software framework in robotics. This section is an update on Learning ROS for Robotics Programming - Second Edition, based in ROS Hydro/Indigo. With ROS, you will learn how to program and control your robots the easy way, using tons of examples and source code that will show you how to use sensors and devices, or how to add new functionalities, such as autonomous navigation, visual perception, and others, to your robot. Thanks to the open source ethos and a community that is developing state-of-the-art algorithms and providing new functionalities, ROS is growing every day.
This section will cover the following topics:
- Installing ROS Kinetic framework on a compatible version of Ubuntu
- The basic operation of ROS
- Debugging and visualizing data
- Programming your robot using this framework
- Connecting sensors, actuators, and devices to create your robot
- Using the navigation stack to make your robot autonomous
In this chapter, we are going to install a full version of ROS Kinetic in Ubuntu. ROS is fully supported and recommended for Ubuntu, and it is experimental for other operative systems. The version used in this section is the 15.10 (Wily Werewolf), and you can download it for free from http://releases.ubuntu.com/15.10. Note that you can also use Ubuntu 16.04 (Xenial), following the same steps shown here; indeed, for the BeagleBone Black installation we will use Ubuntu Xenial.
Before starting with the installation, we are going to learn about the origin of ROS and its history.
The Robot Operating System (ROS) is a framework that, nowadays, is widely accepted and used in the robotics community. Its main goal is to make the multiple components of a robotics system easy to develop and share so they can work on other robots with minimal changes. This basically allows for code reuse, and improves the quality of the code by having it tested by a large number of users and platforms. ROS was originally developed in 2007 by the Stanford Artificial Intelligence Laboratory (SAIL) in support of the Stanford AI Robot project. Since 2008, Willow Garage continued the development, and recently Open Source Robotics Foundation (OSRF) began to oversee the maintenance of ROS and partner projects, like Gazebo, including the development of new features.
A lot of research institutions have started to develop in ROS, adding hardware and sharing their code. Also, companies have started to adapt their products to be used in ROS. In the following set of images, you can see some of the platforms that are fully supported. Normally, these platforms are published with a lot of code, examples, and simulators to permit the developers to start work easily. The first three humanoid robots are examples of robots with published code. The last one is an AUV developed by the University of Las Palmas de Gran Canaria, and the code has not been published yet. You can find many other examples at http://wiki.ros.org/Robots.
Most of the sensors and actuators used in robotics are supported by ROS as drivers.
Furthermore, some companies benefit from ROS and open hardware to create cheaper and easier to use sensors, as existing software can be used for them at zero cost. The Arduino board is a good example because you can add many different kinds of sensors to this cheap electronic board, such as encoders, light and temperature sensors, and many others, and then expose their measurements to ROS to develop robotic applications.
ROS provides a hardware abstraction, low-level device control with ROS control, implementations of commonly used functionalities and libraries, message passing between processes, and package management with
It uses graph architecture with a centralized topology, where processing takes place in nodes that may receive and send messages to communicate with other nodes on the graph net. A node is any process that can read data from a sensor, control an actuator, or run high level, complex robotic or vision algorithms for mapping or navigating autonomously in the environment.
*-ros-pkg is a community repository for developing high-level libraries easily. Many of the capabilities frequently associated with ROS, such as the navigation library and the rviz visualizer, are developed in this repository. These libraries provide a powerful set of tools for working with ROS easily; visualization, simulators, and debugging tools are among the most important features that they have to offer. In the following image you can see two of these tools, the rviz and rqt_plot. The screenshot in the center is rqt_plot, where you can see the plotted data from some sensors. The other two screenshots are rviz; in the screenshot you can see a 3D representation of a real robot.
ROS is released under the terms of the Berkeley Software Distribution (BSD) license and is an open source software. It is free for commercial and research use. The
ros-pkg contributed packages are licensed under a variety of open source licenses.
With ROS, you can take a code from the repositories, improve it, and share it again. This philosophy is the underlying principle of open source software.
ROS has numerous versions, the last one being Indigo. In this section, we are going to use Kinetic because it is the latest version. Now we are going to show you how to install ROS Kinetic. As we mentioned before, the operating system used in the section is Ubuntu, and we are going to use it throughout this section and with all the tutorials. If you use another operating system and you want to follow the section, the best option is to install a virtual machine with a copy of Ubuntu. At the end of this chapter, we will explain how to install a virtual machine to use the ROS inside it, or download a virtual machine with ROS installed.
If you want to try installing it on an operating system other than Ubuntu, you can find instructions on how to do so with many other operating systems at http://wiki.ros.org/kinetic/Installation.
We assume that you have a PC with a copy of Ubuntu 15.10. It will also be necessary to have a basic knowledge of Linux and command tools such as the terminal, Vim, folder creation, and so on. If you need to learn these tools, you can find a lot of relevant resources on the Internet, or you can find books on these topics instead.
Last year, the ROS web page was updated with a new design and a new organization of contents. The following is a screenshot of the web page:
In the menu, you can find information about ROS and whether ROS is a good choice for your system. You can also find blogs, news, and other features.
Instructions for ROS installation can be found under the
Install tab in the
Getting Started section.
ROS recommends that you install the system using the repository instead of the source code, unless you are an advanced user and you want to make a customized installation; in that case, you may prefer installing ROS using the source code.
To install ROS using the repositories, we will start by configuring the Ubuntu repository in our system.
In this section, you will learn the steps for installing ROS Kinetic in your computer. This process has been based on the official installation page, which can be found at http://wiki.ros.org/kinetic/Installation/Ubuntu.
We assume that you know what an Ubuntu repository is and how to manage it. If you have any doubts about it, refer to https://help.ubuntu.com/community/Repositories/Ubuntu.
Before we start the installation, we need to configure our repositories. To do that, the repositories need to allow
multiverse. To check if your Ubuntu accepts these repositories, click on
Ubuntu Software Center in the menu on the left-hand side of your desktop, as shown in the following screenshot:
Software Sources and you will see the following window. Make sure that all the listed options are checked as shown in the following screenshot (choose the appropriate country for the server from which you download the sources):
Normally these options are marked, so you should not have any problem with this step.
In this step, you have to select your Ubuntu version. It is possible to install ROS Kinetic in various versions of the operating system. You can use any of them, but we recommend version 15.10 to follow the chapters of this section. Keep in mind that Kinetic works in the Wily Werewolf (15.10) and Xenial Xerus (16.04) versions of Ubuntu. Type the following command to add the repositories:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros-latest.list'
Downloading the example code:
Detailed steps to download the code bundle are mentioned in the Preface of this section. Please have a look.
The code bundle for the section is also hosted on GitHub at https://github.com/rosbook/effective_robotics_programming_with_ros. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
This step is to confirm that the origin of the code is correct and that no one has modified the code or programs without the knowledge of the owner. Normally, when you add a new repository, you have to add the keys of that repository, so it's added to your system's trusted list.
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
Now we can be sure that the code came from an authorized site and has not been modified.
We are ready to start the installation now, but before we do that, we'd better make an update to avoid problems with the libraries and versions of software that are not ideal for ROS. This is done with the following command:
$ sudo apt-get update
ROS is huge; sometimes you will install libraries and programs that you will never use. Normally it has four different installations, but this depends on the final use. For
example, if you are an advanced user, you might only need the basic installation for a robot without much space on the hard disk. For this section, we recommend you use the full installation because it will install everything necessary to practice the examples and tutorials.
It doesn't matter if you don't know what are you installing right now — rviz, simulators, navigation, and so on. You will learn everything in the upcoming chapters:
- The easiest (and recommended if you have enough hard disk space) installation is known as
desktop-full. It comes with ROS, the rqt tools, the rviz visualizer (for 3D), many generic robot libraries, the simulator in 2D (like a stage plan) and 3D (usually Gazebo), the navigation stack (to move, localize, do mapping, and control arms), and also perception libraries using vision, lasers, or RGBD cameras:
$ sudo apt-get install ros-kinetic-desktop-full
- If you do not have enough disk space, or if you prefer to install only a few packages, install only the desktop install initially, which only comes with ROS, the rqt tools, rviz, and generic robot libraries. You can install the rest of the packages as and when you need them, for example, by using
aptitudeand looking for
ros-kinetic-*packages with the following command:
$ sudo apt-get install ros-kinetic-desktop
- If you only want the bare bones, install ROS-base, which is usually recommended for the robot itself, or for computers without a screen or just a TTY. It will install the ROS package with the build and communication libraries and no GUI tools at all. With BeagleBone Black (BBB), we will install the system with the following option:
$ sudo apt-get install ros-kinetic-ros-base
- Finally, whichever of the previous options you choose, you can also install individual/specific ROS packages (for a given package name):
$ sudo apt-get install ros-kinetic-PACKAGE
Before using ROS we need to initialize
rosdep command-line tool helps with the installation of system dependencies for the source code that we are going to compile or install. For this reason, it is required by some of the core components in ROS, so it is installed by default with it. To initialize
rosdep, you have to run the following commands:
$ sudo rosdep init $ rosdep update
Congratulations! If you are at this step, you have an installed version of ROS on your system! To start using it, the system needs to know the location of the executable or binary files, as well as the other commands. To do this, normally you need to execute the next script; if you also install another ROS distro, you can work with both just by calling the script of the one you need each time, since this script simply sets your environment. Here, we use the one for ROS Kinetic, but just replace
jade, for example, if you want to try other distros:
$ source /opt/ros/kinetic/setup.bash
If you type
roscore in the shell, you will see something starting up. This is the best test for finding out if you have ROS, and if it is installed correctly.
Note that if you open another terminal you also have to source the
setup.bash file to set the environment variables to detect the ROS packages installed on your system. Otherwise,
roscore or other ROS commands will not work. This is because the script must be sourced again to configure the environment variables, which include the path where ROS is installed, as well as other packages and additional paths for compiling new code properly.
It is very easy to solve this; you just need to add the script at the end of your
.bashrc script file so that when you start a new shell, the script will execute and you will have the environment configured.
.bashrc file is within the user home (
/home/USERNAME/.bashrc). It has the configuration of the shell or terminal, and each time the user opens the terminal, this file is loaded. That way, you can add commands or configuration to make the user's life easy. For this reason, we will add the script at the end of the
.bashrc file to avoid keying it in each time we open a terminal. We do this with the following command:
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
To see the results, you have to execute the file using the following command, or close the current terminal and open another:
$ source ~/.bashrc
Some users need more than a single ROS distribution installed in their system, so you'll have several distros living in the same system and may need to switch between them. Your
~/.bashrc file must only source the
setup.bash file of the version you are currently using, since the last call will override the environment set by the others.
For example, you might have the following lines in your
… source /opt/ros/indigo/setup.bash source /opt/ros/jade/setup.bash source /opt/ros/kinetic/setup.bash …
The ROS Kinetic version will be executed in this case. Make sure that the version you are running is the last one in the file. It's also recommended to source a single
If you want to check the version used in a terminal, you can do so easily running the
echo $ROS_DISTRO command.
Now the next step is to install a command tool that will help us install other packages with a single command. This tool is based in Python, but don't worry, you don't need to know Python to use it. You will learn how to use this tool in the upcoming chapters:
To install this tool on Ubuntu, run the following command:
$ sudo apt-get install python-rosinstall
And that's it! You have a complete ROS system installed in your system. When I finish a new installation of ROS, I personally like to test two things: that
turtlesim both work.
If you want to do the same, type the following commands in different shells:
$ roscore $ rosrun turtlesim turtlesim_node
VirtualBox is a general-purpose, full virtualizer for x86 hardware, targeted at server, desktop, and embedded use. VirtualBox is free and supports all the major operating systems and pretty much every Linux flavor out there.
If you don't want to change the operating system of your computer to Ubuntu, tools such as VirtualBox help us virtualize a new operating system in our computers without making any changes.
In the following section, we are going to show you how to install VirtualBox and a new installation of Ubuntu. After this virtual installation, you should have a clean installation for restarting your development machine if you have any problems, or to save all the setups necessary for your robot in the machine.
The first step is to download the VirtualBox installation file. The latest version at the time of writing this section is 4.3.12; you can download the Linux version of it from http://download.virtualbox.org/virtualbox/4.3.12/. If you're using Windows, you can download it from http://download.virtualbox.org/virtualbox/4.3.12/VirtualBox-4.3.12-93733-Win.exe.
Once installed, you need to download the image of Ubuntu; for this tutorial we will use a copy of Ubuntu 15.10 from OSBOXES found at http://www.osboxes.org/ubuntu/; then we will simply install ROS Kinetic following the same instructions described in the previous section. In particular, the Ubuntu 15.10 image can be downloaded from http://sourceforge.net/projects/osboxes/files/vms/vbox/Ubuntu/15.10/Ubuntu_15.10-64bit.7z/download.
This would download a
.7z file. In Linux, it can be uncompressed with the following:
$ 7z x Ubuntu_15.10-64bit.7z
.7z command is not installed, it can be installed with the following:
$ sudo apt-get install p7zip-full
The virtual machine file will go into the 64-bit folder with the name:
Ubuntu 15.10 Wily (64bit).vdi
Creating a new virtual machine with the downloaded file is very easy; just proceed with the following steps. Open VirtualBox and click on
New. We are going to create a new virtual machine that will use the
Ubuntu 15.10 Wily (64bit).vdi file downloaded before, which is a hard disk image with Ubuntu 15.10 already installed.
Set the name, type, and version of the virtual machine as shown in the following screenshot:
You can configure the parameters of the new virtual machine in the windows that follow. Keep the default configuration and change only the name for the virtual system. This name is how you distinguish this virtual machine from others. For the RAM, we advise that you use as much as possible, but 8 GB should be enough.
When you finish these steps, install ROS Kinetic as you would on a regular computer following the steps of the previous sections, and you will have a full copy of ROS Kinetic that can be used with this section.
Docker is an open platform that helps to distribute applications and complete systems. In some ways, it is similar to a virtual machine, but it is much faster and more flexible; see https://www.docker.com or https://dockerproject.org for more information.
$ sudo apt-get install docker.io
Docker images are like virtual machines or systems already set up. There are servers that provide images like this, so the users only have to download them. The main server is Docker hub, found at https://hub.docker.com. There, it is possible to search for Docker images for different systems and configurations. In our case, we are going to use ROS Kinetic images already available. All ROS Docker images are listed in the official ROS repo images on the web at https://hub.docker.com/_/ros/. The ROS container image is pulled down with the following command:
$ docker pull ros
There's a possibility that you may see this error:
You should either update your system or try adding your user to the
docker group to resolve this:
$ sudo usermod -a -G docker $(whoami)
You should see multiple Docker images getting downloaded simultaneously. Each image has a different hash name. This will take some time, especially on slow networks. You will see something like the following once it is done:
The ROS Kinetic distribution can be pulled down using the corresponding tag, using the following command:
$ docker pull ros:kinetic-robot
Although you do not need to know it, the images and containers are stored by Docker in
/var/lib/docker by default.
Once the container is downloaded, we can run it interactively with the following command:
$ docker run -it ros
This will be like entering a session inside the Docker container. This command will create a new container from the main image. Inside it we have a full Ubuntu system with ROS Kinetic already installed. We can install additional packages and run ROS nodes, as in a regular system. With
docker ps -a, you can check all the containers available and the image they come from.
We have to set up the ROS environment inside the container in order to start using ROS. That is, we have to run the following command:
$ source /opt/ros/kinetic/setup.bash
Docker containers can be stopped from other terminals using
docker stop, and they can also be removed with
docker rm. Docker also allows you to configure the container to expose the network, as well as mounting a host folder as volumes into it. In addition to this, it also supports a Python API, and has many other features. All this can be found in the official documentation at https://docs.docker.com. However, in principle,
docker run should be enough, and we can even SSH into a running Docker container, as a regular machine, using its name. We can also open another terminal for a running container with the following command (where
NAME is the name of the Docker container, that you can fine using
docker ps -a):
$ docker exec -it NAME bash
You can also create your own Docker images using
docker build and specify what should be installed in them in
Dockerfile. You can even publish them online with
docker push, contributing them to the community or simply sharing your working setup. This section comes with a working Docker image and
Dockerfile to build it, and you can find this by running
docker build from the same folder where
Dockerfile is. This Docker image is basically an extension of the ROS Kinetic one with the code of the section. The instructions to download and install it would be on the GitHub repository with the rest of the code.
BeagleBone Black is a low-cost development platform based on an ARM Cortex A8 processor. This board is fabricated with a Linux distribution called Ångström. Ångström was developed by a small group who wanted to unify Linux distribution for embedded systems. They wanted an operating system that was stable and user-friendly.
Texas Instruments designed BeagleBone Black thinking that the community of developers needed an on-board computer with some general purpose input/output (GPIO) pins. The BeagleBone Black platform is an evolution of the original BeagleBone. The main features of the board are an ARM Cortex A8 processor at 1 GHz with 512 MB RAM, and with Ethernet, USB, and HDMI connections and two headers of 46 GPIO pins.
This GPIO can be set up as digital I/O, ADC, PWM, or for communication protocol like I2C, SPI, or UART. The GPIO is an easy way to communicate with sensors and actuators directly from the BeagleBone without intermediaries. The following is a labeled image of BeagleBone:
When the BeagleBone board came out, it was not possible to install ROS on the Ångström distribution. For this reason, it was common to install an operating system based on Ubuntu on the BeagleBone. There are different versions of Ubuntu ARM compatible with the BeagleBone Black and ROS; we recommend that you use an image of Ubuntu ARM 16.04 Xenial armhf on the platform to work with ROS.
Now, an ROS version for Ångström distribution is ready to be installed; you can do so following the installation steps given at http://wiki.ros.org/kinetic/Installation/Angstrom. Despite this possibility, we have chosen to install ROS on Ubuntu ARM because these distributions are more common and can be used on other ARM-based boards such as UDOO, ODROIDU3, ODROIDX2, or Gumstick.
ARM technology is booming with the use of mobile devices such as smartphones and tablets. Apart from the increasing computer power of the ARM cortex, the great level of integration and low consumption has made this technology suitable for autonomous robotic systems. In the last few years, multiple ARM platforms for developers have been launched in the market. Some of them have features similar to the BeagleBone Black, such as the Raspberry PI or the Gumstick Overo. Additionally, more powerful boards like GumstickDuoVero with a Dual Core ARM Cortex A9 or some quad core boards like OdroidU3, OdroidX2 or UDOO are now available.
Before installing ROS on BeagleBone Black, we have to achieve some prerequisites. As this section is focused on ROS, we will list them without going into detail. There is a lot of information about BeagleBone Black and Ubuntu ARM available on websites, forums, and books that you can check out.
First, we have to install an Ubuntu ARM distribution compatible with ROS, so an image of Ubuntu ARM is needed. You can obtain an Ubuntu 16.04 Xenial armhf using
wget with the following command:
$ wget https://rcn-ee.com/rootfs/2016-10-06/elinux/ubuntu-16.04.1-console-armhf-2016-10-06.tar.xz
Once the image is downloaded, the next step is installing it on a microSD card. First, unpack the image with the following commands:
$ tar xf ubuntu-16.04.1-console-armhf-2016-10-06.tar.xz $ cd ubuntu-16.04.1-console-armhf-2016-10-06
Insert a microSD of 2 GB or more on the card reader of your computer and install the Ubuntu image on it with the following setup script:
$ sudo ./setup_sdcard.sh --mmc DEVICE --dtb BOARD
In the preceding script,
DEVICE is the device where the microSD appears on the system, for example
BOARD is the board name. For the BeagleBone Black it would be
beaglebone. So, assuming the microSD is in
/dev/mmcblk0, and you are using a BeagleBone Black, the command would be as follows:
$ sudo ./setup_sdcard.sh --mmc /dev/mmcblk0 --dtb beaglebone
If you do not know the device assigned to the microSD, you can use the following command:
$ sudo ./setup_sdcard.sh --probe-mmc
Once we have Ubuntu ARM on our platform, the BeagleBone Black network interfaces must be configured to provide access to the network, so you will have to configure the network settings, such as the IP, DNS, and gateway.
Remember that the easiest way could be mounting the SD card in another computer and editing
Another easy way consists on using an Ethernet cable and running the DHCP client to obtain an IP address.
$ sudo dhclient eth0
For this, you need to boot up the BeagleBone Black with the microSD. For that, you need to keep the S2 button press before you power on the board, either with the DC or USB connector. After some minutes the system will show the login prompt. Log in with the user
ubuntu and password
temppwd (default ones) and then run the DHCP client command shown above with the Ethernet cable connected. Then, you can check the IP address assigned using (look at the
inet addr: value):
$ ifconfig eth0
- HDMI (with microHDMI adapter) cable to see terminal prompt on the screen during the network setup; after that we can SSH into the board
- Keyboard connected through USB
- Power supplied through the microUSB connector
- Ethernet cable to access the Internet, as explained so far
After setting up the network, we should install the packages, programs, and libraries that ROS will need. Now that the network is up, we can also SSH into the board with (assuming the IP address assigned to it is
$ ssh firstname.lastname@example.org
We are going to follow the instructions in http://wiki.ros.org/indigo/Installation/UbuntuARM, but with the changes required so they work for ROS kinetic (note they are still for indigo on the web). The first step consists on setting up the repository sources so we can install ROS.
$ sudo vi /etc/apt/sources.list
And add restricted to the sources, so you have something like this:
deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe multiverse #deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe multiverse deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe multiverse #deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe multiverse #Kernel source (repos.rcn-ee.com) : https://github.com/RobertCNelson/linux-stable-rcn-ee # #git clone https://github.com/RobertCNelson/linux-stable-rcn-ee #cd ./linux-stable-rcn-ee #git checkout `uname -r` -b tmp # deb [arch=armhf] http://repos.rcn-ee.com/ubuntu/ xenial main #deb-src [arch=armhf] http://repos.rcn-ee.com/ubuntu/ xenial main
Then, update the sources running:
$ sudo apt-get update
The operating system for BeagleBone Black is set up for micro SD cards with 1-4 GB. This memory space is very limited if we want to use a large part of the ROS Kinetic packages. In order to solve this problem, we can use SD cards with more space and expand the file system to occupy all the space available with re-partitioning.
So if we want to work with a bigger memory space, it is recommended to expand the BeagleBone Black memory file system. This process is further explained at http://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD.
- We need to become a super user, so we will type the following command and our password:
$ sudo su
- We will look at the partitions of our SD card:
$ fdisk /dev/mmcblk0
- On typing
p, the two partitions of the SD card will be shown:
- After this, we will delete one partition by typing
dand then we will type
2to indicate that we want to delete
$ d $ 2
- On typing
n, a new partition will be created; if we type
pit will be a primary partition. We will indicate that we want to number it as the second partition by typing
$ n $ p $ 2
- You can write these changes by typing w if everything is right, or eliminate the changes with Ctrl + Z:
- We should reboot the board after finishing:
- Once again, become a super user once the reboot is complete:
- Finally, run the following command to execute the expansion of the memory file system of the operating system:
$ resize2fs /dev/mmcblk0p2
Now we should be ready to install ROS. At this point, the process of installation is pretty similar to the PC installation previously explained in this chapter, so we should be familiar with it. We will see that the main difference when installing ROS on BeagleBone Black is that we can't install the ROS full-desktop; we must install it package by package.
$ sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX
After this, we will configure the source lists depending on the Ubuntu version that we have installed in BeagleBone Black. The number of Ubuntu versions compatible with BeagleBone Black is limited, and only active builds can be found for Ubuntu 16.40 Xenial armhf, the most popular version of Ubuntu ARM. Run the following to install the Ubuntu armhf repositories:
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
$ sudo apt-get update
This part of the installation is slightly different for the BeagleBone Black. There are a lot of libraries and packages in ROS, and not all of them compile fully on an ARM, so it is not possible to make a full desktop installation. It is recommended that you install them package by package to ensure that they will work on an ARM platform.
You can try to install ROS-base, known as ROS Bare Bones. ROS-base installs the ROS package along with the build and communications libraries but does not include the GUI tools (press ENTER (Y) when prompted):
$ sudo apt-get install ros-kinetic-ros-base
We can install specific ROS packages with the following command:
$ sudo apt-get install ros-kinetic-PACKAGE
If you need to find the ROS packages available for BeagleBone Black, you can run the following command:
$ apt-cache search ros-kinetic
For example, the following packages are the basics (already installed as ros-base dependencies) that work with ROS and can be installed individually using
$ sudo apt-get install ros-kinetic-ros $ sudo apt-get install ros-kinetic-roslaunch $ sudo apt-get install ros-kinetic-rosparam $ sudo apt-get install ros-kinetic-rosservice
Although, theoretically, not all the packages of ROS are supported by BeagleBone Black, in practice, we have been able to migrate entire projects developed on PC to BeagleBone Black. We tried a lot of packages, and the only one that we could not install was rviz, which is indeed not recommended to run on it.
rosdep command-line tool must be installed and initialized before you can use ROS. This allows you to easily install libraries and solve system dependencies for the source you want to compile, and is required to run some core components in ROS. You can use the following commands to install and initialize
$ sudo apt-get install python-rosdep $ sudo rosdep init $ rosdep update
If you have arrived at this step, congratulations, because you have installed ROS in your BeagleBone Black. The ROS environment variables can be added to your bash, so they will be added every time a shell is launched:
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc $ source ~/.bashrc
We have to be careful if we have more than one version of ROS in our system. The
bashrc setup must use the variables of the version being used only.
If we want to set up the environment in the current shell, we will run the following command:
$ source /opt/ros/kinetic/setup.bash
$ sudo apt-get install python-rosinstall
And from another terminal publish a pose message (note you can press TabTab after
geometry_msgs/Pose and it'd autocomplete the message fields, that then you need to change since it'd have the default values):
$ rostopic pub /dummy geometry_msgs/Pose Position: x: 1.0 y: 2.0 z: 3.0 Orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 -r 10
Now, from your laptop (in the same network), you can set
ROS_MASTER_URI to point to the BeagleBone Black (IP
192.168.1.6 in our case):
$ export ROS_MASTER_URI=http://192.168.1.6:11311
And now you should be able to see the pose published from the BeagleBone Black on your laptop doing:
$ rostopic echo -n1 /dummy Position: x: 1.0 y: 2.0 z: 3.0 Orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 ---
If you use a PoseStamped, you can even visualize it on rviz.
From this point, you can check multiple projects at http://wiki.ros.org/BeagleBone, as well as another installation option, which uses the Angstrom OS instead of Ubuntu, but it does not support ROS Kinetic at the moment.
In this chapter, we have installed ROS Kinetic on different physical and virtual devices (PC, VirtualBox, and BeagleBone Black) in Ubuntu. With these steps, you should have everything needed to start working with ROS installed on your system, and you can also practice the examples in this section. You also have the option of installing ROS using the source code. This option is for advanced users and we recommend you use only the installation from the apt repositories as it is more common and normally does not give any errors or problems.
It is a good idea to play around with ROS and its installation on a virtual machine. That way, if you have problems with the installation or with something else, you can reinstall a new copy of your operating system and start again.
Normally, with virtual machines, you will not have access to real hardware, such as sensors or actuators. In any case, you can use it for testing the algorithms.