Tag Archives: ROS

The Robot Operating System (ROS) is an open-source meta-operating system which provides essential features, namely hardware abstraction, low-level device control, implementation of environmental functionality, such as visualisation, simulation or testing and allows message-passing between concurrent running processes [O’K13]. Furthermore, it offers implementations of commonly used functionality in installable packages which even cover complex
algorithms like Simultaneous Localization and Mapping (SLAM) and Visual Object Recognition (VOR).

ROS moreover contains tools and libraries for obtaining, building, writing and running code across multiple heterogeneous computers and therefore includes language and platform independent tools. For example, ROS supports multiple client libraries, namely roscpp for C++ , rospy for Python , roslisp for Lisp and many others. It is also possible to link application-related code and external libraries like OpenCV for computer vision or Eigen3 for efficient linear algebra computation. Furthermore, ROS can successfully be wrapped around other frameworks like the Player Project .

ROS is mostly licensed free and has been developed as open source software under BSD Licence, which offers a variety of advantages for a low cost robot.

Unsurprisingly, with the high complexity of ROS there comes one of the highest learning curves of all robotic frameworks. Besides, due to rapid changes of main characteristics during different major versions, nearly all books and most tutorials on the internet became unreliable which is often very confusing for a beginner. But, after the top of the curve, a lot of things are self explanatory and complex features can be implemented very fast.

Unfortunately, another point to mention and one of the main disadvantages of ROS is the dependency on the ROS host and its Operating System (OS). In case you do not develop on a x86 32bit system a lot of automations do not work and require patience to be solved.
Especially, the support of packages on armhf , the ARM release repository, is not very usable, yet. Additionally, despite the importance of reactivity and low latency ROS is – like all other frameworks – no realtime OS.

ROS general terminology

ROS is a message-based concurrent running heterogeneous peer-to-peer network application. Its structure can be imagined as a mostly undirected graph with an obligatory center process node, called roscore . Broadly speaking, this one master node tracks every other part of the robotic network, including running processes and their interfaces. The centralistic design consequently uses its advantages by offering global debugging possibilities and error logging. It further mediates direct connections between every graph node on request. This becomes very useful in cases like image processing, where running traffic over the central node would impact the global system by increasing network usage and processing power.
Still simplifying, other parts of the graph are organized name spaces, called rosnodes , which in turn are containing more rosnodes or process edges called dependently on their function as rostopics or rosservices . A rosnode in a ROS environment therefore can be a robot, a processing server for navigation or even a human interaction device, like a laptop. Usually they physically do not cross the border of a single computing system, but often a single system can run multiple name spaces. Also, rosnodes profit from zero copy shared memory handling between their topics by using the ROS nodelet manager and by that significantly reduce
memory consumption. Every rosnode offers at least one rostopic , a multi-peer subscribable message provider, or a rosservice , a bidirectional unique connection between peers containing parameters.

ROS history

In 2007, the first robot running a version of ROS was STanford Artificial Intelligence Robot(STAIR) which was developed by Stanford Artificial Intelligence Laboratory (SAIL). During
that time ROS was called switchyard but already followed its main principles like inter-
process communication, concurrency and heterogeneous environments. After that, Willow Garage primarily developed ROS until February 2013. At this time ROS reached the critical-
mass, every open source project needs to survive without being mainly driven by external
funding. Since then the stewardship of ROS has been moved to the Open Source Robotics Foundation and subsequently left Willow Garage .
Major versions of ROS are called distributions and are named using adjectives that start
with with successive letters of the alphabet. Starting with box turtle , C Turtle , diamondback ,
electric , fuerte , groovy , hydro and finally Indigo , which is available since May 2014.

There are several ways to use ROS Indigo/Jade with a webcam. The one way working at most computer is using a ROS package called uvc_camera which has been created by Ken Tossell. UVC in this context stands for USB Video Class, which is a standard that covers almost all consumer webcams.

Unfortunately there currently is no step by step tutorial how to use the package, which is why I created this page. In order to run the package, you will need a local catkin workspace as we created it in another post. This is caused by the fact, that the available package is outdated and does not contain any launch files.

Step by Step Guide

We start by cloning the files into our workspace ./src directory, solving the dependencies with rosdep and finally building the workspace with catkin_make:

Shell

1

2

3

4

5

cd~/catkin_ws/src/#change directory to your source folder

git clonehttps://github.com/ktossell/camera_umd.git#clone the package from its repo

rosdep install camera_umd uvc_camera jpeg_streamer

cd..#go one dir up to catkin_ws

catkin_make#build the workspace

Before I could build my workspace with the newly cloned files, I still was required to install video4linux support libraries in their development version by:

Shell

1

sudo apt-getinstall libv4l-dev

After catkin_make finished you can launch the uvc_camera node by:

Shell

1

2

roscd uvc_camera/launch/

roslaunch./camera_node.launch

After having a roscore running, the camera_node.launch file should give you something like the following output:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

opening/dev/video0

pixfmt0='YUYV'desc='YUV 4:2:2 (YUYV)'

discrete:640x480:1/301/251/201/151/101/5

discrete:160x120:1/301/251/201/151/101/5

discrete:176x144:1/301/251/201/151/101/5

discrete:320x176:1/301/251/201/151/101/5

discrete:320x240:1/301/251/201/151/101/5

discrete:352x288:1/301/251/201/151/101/5

discrete:432x240:1/301/251/201/151/101/5

discrete:544x288:1/301/251/201/151/101/5

discrete:640x360:1/301/251/201/151/101/5

pixfmt1='MJPG'desc='MJPEG'

discrete:640x480:1/301/251/201/151/101/5

discrete:160x120:1/301/251/201/151/101/5

discrete:176x144:1/301/251/201/151/101/5

discrete:320x176:1/301/251/201/151/101/5

discrete:320x240:1/301/251/201/151/101/5

discrete:352x288:1/301/251/201/151/101/5

discrete:432x240:1/301/251/201/151/101/5

discrete:544x288:1/301/251/201/151/101/5

discrete:640x360:1/301/251/201/151/101/5

int(Brightness,0,id=980900):0to255(1)

int(Contrast,0,id=980901):0to255(1)

int(Saturation,0,id=980902):0to255(1)

bool(White Balance Temperature,Auto,0,id=98090c):0to1(1)

int(Gain,0,id=980913):0to255(1)

menu(Power Line Frequency,0,id=980918):0to2(1)

0:Disabled

1:50Hz

2:60Hz

int(White Balance Temperature,16,id=98091a):0to10000(10)

int(Sharpness,0,id=98091b):0to255(1)

int(Backlight Compensation,0,id=98091c):0to1(1)

menu(Exposure,Auto,0,id=9a0901):0to3(1)

int(Exposure(Absolute),16,id=9a0902):1to10000(1)

bool(Exposure,Auto Priority,0,id=9a0903):0to1(1)

Setting auto_focus isnotsupported

Setting focus_absolute isnotsupported

where you can see the possible run modes you know can configure in your custom launch file:

You can now start rqt and its plugin Visualization > Image View, choose e.g. the /image_raw topic and in case you have club mate and a hitchhiker’s guide to the galaxy by Douglas Adams around, you’ll get the following output:

We are beginning with a blank Xubuntu 14.04 Trusty x86 on a [amazon asin=B004URCE4O&text=Lenovo Thinkpad T520] . Any other version of a working Ubuntu 14.04 x86 should be compatible to this tutorial.

Setup Ubuntu environment:

If you are a complete beginner with Linux and Ubuntu, i would advice you to install several tools that are necessary or at least helpful while working with ROS. To install them use the following command and allow sudo to run with administrative permissions by entering your password when asked:

sudo apt-get install fail2ban ufw terminator git

In short, fail2ban is a advanced firewall tool that protects you from bruteforce, ufw is a ‘human readable interface’ to iptables and allows easy firewall rule organisation. Next, terminator is a terminal multiplexer that provides multiple terminals at once without leaving the keyboard while operating. Another essential tool is git, a source code versioning system.

There are more tools that are helpful, but can be considered as optional:

Setup ~/.bashrc part I:

In order to work correctly ROS requires several bash environment variables, that are not very well documented in the install tutorial. You can enter the following commands every time you start a new bash, or add it to .bashrc, the script that gets executed every time you start a bash.

The most important command:

1

source/opt/ros/hydro/setup.bash

enables bash to provide all ROS related commands like
roscore and
rostopic .

In order to work in an network environment (see their wiki), ROS also requires three more variables, namely:

1

2

3

export ROS_MASTER_URI="http://127.0.0.1:11311"

export ROS_HOSTNAME="127.0.0.1"

export ROS_IP="127.0.0.1"

Where ROS_MASTER_URI, defines the ip location of the roscore and the other two the ip of the local instance. As you see, in the example all ips are the local host ip 127.0.0.1 and need to be accordingly changed in order to work properly.

To simplify the ip settings, I suggest some modifications to the commands like that:

Create catkin workspace:

To use non packaged versions of ROS packages or the latest versions that did not have been compiled to the repository, you’ll need a local catkin workspace. Catkin is the ROS build tool, that is required to build packages from source. It allows multiple programming languages per package and handles linking dependencies. To create a local workspace you can follow the ROS wiki tutorial: http://wiki.ros.org/catkin/Tutorials/create_a_workspace.

In short, you also can follow these comands:

mkdir-p~/catkin_ws/src

cd~/catkin_ws/src

catkin_init_workspace

We will now build the empty work space as a first test:

cd~/catkin_ws/

catkin_make

source devel/setup.bash

Setup ~/.bashrc part II:

We also need to reference the newly created local workspace in our bashrc. Without doing that, tools like roslaunch and rosrun wouldn’t be able to find the customly created packages.

source/home/insert-your-username/catkin_ws/devel/setup.bash

You can now build, clone or fork your custom packages and therefore can call your pc a working ROS Indigo environment! 🙂

As our [amazon &title=CubieTruck&text=CubieTruck] is faced with strange issues when using chrony and internet access is not a general prerequisite on ROS setups, i needed to figure out a new way to synchronize the time with no internet ntp server available. For some reasons, even my local ntp was broken, which is why I try to set the time according to the ros master on all clients by this simple bash command:

1

ntpdate`echo$ROS_MASTER_URI|grep-oE"b([0-9]{1,3}.){3}[0-9]{1,3}b"`

it simply extracts the IPv4 part of the $ROS_MASTER_URI environment and uses ntpdate to set the time on the excecuting client system.

In case you only want to know the exact time derivation consider using the ntpdate parameter -q which only emulates the request.

Today I’ve got the chance to get my hands on a Leap Motion. As it uses depth information to track hands on a short range from the device and as there is a ros driver package existing for it, I hoped to get a 3D PointCloud. It costs about 80€ and could have been a cheap replacement for the [amazon &title=Xtion&text=Asus Xtion].