Seq BAP code export question

Hello Guys,

I’ve been playing some more with the SEQ program and have a question:

I have a sequence I would like to program into the Atom Pro but I need a little help understanding the code. My guess is the “SeqIndex” variable is the number of times it will loop through the sequence? This number is at zero so I don’t understand. What I would like for the program to do is only run the entire sequence from start to finish only once. I do not want it to loop endlessly.

Can someone give me some help on this? :smiley:

[code] ; ------------------------------------------------------
; Lynxmotion Visual Sequencer SSC-32 ‘Export’ Program
; Sequencer SSC-32 project : Brat02_head
; Date : 12/12/2007 4:48:00 PM
; ------------------------------------------------------
; Format : Basic Atom 24/28 IDE <= V02.2.1.1 or Pro IDE + SSC-32
; Original filename : Brat02_head.bas
; ------------------------------------------------------

Steps Wordtable $03DC, $0C15, $13CF, $7B85, $839E, $8BB0, $940A, $901F, $901F, |
$7A48, $781F, $781F, |
$0304, $0CA5, $1488, $7D4B, $8198, $8CDD, $9537, $901F, $901F, |
$050F, $7A16, $841A, $801F, $801F, |
$0ACB, $12A0, $7857, $8B21, $934C, $901F, $901F, |
$0347, $7D64, $825B, $801F, $801F, |
$0CA5, $1488, $7B8B, $8CDD, $9537, $901F, $901F, |
$04FE, $79CC, $8440, $801F, $801F, |
$0ACB, $12A0, $7B8B, $8B21, $934C, $901F, $901F, |
$0326, $7D19, $8234, $801F, $801F, |
$0CA5, $1488, $7B8B, $8CDD, $9537, $901F, $901F, |
$04A9, $79FD, $8406, $801F, $801F, |
$0477, $0C15, $13CF, $7B8B, $8BB0, $940A, $901F, $901F, |
$03DC, $839E, $801F, $801F

SeqPos Wordtable $0000, |
$0056

SeqIndex var Word
Index var Word
LastServo var Byte
TmpServo var Byte
TmpValue var Word
DejaVu var bit

LastServo = 99
DejaVu = 0

pause 500

Main
For SeqIndex = 0 to 0
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout p15,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout p15,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
next
goto Main
[/code]

Mike,

That code is never going to execute.

The first for loop has SeqIndex going from 0 to 0.

It occurs to me that could mean it executes once only, but that would not follow the usual operation of a for loop if that is the case.

I don’t have SEQ here so can’t test the generated code to see what it actually does, and really can’t help much.

Do you have something set wrong in the parameter set that generated the code?

Can you show screen captures of what you are doing at each step? I can help a little more if I can see what you are doing at each step to generate the code. The more info I can get, the more likely I can help. :smiley:

8-Dale

Well the code does work for the BAP and it plays the sequence forever. Now I need to figure out how to make it play the entire sequence only once.

This is really cool seeing it move from the control of the BAP. :laughing:

If I can get this code to run only once, then I can program the BAP to “call” on the sequence and run it X-number of times for variable distance steps, once for short travel or several times for longer travel.

Just change it to

for SeqIndex = 0 to 1

That should only execute once.

Why do you just want it to execute once?

You can accomplish this a lot easier, Mike. :wink:

Change it to:

For SysIndex = 0 to MaxRun

where MaxRun is how many times you want it to execute. You set MaxRun to the number of times to execute before you call the routine. Just don’t let MaxRun be set to 0! :slight_smile:

Theoretically, this should just execute the number of times you want it to. This would also cut out a LOT of gosubs to the routine. :slight_smile:

8-Dale

Well I figured it out. You need to have the FOR 0 TO 0. If you change 0 to 1 it works fine first time through then one of the ankle servos begin to move without stoping and I had to turn the power off before it crashed against the servo bracket.

To make it only run the sequence once, you have to remove the “GOTO MAIN” at the end. This will make it run the sequence steps only once.

WOOO HOOO! It works! :laughing:

Hi there !

SeqIndex is an index pointing on sequences.
so, if there’s only one sequence, the main loop is set from 0 to 0 to run the unique sequence.

It could look stupid to use a “for” loop with a “0 to 0” counter, but the purpose here is to be didactic :

  • the code between the “Main” label and the “goto Main” command will perform all sequence(s) only once, the “goto Main” loop infinitely…so you are right, deleting the “goto Main” is the way to perform the project only once

  • if you delete the “For SeqIndex = 0 to 0” line and the last “Next” line, then if you add a “return” to the end of code and rename the “Main” label into a “PlaySeq” label…here’s a Sub program playing any sequence, you just need to initialize the SeqIndex variable with the Sequence # and calling the sub with “gosub PlaySeq” :

[code]; ------------------------------------------------------
; Lynxmotion Visual Sequencer SSC-32 ‘Export’ Program
; Sequencer SSC-32 project : Brat02_head
; Date : 12/12/2007 4:48:00 PM
; ------------------------------------------------------
; Format : Basic Atom 24/28 IDE <= V02.2.1.1 or Pro IDE + SSC-32
; Original filename : Brat02_head.bas
; ------------------------------------------------------

Steps Wordtable $03DC, $0C15, $13CF, $7B85, $839E, $8BB0, $940A, $901F, $901F, |
$7A48, $781F, $781F, |
$0304, $0CA5, $1488, $7D4B, $8198, $8CDD, $9537, $901F, $901F, |
$050F, $7A16, $841A, $801F, $801F, |
$0ACB, $12A0, $7857, $8B21, $934C, $901F, $901F, |
$0347, $7D64, $825B, $801F, $801F, |
$0CA5, $1488, $7B8B, $8CDD, $9537, $901F, $901F, |
$04FE, $79CC, $8440, $801F, $801F, |
$0ACB, $12A0, $7B8B, $8B21, $934C, $901F, $901F, |
$0326, $7D19, $8234, $801F, $801F, |
$0CA5, $1488, $7B8B, $8CDD, $9537, $901F, $901F, |
$04A9, $79FD, $8406, $801F, $801F, |
$0477, $0C15, $13CF, $7B8B, $8BB0, $940A, $901F, $901F, |
$03DC, $839E, $801F, $801F

SeqPos Wordtable $0000, |
$0056

SeqIndex var Word
Index var Word
LastServo var Byte
TmpServo var Byte
TmpValue var Word
DejaVu var bit

LastServo = 99
DejaVu = 0

pause 500

Main
SeqIndex = 0
gosub PlaySeq
goto Main ; or “end” to play once

PlaySeq
For Index = SeqPos(SeqIndex) to SeqPos(SeqIndex + 1) - 1
TmpServo = Steps(Index) >> 11
TmpValue = Steps(Index) & 2047
if LastServo = TmpServo then
TmpValue = TmpValue << 5
if DejaVu then
Pause TmpValue
LastServo = 99
else
serout p15,i38400,“T”, DEC TmpValue, 13]
DejaVu = DejaVu ^ 1
endif
else
TmpValue = TmpValue + 500
serout p15,i38400,"#", DEC TmpServo, “P”, DEC TmpValue]
DejaVu = 0
LastServo = TmpServo
endif
next
return
[/code]

to perform only once, delete the “goto main” and add an “end” command at the same place.

in this example it’s not very usefull to add a sub program because there’s only one sequence, but imagine 10 sequences that you can call Initializing the SeqIndex variable with the Sequence # (from 0 to 9 if 10 sequences) and call the sub routine with “gosub PlaySeq”.
you can use the main loop to make decision on what sequence to play according to inputs (IR sensors etc…) or according to orders from a PS2 controller etc…

[code]…

Main
…test inputs or PS2 pad or what you need
if MyTestResult = Kick then
SeqIndex = 0 ; this is the Kick sequence :wink:
elseif MyTestResult = Crounch then
SeqIndex = 4 ; this is the Crounch sequence
…etc

else
SeqIndex = 99 ; a flag to say "“nothing to perform”
endif

if SeqIndex <> 99 then ; (if something to perform)
gosub PlaySeq ; performs the previously initialized Sequence #
endif
goto Main ;

…[/code]

Thanks Laureatus,

This is exactly what I want to do. I was going to develop all the various moves with the SEQ software and paste the code into sub routines that can be called. 8)

This is so cool!

Dear Laureatus,

I have a question here, I observer that the code exported from Seq is almost the same for difference task exclude the first part of definition with Data … So now I attach my robot with a sensor and I want it to do 2 tasks and the code will look like:
Main
If signal=1
task1
else
task2
goto Main
The problem is I don’t know how to combine the code, should I put in the code of task1 and task2 all the code or only the part of definition and the rest stays the same?