At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search
Home » Articles » Robotics » Norland Research Calculator Robot

Emulating the Compurobot on the Calculator Robot II

This article will look at a simple program for the Calculator Robot II that emulates the Compurobot (shown right). The Compurobot was an educational robot designed in the 19XXs, that allowed kids to understand the concepts of programming. The Compurobot was programmed using a series of buttons on the top of the robot. They were pressed in sequence to enter a program that controlled the movement of the Compurobot. The movements were:

  • Forward
  • Backward
  • Left
  • Right
  • Curve left
  • Curve right
  • Wait
  • 3 gear modes (speeds)
All movements could also be multipled using number buttons. For example, pressing the forward button followed by '3' would program the robot to move forward for 3 seconds.

The Program

To make sure the program was easy to understand, I took some liberties with the programming. Firstly, I did not include curving code. This would require the servos to be dynamically reconfigured, so that the left servo was slower than the right when moving forward (to curve left), and vice versa. This is definitely possible, but would expand the program a fair bit. Similarly, the 3 gear modes have been omitted. Also, while the code is sufficiently robust, character checks are not performed.

This said, the calculator version is more powerful in other respects. It isn't limited by 48 commands, only by your calculator memory. Additionally, the Compurobot only allowed two numbers to be multiplied together, while the calculator version allows as many as you want.

The program is non-interactive, and instead relies upon Str1 to hold the commands. They are inputted as follows:

CommandCode
Move forwardF
Move backwardB
Move leftL
Move rightR
WaitW
Multiplier*

Example programs include:

"F4"->Str1:prgmCOMPROBOT
"F2*2"->Str1:prgmCOMPROBOT
"FFFF"->Str1:prgmCOMPROBOT
"F3LF3LF3LF3"->Str1:prgmCOMPROBOT
Note that the first 3 programs to the same thing.

Code

Note: Do not copy and paste this code, since I have had to substitute some symbols here. Use the group file at the end of the article.
 1: ClrDraw:AxesOff:LabelOff:CoordOff:ExprOff
 2: {-1}->L1
 3: RecallPic Pic0
 4: For(A,1,250,1)
 5: getKey
 6: End
 7: ClrHome
 8: Disp "PARSING"
 9: 0->C:0->D:0->L:100->N:1->A
10: Lbl LP
11: While A<=length(Str1)
12: sub(Str1,A,1)->Str2:C->D:A+1->A
13: If Str2="F":Then:122->C:Goto PC:End
14: If Str2="B":Then:100->C:Goto PC:End
15: If Str2="W":Then:111->C:Goto PC:End
16: If Str2="L":Then:112->C:Goto PC:End
17: If Str2="R":Then:121->C:Goto PC:End
18: If Str2<>"*":N*expr(Str2)->N
19: End
20: 0->A:C->D
21: Lbl PC
22: If D<>0:Then
23: augment(L1,{D,N})->L1
24: End
25: 100->N:0->D
26: If A<>0:Goto LP
27: Disp "EXECUTING"
28: For(A,2,dim(L1),2)
29: Send({L1(A),L1(A+1)})
30: Get(Q)
31: End
As with any program in TI-BASIC, it is rather hard to get an idea what the program is doing, since variables are non-meaningful, nevertheless I'll explain essentially what the program is doing.

Execution is a two-step procedure: the program parses the string and then sends the commands to the robot. Lines 1-9 simply set everything up and display the splash screen for a second or two.

The label on Line 10 stands for LOOP. You can see I use a while loop to parse the whole string, using A as the counter. Line 12 sees me grab the current token and put it into Str2. We then copy the current command to D (more on this in a minute) and then increment our token pointer, A.

Now, Lines 13-17 are essentially the same. We check the current token for a particular command, then we store the necessary command in C. We then jump to PC (Process Command). Process Command processes the previous command (currently held in D). This is because Compurobot allows those multipliers after the main command (for example, "F3"). Therefore, the actual full command is not known until the next command (or end of string) is reached. We'll study Process Command itself in a minute.

Next, Line 18 processes the numbers. As long as the token isn't the multiplier, we multiply the current number (in N) with the token. expr() will simply take the number and convert it into an integer. Note that N is set to 100 by default (for 100 milliseconds).

Line 20 is used to enable us to process the last command once the string has reached the end. Again, this might be hard to grasp, but if you step mentally through the code with a short string (try "3F"), you'll see how it works.

Lines 21-26 are our PC routine. Line 22 ensures that we don't accidentally add a command at the beginning of the list before a full command has been processed. Line 23 does the magic - it appends the command {D,N} to L1. Next, we reset our command and number variables, before jumping back to our while loop (unless we've reached the end of our string).

We've now completely processed the string and have all the commands in L1. We just need to send them to the robot a pair at a time. Lines 28-31 do just that!

Submitted: 15/07/2003

Article content copyright © James Matthews, 2003.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -