Robot/Process Extensions
This section describes a simple network API that Brainhat
supports for interaction with robots and other processes.
Set-up involves several steps:
Sample robot server code (roboipc) can be found in the distribution.
You can use it to test robot interaction with Brainhat without
a robot.
Simply compile and run.
Incorporating Command Processing
This could be the equivalent of a robot command:
"put the red ball in the bin."
The tag value is a unique identifier that the robot and Brainhat
share to track the state of a delegated command.
We will see how it used, below.
The command is a primitive action that the robot will understand.
Examples might be get, put or position.
The vocabulary of verbs that the robot might use is virtually
unlimited, and you may extend it as you like.
External action verbs for robot (and other) commands
are identified in the data files as children of a
special concept called extaction, as in:
Extaction verbs are organized the same as others, with an infinitive
form and subordinate forms connected as children.
They may be used for non-robot commands, just as any other verb.
Object is the object the robot is manipulating.
Target, when present, will be the object of the preposition
for commands that specify a source or destination for an action.
Likewise, orientation will be the preposition for those
commands that specify a source or destination.
The sample above shows "color=red" as one of the elements of the
command to the robot.
"Color" is not a primitive for robot commands.
Rather, "color" just happens to be non-prepositional attribute associated with
the object in the example (the ball).
Any other attribute might have been included as well.
If the ball was big, for example, a attribute/value pair like
"size=big" might have been part of the command.
Accordingly, the number and variety of attribute/value pairs is
unlimited.
How you dispatch commands within the robot depends the robot or service
you have created.
When the command is completed, the robot should inform Brainhat so that
Brainhat can direct the robot to the next task and/or tell the speaker
that the command is finished.
Here's what you need to do:
If the command completes successfully, the robot may simply send Brainhat
an acknowledgement.
The syntax for the successful completion is:
where "#####" represents the tag number taken from the command
as delegated to the robot by Brainhat.
The "Y" stands for "yes" (meaning completion was successful).
To finish our example above, for instance, the robot
would send Brainhat the message:
Upon receipt of the message, Brainhat would tell the speaker
"the robot did put the ball in the bin."
You may also change the "Y" to an "N" to signify failure:
Brainhat will inform the speaker
"the robot did not put the ball in the bin" and
perform any follow-on action associated with the failure.
You may tack on a reason as well, if you like:
Brainhat will report
"the robot did not put the ball in the bin because the ball is lost."
Messages from the robot do not have to be associated with commands.
At any time you can send Brainhat a message without a tag, such as
Brainhat will voice the message and incorporate it into the
conversation just as if it had come from the user.
Note that the messages to Brainhat can come asynchronously, while
Brainhat is busy doing other things; no sequencing is necessary.
Likewise, you may issue many messages to Brainhat.
They will be processed as they arrive.
Identifying the Robot(s) to Brainhat
At runtime, when you delegate commands to robby, Brainhat will
be able to tell that robby robot is an instance of xrobot
via the child command above.
Telling Brainhat where the Robot(s) are
As soon as you identify a robot to Brainhat, the program will
attempt a connection.
Successful, all subsequent communications to robby robot will go out to the
address and port specified.
Once the command is given to Brainhat, it will be delegated to the
waiting robot.
(Just to review: the verb must be a child of extaction, the
robot must be a child of xrobot, and the robot must be
connected.)
Of course, robots only become really useful when they can be left
alone to complete a task.
With Brainhat, you can mete out the components of a complex
undertaking by combining robot execution with Brainhat's
capability to exercise propositions.
The conversation starts when the speaker says "i'm hungry."
Brainhat then delegates the jobs of getting a hotdog and beer to
the robot.
When both items are delivered, Brainhat asks if the speaker
is happy.
To try this scenario out, run a copy of roboipc,
and tell Brainhat "robby's address is 127.0.0.1"
Robot commands will appear in the roboipc window.
Respond "#####:Y" to each of the robot requests as detailed above.
|