In Digital Spaces, an Agent is semi-autonomous logical entity that is provided with medium level commands, such as "move in this direction", and is responsible for controlling the simulation components (often physics and visual entities) to enact and represent these commands.
Each Agent also provides a number of states, which may be toggled or blended, which further affect the behaviour of the representation.
- Note:
- Medium level commands are things like "move in this direction", "face this direction", "enter this state" and "cease this state". Low level commands are what needs to be done to implement the medium level commands. Often this is "apply physical force", "change physics motor parameters", or "trigger skeletal animation". In this context, a high level command would be something that produces multiple medium level commands. An example of this would be path finding.
Digital Spaces provides a range of agent types, whose behaviour can be configured by the use of .agent files. The provided agents are:
- Human - often used to represent the user, or computer controlled characters
- Vehicle - with sub-types Car and Tank, which affects the steering method
- Rover - uses independant wheel angles to behave between tank and car, see the Mars Exploration Rovers for an example
- Space - used to simulate a landing space vehicle, uses thrusters to move about, while maintaining vertical orientation.
- Robot - Uses states to present pre-set joint poses, in the same way as industrial robots
A reference for the .agent file format can be found at
http://www.digitalspaces.net/wiki/index.php/Agent_File_Format .
The simplest use of an agent is manual (user) control. Components are provided that send commands to the different types of Agents based on user input. Example fragement from the .space file:
<required id="{00519F89-B1DF-43d8-9B01-0EE069ADC16C}" >
<configuration id="{00519F89-B1DF-43d8-9B01-0EE069ADC16C}">
<agent src="vehicle.agent"/>
</configuration>
<required id="{96E29E53-95F9-4bd5-81D6-DB5FFC90675E}" />
</required>
The required id
{00519F89-B1DF-43d8-9B01-0EE069ADC16C} is the identifier for the VehicleAgentControl capability. Technically, it's the identifier for the configuration data format, which is what is used in the configuration section. The required id
{96E29E53-95F9-4bd5-81D6-DB5FFC90675E} is that of the Agent Manager, which provides the vehicle agent implementation.
The configuration format is simple. One or more <agent> tags are specified, with the src attribute indicating the name of the .agent format file. The Vehicle Agent Controller component takes care of passing these files to the Agent Manager as templates, then instancing an occurance of the specified template. The Vehicle Agent Controller displays a GUI with a box listing the one or more agents it has instanced, with the names based on the .agent filename. The user selects an agent they wish to control, and the Vehicle Agent Controller proceedes to read signals from the User Input component, convert these into driving directions, and passes it to the Agent.
The Vehicle Agent Controller is designed to work with a joystick. In Digital Spaces, joysticks are referred to as haptic devices, as our joystick support also includes force feedback.
While the Controller systems provide a convenient way of loading an agent, you will not always want to load an agent through a controller. Often you will want to control an Agent using higher level logic, that will produce mid-level commands for the Agent. Here is an example of loading an agent template, and instancing an agent from that template, at load time:
<required id="{96E29E53-95F9-4bd5-81D6-DB5FFC90675E}" >
<configuration id="{E7720449-338B-4bfc-88CC-331C506E1210}">
<template name="car_template" src="car_file.agent"/>
<agent name="car#1" src="car_template"/>
</configuration>
</required>
Creating an Agent occurs in two parts. First you need to prepare an Agent Template. This is the step performed by the <template> entry in the configuration. A Template is created using a unique name, by which it will be referred to in the future. The src (source) of the template is a .agent file. A Template can be used more then once, as long as the .agent specification has been prepared correctly.
Once the Template is available, an Agent can be instanced. That is what the the <agent> entry does. It creates an agent with the specified name, using the source (src) template.
This in and of itself is not terribly useful. However, you can use the GetAgent function of the DIAgentManager interface to get access to this instanced Agent, and start issuing it commands through a script or component.
A useful thing to do with an Agent is to have it follow a series of pre-programmed waypoints.
<configuration id="{C839015B-AD67-4a5d-9E18-4B0F9644BC29}">
<source file="source.file.xml" /> <!-- Supports multiple source entries -->
<tolerance x="1.0" y="1.0" z="1.0" />
<spawnagent enabled="true" />
<waypointsvisible enabled="true" />
<removeagent enabled="true" />
<loopagent enabled="true" />
</configuration>
The waypoint source file format can be seen at
http://www.digitalspaces.net/wiki/index.php/Waypoint_File_Format . Using the AgentManager_Waypoint component allows you to have one or more Agents following one or more paths in your Space without needing to program any additional logic. This component also provides an editing interface (displayed using Windows -> Show All) to make in-scene waypoint editing easier.