-
Notifications
You must be signed in to change notification settings - Fork 4
Core Communication Modules
- Transport
- Core Agent
- [N-tuple Templates(https://github.com/icsi-berkeley/framework_code/wiki/Core-Communication-Modules#n-tuple-templates)
The language and action modules are bridged by shared action protocols we call n-tuples. Both the Problem Solver and Specializer have access to n-tuple templates, which are JSON structures oriented towards particular tasks, action, and information retrieval. The Specializer uses information from the SemSpec to fill in a template; the filled-in template is called an n-tuple. This is then transported over a network to the Problem Solver.
See the Transport documentation for more information.
The Core Agent defines a class that has the ability to send and receive n-tuples. Both the Core UI-Agent and the Core Problem Solver subclass the Core Agent.
A Core Agent is designed to be easy to initialize. The only required argument is the desired name of the channel, e.g.:
python core_agent.py Agent1
The above command would create a CoreAgent with a channel name of "Agent1". All CoreAgents have a Transport object as a field attribute, as well as:
- Name ("Agent1")
- Federation (by default, this is set to "FED1")
- Address (the concatenation of a federation and a name, such as "FED1_Agent1")
The federation is an important attribute, since it helps avoid potential name collisions, in the event of running multiple same-named agents on the same network. The federation can be set with an environment variable, e.g.:
export $ECG_FED=FED1
Optionally, the user can also designate a log-file and a log-level, in which to log errors or messages.
read_templates(self, filename)
This method reads in a JSON file from the given filename, and returns an OrderedDict of templates. Since a user can specify an inheritance hierarchy for templates, this method also updates a "child" with the key/value pairs of its "parent", unless a particular key/value pair is overridden. If a specified parent does not exist, the method raises a TemplateException, which should cause the program to quit (as this is almost certainly an error).
Whenever a CoreAgent subscribes to a particular channel, it passes in a callback method, which is called whenever the CoreAgent receives an n-tuple from that channel name. The CoreAgent defines a simple callback method, which just prints out the received n-tuple. Both the UI-Agent and Problem Solver override this callback method as part of their default behavior. Additional callbacks can be written for different purposes, and to subscribe to different channels.
N-tuple templates serve two primary functions in our system:
- Declarative instructions: While building an n-tuple, the templates act as declarative specifications for which aspects of the Semantic Specification the Core Specializer should extract, and give instructions on how the output should be formatted.
- Shared semantics: Templates are oriented towards particular tasks, and are shared between the Specializer and Problem Solver, which establishes a shared vocabulary and semantics between a human user and a robot agent (or other task).