>xabsl | The Extensible Agent Behavior Specification Language | ||||||||||
start | team | language reference | tools | xabsl engine | download | licence | |||||||||||
Language ReferenceAgents following the introduced hierarchical state machine architecture can be completely described in the XABSL language. The XABSL language design ensures:
ModularityAn XABSL agent behavior specification is distributed over many files.
This helps to keep an overview over larger agents and to work in parallel.
Common Language ElementsAlmost all language elements can be provided with describing texts which are used in generated documentations. Such descriptions are defined in the following syntax: <doc comment> ::= /** <describing text> */These documenting comments are always associated with the subsequent language element. The syntax definitions below show at which positions they can be placed in XABSL code. In all XABSL files, comments, that are to be ignored during compilation, can be added using // for a single line of comment or by surrounding a code block with /* and */ for a comment block which can span multiple lines of code. When symbols, options, or basic behaviors are referenced, a list of parameters can be specified. This is always done according to the following syntax: <parameter list> ::= ( <parameter> = <decimal expression> | <boolean expression> | <enumerated expression> { , <parameter> = <decimal expression> | <boolean expression> | <enumerated expression> } )
Symbol DefinitionsAll symbols that are used inside options have to be defined before in separate symbol definition files. For example the file "my_symbols.xabsl" can look like this: /** My most used symbols */ namespace my_symbols("My Symbols") { /** A boolean symbol */ bool input something_wrong; /** A decimal symbol */ float input foo "mm"; /** The absolute value of a number */ float input abs ( /** The value for that the absolute value shall be calculated */ float value; ); /** Pets */ enumeration type_of_pet { dog, cat, guinea_pig }; /** Which pet was seen by the robot */ enum type_of_pet input type_of_recognized_pet; /** Operation modes */ enumeration op_mode { slow, fast very_fast }; /** The mode how fast the robot shall act */ enum op_mode output op_mode; /** The value of pi */ float const pi = 3.14 "rad"; ... } Syntax of a symbols definition file: <symbol definition file> ::= { include "<include file>"; } [<doc comment>] namespace <id>("<title>") { { <enumeration> | <input symbol> | <output symbol> | <internal symbol> | <constant> } }
There are five different symbol definitions allowed inside a symbols definition file:
Basic Behavior PrototypesFor each basic behavior (they are written in C++), a prototype has to be declared. An example basic behavior file "my_basic_behaviors.xabsl" can look like this: /** My common basic behaviors */ namespace my_basic_behaviors("My Basic Behaviors") { /** Lets the agent move to a point */ behavior move_to { /** X of destination position */ float x [-1000..1000] "mm"; /** Y of destination position */ float x [-1000..1000] "mm"; }; } Syntax of a basic behavior definition file: <basic behavior definition file> ::= { include "<include file>"; } [<doc comment>] namespace <id>("<title>") { { <behavior> } }
The syntax of the definition of basic behavior prototypes is as follows: <behavior> ::= [<doc comment>] behavior <name> [ { { <parameter> } } ] ;
<parameter> ::= [<doc comment>] [float] <name> [[<range>]] ["<measure>"] | bool <name> | enum <enumeration> <name> ;
OptionsEach option has to be defined in a seperate file, e.g. "Options/foo.xabsl": include "../my_symbols.xabsl" include "../my_basic_behaviors.xabsl" /** Some option */ option foo { initial state first_state { ... } state second_state { ... } } An option file must have the following syntax: <option file> ::= { include "<include file>"; } [<doc comment>] option <name> { { <parameter> } [ <common decision tree> ] <state> { <state> } }
Options can have parameters which are defined in the same way as input symbol parameters. The name of an option parameter has to start with @ in order to be distinguished from an input symbol: <parameter> ::= [<doc comment>] [float] @<name> [[<range>]] ["<measure>"] | bool @<name> | enum <enumeration> @<name> ;
At the start of an option definition optionally a common decision tree can be defined with the following syntax: <common decision tree> ::= common decision { [<doc comment>] if ( <boolean expression> ) <decision tree> { [<doc comment>] else [<doc comment>] if ( <boolean expression> ) <decision tree> | [<doc comment>] else { [<doc comment>] if ( <boolean expression> ) } <decision tree> } } If there are transitions with the same conditions in each state, these conditions can be put into this common decision tree. It is carried out before the decision tree of the active state. If no condition of the common decision tree evaluates true, the decision tree of the active state is carried out. That is also the reason why there must be no else statement which is not followed by another if statement. If the common decision tree uses expressions that are specific for a state (state_time, action_done), these expressions refer to the state that is currently active. The elements boolean expression and decision tree are the same as in the normal decision tree of a state, which is explained later in this document. Besides and after the optional common decision tree each option has to have at least one state definition, which is described in the next section. StatesThe state definition represents a single state of an option's state machine, as shown in this example: initial target state first_state { decision { if (foo < 14 ) goto second_state; else goto first_state; } action { move_to(x = 42); op_mode = fast; } } It has the following syntax: <state> ::= [initial] [target] state <name> { decision { [ else ] <decision tree> } action { { <action definition> } } }
Decision TreesEach state has a decision tree. The task of this decision tree is to determine a transition to another state depending on the input symbols. The syntax of a decision tree is as follows: <decision tree> ::= { <decision tree> } | [<doc comment>] if ( <boolean expression> ) <decision tree> [<doc comment>] else <decision tree> | goto <state>; | stay; A decision tree contains either an if/else block or a transition to a state. The if/else element consists of a boolean expression and two decision trees. The first one is executed if the expression evaluates to true, the second one otherwise. This recursive definition allows for complex nested expressions.
Action definitionsEach state has a number of action definitions. These definitions specify which actions are to be executed when a state is active. The syntax is as follows: <action definition> ::= <output symbol> | <internal symbol> = <decimal expression> | <boolean expression> | <enumerated expression> ; | <option> [ <parameter list> ] ; | <basic behavior> [ <parameter list> ] ;
Boolean ExpressionsA boolean expression can be of the following syntax: <boolean expression> ::= ( <boolean expression> ) | !<boolean expression> | <boolean expression> && <boolean expression> | <boolean expression> || <boolean expression> | <qualified enumerated expression> == <enumerated expression> | <decimal expression> == <decimal expression> | <qualified enumerated expression> != <enumerated expression> | <decimal expression> != <decimal expression> | <decimal expression> < <decimal expression> | <decimal expression> <= <decimal expression> | <decimal expression> > <decimal expression> | <decimal expression> >= <decimal expression> | <boolean input symbol> [ <parameter list> ] | <boolean output symbol> | <boolean internal symbol> | @<boolean option parameter> | true | false | action_done
Decimal ExpressionsA decimal expression can be used inside some boolean expressions, for parameterizing symbols, options, and basic behaviors, and for the assignment of decimal output symbols. It has the following syntax: <decimal expression> ::= ( <decimal expression> ) | <decimal expression> + <decimal expression> | <decimal expression> - <decimal expression> | <decimal expression> * <decimal expression> | <decimal expression> / <decimal expression> | <decimal expression> % <decimal expression> | <boolean expression> ? <decimal expression> : <decimal expression> | <decimal input symbol> [ <parameter list> ] | <decimal output symbol> | <decimal internal symbol> | @<decimal option parameter> | <constant> | <decimal value> | state_time | option_time
Enumerated ExpressionsAn enumerated expression can be used inside some boolean expressions, for parameterizing symbols, options, and basic behaviors, and for the assignment of enumerated output symbols. For the left-hand side of the comparison of two enumerated expressions in a boolean expression a special enumerated expression, a so-called qualified enumerated expression, is required which implicitly defines its associated enumeration. Particularly a reference to an enumeration element cannot be used, since enumeration elements are not necessarily unique. E.g. the boolean expression "dog == type_of_recognized_pet" would be illegal, "type_of_recognized_pet == dog" must be used instead. Enumerated expressions follow this syntax: <qualified enumerated expression> ::= ( <qualified enumerated expression> ) | <enumerated input symbol> [ <parameter list> ] | <enumerated output symbol> | <enumerated internal symbol> | @<enumerated option parameter> | <boolean expression> ? <qualified enumerated expression> : <qualified enumerated expression> <enumerated expression> ::= <qualified enumerated expression> | <boolean expression> ? <enumerated expression> : <enumerated expression> | <enumeration element>
AgentsThe file "agents.xabsl" is the root document of an XABSL behavior specification. It includes all the options and defines agents. An example "agents.xabsl" file may look like this: /*** Title: My XABSL behavior application Platform: My robot/agent platform. Software-Environment: My software platform */ include "Options/foo.xabsl"; include "Options/bla.xabsl"; /** The default agent */ agent default_agent("Default", foo); /** A test environment for the option bla */ agent test_behavior("Test", bla); The "agents.xabsl" has the following syntax: <agents definition file> ::= /*** Title: <title> Platform: <platform> Software-Environment: <software-environment> */ { include "<include file>"; } [<doc comment>] agent <id>("<agent-title>", <root-option>); { [<doc comment>] agent <id>("<agent-title>", <root-option>); } The title, platform, and software-environment elements are only used for generating the HTML documentation. In an XABSL behavior, the option graph doesn't need to be completely connected. So it is difficult to determine a single root option of the graph. Instead a sub-graph that is spanned by an option and all it's subsequent options and basic behaviors can be declared as an agent. So an agent defines a starting point into the option graph. Included files must contain option definitions for options to be used as agent root options. There has to be at least one agent element inside the agents definition file. It contains the following elements:
|
|||||||||||
Copyright 2002 - 2009 by the XABSL developer team. See the licence for details. | |||||||||||
|
|||||||||||