Control via blackboard architecture.

We have already made a simple integration of perception and action 
- the robot hit a ball upon the seen image. 

We can implement such simple integration by a single loop: sense, select, act. 
However, when we want more, this is insufficient, and we need to operate several 
such loops in parallel. Then, of course, we need to somehow manage coordination among 
these loops.

Therefore, we establish blackboard architecture, where we call the loops agents and 
the coordination mechanism blackboard.

First, open the agentspace.py, which implements such blackboard architecture. Then, 
concentrate on the bottom of the file containing __main__. The first part tests 
the blackboard (called space), and the other part two agents: one periodically 
writes 0,1,2,3,... onto the blackboard, and the other reads and prints out these 
numbers upon notification from the blackboard. Finally, play with the blackboard 
and note the importance of the commands attach_timer and attach_trigger. Try to predict 
the output of this program, then run it by run-test.bat and check the quality of 
your suggestion. Then play more or use quit().

Then follow versions of the gradually implemented control system of the robot that 
takes the ball from the table, tells "the ball" (moving lips), and releases it on 
the ground.

Now let us make the headset/speaker enabled (not required at your own computer, just in 
the terminal room): insert your headset into the top hole for the jack on the front 
of your PC. Use the right mouse to click on the Volume Control icon in the right 
part of the bottom windows bar. Select playback devices, click on speakers, and 
Set Default, OK. Then click on the same icon, choose Volume control options, and 
select the check box for Speakers, OK. Then use the left mouse click and set the 
sound intensity for the speaker in the mixer (which also enables the device); 
you should hear a ring; click on the desktop. 
Open cmd in the directory with the training content and type:
> set ESPEAK_DATA_PATH=.
> espeak "hallo student"
and adjust the sound intensity by the above procedure; about 20 percent would be 
an acceptable value.

Start the simulator by launching install_and_run.bat
Answer n as No on the question about objects.
Explore programs version*.py that you can run by run-version*.bat
The batch employs the interactive mode of Python, so when finished, 
you can inspect the employed data and exit it by quit().
(The run-renew.bat returns the robot to its default pose, 
but it is not necessary to use it.)

version 1
We put the ball in a suitable spot on the table and let the robot pick it up and 
drop it. No loop.

version 2
We put the ball in a suitable spot on the table. Then, we receive images from 
the left robot's eye in a loop and display them. Finally, we can see the ball 
in the displayed image (we see no movement). Click to the window and press Esc to exit.

version3
We add the blue color filter and detect the ball's position (position 15)
on the image. It is (148,110).

version4
We add picking up the ball whenever the robot sees it in the recorded position. 

version5
We add telling "the ball" and dropping the ball. Surprisingly, the robot also acts 
when no ball is on the table but still sees it. Where is the problem? The problem 
is that the robot's actions take their time, which is incompatible with the image 
reception from the camera.

version6
We put the image reception into an agent - called CameraAgent - which periodically 
writes the received image onto the backboard. Then, we read images from the 
backboard instead of the camera in the main loop. As a result, the above problem 
disappears, thanks to this solution's automatic sampling of images.
(We cannot escape by the Esc key now, but we can close the program's window or
press ctrl-c, then Y <Enter>)

version7
We can apply the same strategy to the remaining part of the main loop and replace 
it with agents. One agent receives camera images, the next detects the ball's 
position, and the last one controls the robot's body. 

version8
Now we can add head control to let the robot speak to us. Then we see that robot 
says, but it does not move with its lips.

version 9
Thanks to the blackboard, we can add moving lips easily by another agent. 

Try to implement your agent that manipulates the ball in the following way: 
If the ball is on the table, it moves to the left. 
If the ball is below the table, it is moved to the right corner (from the robot's viewpoint). 
Do not manipulate the ball; otherwise. 
The ball position is a tuple of (x,y,z) coordinates. 
The level of the table is -46.0245. 
The right corner coordinates are (-300.0, 150.0, -46.0245).
The ball coordinates for position x are ball.set((-300.0, 150.0 - 10*x, -46.0245))
