Book Image

Robot Operating System Cookbook

By : Kumar Bipin
Book Image

Robot Operating System Cookbook

By: Kumar Bipin

Overview of this book

This book will leverage the power of ROS with an introduction to its core and advanced concepts through exciting recipes. You will get acquainted with the use of different synchronous and asynchronous communication methods, including messages, services, and actions. You will learn how to use the various debugging and visualization tools used in development and how to interface sensors and actuators with the ROS framework. Firstly, you will get to grips with ROS simulation frameworks, such as Gazebo and RotorS for modeling and simulating any physical robot and virtual environment. You will also cover mobile robotics, micro-aerial vehicles, and robotic arms, which are the leading branches of robotic applications. Robot Operating System Cookbook will also guide you in the development of an autonomous navigation framework for both mobile robots and micro-aerial vehicles. Finally, you will explore ROS-Industrial, an open source project that extends the advanced capabilities of ROS software to manufacturing industries.
Table of Contents (12 chapters)

Installing the ROS packages

Before the installation of the ROS packages, make sure our Debian package index is up-to-date:

$ sudo apt-get update

There are many different libraries and tools in ROS—not all compile fully on ARM. So, it is not possible to make a full desktop installation. We should install ROS packages individually.

We could install ros-base (Bare Bones), which includes the ROS package, build, and communication libraries, but does not include GUI tools (press ENTER (Y) when prompted):

$ sudo apt-get install ros-<ros_version>-ros-base

However, we could try to install the desktop installation, which includes the ROS, rqt, RViz, and robot-generic libraries:

$ sudo apt-get install ros-<ros_version>-desktop

Adding individual packages

We can install a specific ROS package:

$ sudo apt-get install ros-<ros_version>-PACKAGE

Find available packages with the following command:

$ apt-cache search ros-<ros_version>

Initializing rosdep

The rosdep command-line tool must be installed and initialized before we can use ROS. This allows us to easily install libraries and solve system dependencies for the source we want to compile, and is required to run some core components in ROS:

$ sudo apt-get install python-rosdep $ sudo rosdep init $ rosdep update

Environment setup

Well done! We have completed the ROS installation for the ARM platform. The ROS scripts and executables are mostly installed in /opt/ros/<ros_version>.

To get access to these scripts and executables, the ROS environment variables need to be added to the bash session. We have to source the following bash file:

$ source /opt/ros/<ros_version>/setup.bash

It's convenient if the ROS environment variables are automatically added to the bash session every time a new shell is launched:

$ echo "source /opt/ros/<ros_version>/setup.bash" >> ~/.bashrc
$ source ~/.bashrc

If we have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version we are currently using:

$ source /opt/ros/<ros_version>/setup.bash

Getting rosinstall

rosinstall is a frequently used command-line tool in ROS that is distributed separately. It enables us to easily download several source trees for the ROS packages with a single command.

This tool is based on Python and can be installed using the following command:

$ sudo apt-get install python-rosinstall

As a basic example, we could run an ROS core on one terminal:

$ roscore

And from another terminal, we can publish a pose message:

$ rostopic pub /dummy geometry_msgs/Pose Position: x: 3.0 y: 1.0 z: 2.0 Orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 -r 8

Moreover, we could set ROS_MASTER_URI on our desktop system (in the same network) to point to our ARM Platform (IP 192.168.X.X).

On your laptop, add the following:

$ export ROS_MASTER_URI=http://192.168.1.6:11311

And, we will see pose published from the ARM platform to our laptop.

On your laptop, add the following:

$ rostopic echo -n2 /dummy Position: x: 1.0 y: 2.0 z: 3.0 Orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 ---