Project Implementation
The Web page represents the interface to the user and allows the user to send
commands to the robot pet. A demo page is viewable either by clicking here.
The Web page is mounted on a normal http web server (in our case we used
Apache running on Linux). This interfaces to VCC using simple filesystem access.
This utilises the ability to mount linux based network drives under Windows
using the Samba Linux/Windows networking interface. This allows a file to be
updated by a linux process (the web server) and read by a windows process (a C++
program running in the VCC environment).
The setup we used was that buttons on the web page would call the same
webpage with a parameter. As the web page was served if it had been called with
a parameter it was placed in a file in a shared directory. If there was no
parameter a null command was placed in the file. The file only ever held one
command so there was the possiblility of commands being lost but for this
application that was acceptable. The web page was written in a language called
PHP. The source code for the demo web page is
available here.
In VCC one block - the WWW handler -
is responsible for repeatedly looking at the shared file using standard C++ file
handling functions and then firing off events when it reads a command. The WWW
handler has different outputs for all the different commands, this is mainly to
aid debugging during analysis sessions in VCC. The WWW handler also has one
other input - a clock signal from a "Uniform Pulses" box. This box is a standard
feature of the VCC library and will generate pulses at regular intervals of
simulated time. Without this the WWW handler code would not be run as the block
would not recieve any events as the file changing cannot trigger a VCC event
directly. The clock pulse is not refered to in the code as it does not need to
be, VCC just runs the code because of the incoming event.
References:
The brain is relatively simple
diagramatically as it simply takes in personality commands and sensory input
commands and outputs motor control commands. The code inside has two possible
modes:
a) a 'normal' mode where degrees of intelligence are displayed and pseudo
random movements are generated.
b) a 'Barbara Woodhouse' mode whereby it only
does exactly what it is told by its user.
References:
The Motor Controller simply takes
motor commands from the brain and translates them into signals for the lego
motor. Originally this block also carried out the timing for each motor
movement. The motor controller would send a signal to a motor line and then a
certain amount of time later a stop signal would be sent. That way every motor
command sent from the brain would translate into a specific amount of movement.
During development that functionality was moved further into the Lego Robot
system primarily due to the difficulty of maintaining virtual timing and real
timing at this level in whitebox C.
References:
The Lego Robot block uses a Windows CPP call to open a named pipe. This is a
Windows communication method that allows the VCC process to send commands to a
simple CPP proxy program. This proxy program, called RobotProxy, then sends
motor commands to the Lego robot in a syntax it can understand.
References:
Dave Harding.
|