Page 133 - The Ultimate Palm Robot
P. 133
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 5
116 The Ultimate Palm Robot
That’s when we decided to look at the program itself to see what it was really
supposed to do, rather than assuming it was supposed to work a certain way.
Let’s take a quick look at that TEA file, simple.tea. We will cover the TEA
language in more depth later in the book in Chapter 8, so we’ll take just a
quick sip of the program for now. The first clue to whack us right between the
eyes was a comment line at the top of the file:
/* Wait till back sensor is approached, then do a little jig. */
Obviously, the comment refers only to one sensor. Perhaps the robot was
working exactly the way the program told it to work.
As an aside, it’s worth noting that the comment line uses C-style com-
ments. As we look at this program further, you will see other signs that the
TEAlanguage syntax is partly based on the C language. Another similarity to
C is the ability to include other source files in your TEA file and use the func-
tions defined in those files. The source file simple.tea includes three other
source files. Here is one of the #include lines from simple.tea:
#include <aCore.tea>
The aCore.tea file has methods for pausing the robot and reading and writ-
ing the BrainStem ports. The software from Acroname includes several other
TEA files in the \aSystem directory. These files contain lots of different func-
tions that you can call from your TEA code, which simplifies developing new
code.
Within your TEA source files, you can define functions that can be called.
The simple.tea programs includes two functions: jig( ) and main( ).
The Robot Geek Says
The Rain in Spain Stays Plainly in the main( )
✖ The main( ) function is a special function that is called by the system
code to start the program.
✖ C, C++, and Java also start programs with a main( ) function (although
in Java, it is referred to as the main( ) method).
✖ The main( ) function can appear anywhere inside the source code.
So, back to our little story. We guessed that the jig( ) function was used to
move and turn the PPRK when a sensor detected an object. If you look at the
P:\010Comp\Bots\880-6\ch05.vp
Monday, May 12, 2003 4:06:14 PM