| XML Scripts |
Some background about scripts...
Very Brief Intro to XML
Many applications use XML (Extensible Markup Language) files for storing data. It's a very flexible text format that uses "tags" or keywords combined with brackets to denote fields of data. Fields may be nested within other fields to create complex records.
Garcia and XML
The Garcia API can read XML and convert it to robot commands. A user may write an XML script in a text editor that will define a series of tasks for the Garcia robot. This makes it possible to do useful robotics work without having to recompile code all the time.
Any task that may be represented as a sequence of primitives may be encoded as an XML script. Primitives can set properties within the Garcia robot or make the robot perform specific movements. Scripts themselves are treated as primitives and may be nested within other scripts.
XML scripts are run through a preprocessor so it is possible to define constant values, include files with defined values, and add comments. These preprocessing features can make a script more readable.
To get acquainted with scripts, an example is shown below. It shows the proper syntax for comments, includes, and defines, as well as sample usage of all the XML tags used in Garcia scripts.
#include <aGarciaDefs.tea>
/* my distance */
#define HOW_FAR_TO_GO 2.0
<BEHAVIOR>
<PRIMITIVE> "move" </PRIMITIVE>
<PROPERTY>
<NAME> "distance" </NAME>
<VALUE> HOW_FAR_TO_GO </VALUE>
</PROPERTY>
<PROPERTY>
<NAME> "expected-status" </NAME>
<VALUE> aGARCIA_ERRFLAG_FRONTR_LEFT </VALUE>
</PROPERTY>
</BEHAVIOR>
This script makes the robot go straight until it detects something with its front left ranger. Additional details about properties and primitives may be found in the reference.