|
A central control program (r4d) is used to prioritise some of the inter-module communication. This is also the "cognitive thought" of R4. Most of the decision logic occurs within this program. All the other programs (modules) are designed to perform specific tasks. If you look at the diagram of the software (77Kbytes), you will see how the different modules (separate programs) communicate with each other. In the diagram, the green and blue arrows represent the named pipes. Although the disgram shows all data passing though the control program (r4d), some modules pass instructions directly to others. For example, the voice module passes instructions to the face module to allow for mouth movements.
For copies of the current source code, please check the source code directory. Remember that I am still (slowly) working on R4's software so changes will happen from time to time.
Below are discussions of the running envronment and each of the modules...
The control porgram (r4d) communicates with the other modules by writing or reading single-line text commands to or from the named pipe associated with each of the other modules. The named pipes associated with each module are:
Two environment variables are used for the location of the modules (programs) and named pipes. These are:
voice voice_pipe sound sound_pipe face face_pipe drive drive_pipe command command_pipe joystick joystick_pipe sensor sensor_pipe
The programs (modules) are compiled (make all) and then installed into $R4_BINARIES. Each of the named pipes will need to be created in the $R4_LIB directory with the command:
Variable Default Value R4_BINARIES /usr/local/bin/r4 R4_LIB /usr/local/lib/r4
mknod module_pipe p
When the Control program (r4d) starts, it forks and and the parent dies (ie. it runs in background - as a daemon). The existence of each of the named pipes is tested and if it exists, is opened in the following ways:
The other modules are then spawned (started as separate processes).
voice_pipe output append sound_pipe output append face_pipe output append drive_pipe output append command_pipe input joystick_pipe input sensor_pipe input
The input pipes are read in the order "command", "sensor" then "joystick", with a very short time-out (<100ms). Data read from the pipes is in the form:
Cxxxxxxxxxxxxxxxwhere "C" is a 1 byte command and "xxxxxxxxxxxxxxx" is a variable parameter string defined by the type of command. The input is always terminated by an EOL (^J) character. This means it can be read with standard library routines such as fgets(). Commands to the output pipes are of the same format.
ptsoundfilewhere "t" is the file type ("a" = audio, "w" = wave). For example, the command:
pawhistlewill play the audio file "/usr/local/sound/audio/whistle.au".