Advanced Robocamps Code Archive
All the code presented during the Advanced Robocamps course is written in TEA which is a subset of ANSI C. Complete documentation of the TEA programming language can be found at the Acroname website. This language is continuously being improved on a bi-monthly basis.

The following is by no means a complete documentation of TEA. This is simply a shortened list of code used during Advanced Robocamps.

Code used during Advanced Robocamps


Pick the desired program you want to see.

Commonly Used Syntax


You may select some code from the drop down menu or scroll down the page.

Preprocessing Macros
Code Syntax:
 

#define MACRONAME ITEM-TO-REPLACE-WITH

  Code Example:
  #define FORWARD 60
#define AVOIDSTATUS aPad_ReadInt(0)
  Pseudocode / Description:
  This snippet shows how to create a preprocessing macro. Everywhere in your code you type "FORWARD", the compiler replaces "FORWARD" with "60".
  For more information:
   

"aA2D_ReadInt"
Code Syntax:
 

aA2D_ReadInt(SENSORPORT);

  Code Example:
  int x;
x = aA2D_ReadInt(0);
  Pseudocode / Description:
  This snippet defines a variable "x" and stores the reading of the sensor port.
  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aA2D_ReadInt.html

"aCore_Sleep"
Code Syntax:
 

aCore_Sleep(TIME);

  Code Example:
  aCore_Sleep(10000);
  Pseudocode / Description:
  This snippet delays for 1 second.
  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aCore_Sleep.html

"aMo_Go"
Code Syntax:
 

aMo_Go(LSPEED,RSPEED);

  Code Example:
  aMo_Go(60,-60);
  Pseudocode / Description:
 

This snippet turns the motors on a 2WD differential robot on in opposite directions.

   0 - Stops the motor
   60 - Full speed in forward direction
   -60 - Full speed in reverse direction

You MUST include "aMo_Init" in your program.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aMo_Go.html

"aMo_Init"
Code Syntax:
 

aMo_Init();

  Code Example:
  #include "aMo_Def.tea"
#include <aMo.tea>

void main() {
   aMo_Init();
   aMo_Go(60,60);
}
  Pseudocode / Description:
 

This snippet initializes the motors and tells a 2WD robot to drive forward indefinitely.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aMo_Init.html

"aMulti_Spawn"
Code Syntax:
 

aMulti_Spawn(PROCESSID,PROGRAM-SLOT);

  Code Example:
 

#include <aMulti.tea>
#include <aCore.tea>
#include "aMo_Def.tea"
#include <aMo.tea>
#include <aPrint.tea>

Load this program into Brainstem slot 0:

void main() {
   aMo_Init();
   aMo_Go(60,60);
   aMulti_Spawn(1,1);
}

Load this program into Brainstem slot 1:

void main(char challingProcID) {
   while(1) {
      aPrint_String("\nHello World);
   }
}

  Pseudocode / Description:
 

This snippet launches 2 programs to run at the same time.

The first program tells a 2WD robot to drive forward forever and launches the second program to run concurrently.

The second program prints the message "Hello World" indefinitely.

Only 4 processes can run at the same time. The value PROCESSID can only have a value from 0 - 3.

The PROGRAM-SLOT value can be any of the 11 available slots that TEA programs are stored into.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aMulti_Spawn.html

"aPad_ReadInt"
Code Syntax:
 

aPad_ReadInt(SCRATCHPADLOCATION);

  Code Example:
 

int x;
x = aPad_ReadInt(0);

  Pseudocode / Description:
 

This snippet reads the value stored in the scratchpad at location 0 and stores that value as "x".

The Scratchpad has 0 - 30 available locations to store things.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aPad_ReadInt.html

"aPad_WriteInt"
Code Syntax:
 

aPad_WriteInt(SCRATCHPADLOCATION,VALUE);

  Code Example:
 

x = aPad_WriteInt(10,22);

  Pseudocode / Description:
 

This snippet writes the value 22 to the scratchpad location 10.

The Scratchpad has 0 - 30 available locations to store things.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aPad_WriteInt.html

"aPrint_String"
Code Syntax:
 

aPrint_String("STRING TO PRINT");

  Code Example:
 

aPrint_String("\nHello World");

  Pseudocode / Description:
 

This snippet prints the text "Hello World" to the console.
Useful characters to know are:
   \n - This returns one line
   \t - This tabs

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aPrint_String.html

"aSP03_SpeakString"
Code Syntax:
 

aSP03_SpeakString(VOLUME, PITCH, SPEED, STRING);

  Code Example:
 

aSP03_SpeakString(0, 4, 3, "Talking is fun");

  Pseudocode / Description:
 

This snippet tells the SP03 to say "Talking is fun".
Parameters used are:
   VOLUME - 0 - 7 (7 is the lowest volume)
   PITCH - 0 - 7 (7 is the lowest pitch)
   SPEED - 0 -3 (3 is the fastest)

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/aSP03_SpeakString.html

"Else" Statements
Code Syntax:
 

else {
   statement(s);
}

  Code Example:
 

if (aA2D_ReadInt(0) >= 400) {
   aMo_Go(0,0);
   aCore_Sleep(10000);
}
else {
   aMo_Go(60,60);
   aCore_Sleep(10000);
}

  Pseudocode / Description:
 

This snippet checks the Sensor attached to channel 0 to see if it is greater then 400. If it is, then it turns off the motors on a 2WD differential robot and then waits for 1 second. Otherwise, when the sensor reading is below 400, the 2WD robot moves forward.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/Grammar.html

"If" Statements
Code Syntax:
 

if (expression) {
   statement(s);
}

  Code Example:
 

if (aA2D_ReadInt(0) >= 400) {
   aMo_Go(0,0);
   aCore_Sleep(10000);
}

You can also do the following:

if (aA2D_ReadInit(1) <= 600) aCore_Sleep(400);

  Pseudocode / Description:
 

This snippet checks the Sensor attached to channel 0 to see if it is greater then 400. If it is, then it turns off the motors on a 2WD differential robot and then waits for 1 second.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/Grammar.html

"While" Statements
Code Syntax:
 

while (expression) {
   statement(s);
}

  Code Example:
 

while (1) {
   aMo_Go(0,0);
   aCore_Sleep(10000);
}

You can also do the following:

while (aA2D_ReadInt(1) < 100) {
   aMo_Go(0,0);
   aCore_Sleep(10000);
}

  Pseudocode / Description:
 

The first snippet loops forever, continuously executing what is inside the curly braces.
The second snippet loops only when the sensor reading is below 100.

  For more information:
  http://www.acroname.com/brainstem/ref/h/TEA/Grammar.html