LOOKUP command causing compiler error

Hello again everyone. I’ve been doing work with the BRAT robot and have been using the Atom Pro to make it autonomous. I’m laying down the groundwork for the code and I’ve run into what seems like a compiler bug. When I’m using the LOOKUP command, it’s telling me that one of the commas to separate the arguments is an invalid token type. Here’s my code:

[code]; Copyright 2008 Patrick Stoddard
; Core OS designed to make the Zoey Robot Function

;---------------------------------------Declare Pins--------------------------------------
SSC32 con p14
ping con p15
baud con i38400

;--------------------------------------Declare Servos--------------------------------------
leftHigh CON 2
leftMiddle CON 1
leftLow CON 0

rightHigh CON 16
rightMiddle con 15
rightLow con 14

horizontalPing con 3
verticalPing con 4

;------------------------------------Declare Variables-----------------------------------
positionLeft var float
positionRight var float

position var word
movetime var word

pinnum var byte
movement var byte

;------------------------------------Declare Constants-----------------------------------
d con 1

;---------------------------------Declare Constant Tables--------------------------------
servoAdj FloatTable 5.58, 0, 2.25, 0, 0, 1.08

step1 ByteTable -34, -42, 9
step2 ByteTable -29, -29, -52
step3 ByteTable -16, -34, -14
step4 ByteTable 50, 29, -11
step5 ByteTable 34, 34, 8
step6 ByteTable 27, 11, 16
step7 ByteTable 27, 4, 16
step8 ByteTable -29, -21, 16

;--------------------------------Execute Start Up Procedure------------------------------

;------------------------------------Begin Main Program----------------------------------
DO
WHILE d = 1

getstep[movement]:
if (movement = 0) then
LOOKUP stepnum, [step1, step2, step3, step4, step5, step6, step7, step8], positionLeft ;Initial error given here
LOOKUP stepnum, [step5, step6, step7, step8, step1, step2, step3, step4], positionRight ; error also given here if first LOOKUP is removed
endif
return

move[pinnum, position, movetime]:
serout SSC32, baud,"#", DEC pinnum, “P”,DEC servo0pw, “T”,DEC movetime, 13]
return
[/code]
Any help is greatly appreciated. Thanks!

I think there may be problems with your code.

First I do not see where the variable stepnum is defined.

Also your list of numbers to lookup are actually ByteTables. Which are basically compiled arrays of numbers. And the result is a floating point. I am not sure what you are expecting as a result from the lookup command.

If you are trying to simply extract numbers from one of your ByteTables you can simply do that my an index. StepPart = step1(0)

Taking a WAG that the three values in each of your steps is maybe the value for 3 servos for that portion of the move. If so one possible way to do this would be something like:

i var byte
x var SWORD
y var SWORD
z var SWORD
stepTable ByteTable -34, -42, 9, |
           -29, -29, -52 , |
           -16, -34, -14, | 
           50, 29, -11, |
           34, 34, 8, |
           27, 11, 16, |
           27, 4, 16, |
           -29, -21, 16 

for i = 0 to 21 step 3       ; there are 8 steps here.
    x = stepTable(i)
    y = stepTable(i+1)
    z = stepTable(i+2)
    ; do whatever with these values like:
    gosub DoMyMovement([x, y, z]
next 

Please note, I have not tried to compile this, so I am not sure if I got everything in here correctly. The | allows you to continue a command on the next line, which can be convienant when you are entering tables like this. There are multiple ways to do the look up. You could just as easily have the loop go: for i = 0 to 7 and then do the multiple in the lookups: x = stepTable(i*3).

Good Luck

I’m no programming guru, but I was able to take the BRAT TV RC code and hack it for autonomous control. This code my be useful as it has all of the sequences from the BRAT SEQ tutorial built into it. I will post it today in another thread in the Biped Section.