Chapter 6. The ball tracking example

Table of Contents

Ball detection
The main program
Programming as a behavior graph
Controlling the execution of the behavior

The best way to learn a new language is to study simple examples to see what can be done in practice. In this tutorial, we will concentrate on the red ball tracking application on the Aibo which is interesting because it is a simple behavior with two states and it involves a perception/action loop which is very typical of robotic applications. We will see how URBI can help to control the execution of the behavior in a simple way with command tags.

Ball detection

Detecting a ball involves image processing and cannot be written directly in URBI for obvious efficiency reasons. The best way to provide such algorithmic components (like visual processing or sound processing) is to write a UObject Component in C++, Java or Matlab, and to plug it in URBI. We will not describe at this stage how to write such a component, but instead we will already use one: the ball object.

The ball object is directly integrated in the Aibo URBI Engine and you can use it directly, just like any physical device. It has no ball.val variable but it has a ball.x and ball.y variable which are equal to the coordinate of the ball in the image, expressed between -1/2 and 1/2. When there is a ball visible, ball.visible is equal to 1, zero otherwise. It also have a ball.ratio variable which give the ratio of pixels of the ball in the image, expressed as a percentage of the total image size. These simple object variables are already enough to do many interesting applications, as we will see below.