This is a continuation of a project from 4 years ago. At that time, I designed and implemented a program to take English like commands (“Blink Slowly”) and execute them on an SSC-32. I have since split the program into two modules. One which translates the English commands into integer tokens. The second runs onboard the robot/ animatronic and controlled by the tokens, moves the servos.
The original article was discussed in my Peter Penguin forum post in the Robot Project Showcase.https://www.robotshop.com/forum/download/file.php?id=1389
The A-code language (for Animatronic Code) looks like this:
Startscript,Blink,0
Playmove,Close eyes,200
Scriptpause,100,100
Playmove,Open Eyes Normal,200
ScriptPause,100,100
Playmove,Close eyes,200
ScriptPause,100,100
Playmove,Open Eyes Normal,200
Endscript,Blink,0
:,,
Startscript,Main,0
Label,DoItAgain,0
CallScript,Blink,0
ScriptPause,1500,1500
JumpTo,DoItAgain,0
Endscript,Main,0
The main script is at the bottom of the file. I’ve decided to label it “Main”, but it could have any name. Five lines down, you see the keyword EndScript and the label “Main”. This indicates the end of the script. But there are many other lines. That’s because A-Code can execute many scripts simultaneously. Up to 64, although with this animatronic having only 11 servos, the practical limit is much smaller.
In this example, you can see the code bracketed by StartScript and EndScript keywords. So this show (show = a collection of scripts) consists of just two scripts.You can see from the script name, “Blinky”, and the commands to open and close his eyes, that this script blinks the penguins eyes. The Main script calls it, waits a while and then loops to a label, DoItAgain. and keeps on blinking until I turn it off.
The original program translated all of the keywords into integers, and stored them into a 4 by nnn array. Then, when executing the script, case statements were used to execute the appropriate steps for each keyword.
Here is the 4 x nn array:
0,9,200,2
8,100,100,3
0,5,200,4
8,100,100,5
0,9,200,6
8,100,100,7
0,5,200,8
3,0,0,0
12,1,0,10
8,1500,1500,11
4,9,0,12
3,0,0,0
For example, the second line starts with “8”. That is the token for a pause command, and it will pause execution of the script for 100ms. Almost at the bottom, is a “4”. That is the token for a JumpTo, and since the second value is a 9, it will ,JumpTo the step in position 9.
The original program did both the tokenizing step, and interpretation of the tokens to make the animtronic move.
The current project has split the program in half. It now interprets and tokenizes the show. It’s output is an include file defining an internal array of the tokens. This include file is matched with Arduino code, which takes over the execution of the tokens in a microprocessor, and everything fits onboard the animatronic (except power; working on that, too.)
ACC_7-0.bas (16.8 KB)
CallTest1.h (1.23 KB)
MoveCommands.h (6.77 KB)
Animatron.ino (6.78 KB)