# Using AIML for creating gestures

Since more than a week I am working on a script to create gestures by talking or typing using AIML.

The goal is to talk to your robot like you would talk to a human. E.g. Let's learn some new moves, take the right hand, set thumb (or all others), open or close (also open/close less/more), and now the right arm, move forward, more forward, a little bit less, now up, up, more up, ok, now the right hand again, set......., and now the head, and now the torso and so on. At any time you can say: ok, save this motion and he will only ask for a name. With this name you can call up that motion or insert it later to any other existing pattern using the srai-tag.

This way you can create a gesture which includes any limb at any time, also includes all speeds and pause.

As the possibilities are very high (all limbs, all speeds for the limbs, all combinations), I need to avoid any kind of permutation. Otherwise I will end up in millions of possibilities. So I started to use multiple variables like a chain. Variabales inside variables, all set with predicates.

It's the first time I do such a complex script and I may set the goal very high. My algorithm is growing but still I didn't find the "key". Spending min. 10 hours these days I made it up to 3 times the same limp (e.g. set right hand, right arm, head, torso, head, torso, right hand, right arm, right hand and save all this as "monkey move"). Doing 4 times the same limb gives you 8 combinations (4, 3+1, 2+1+1, 1+1+2, 1+2+1,2+2,1+3 and 1+1+1+1+1). Seven work, one doesn't (1+2+1).

Lot's of times I need variables to execute but also to learn. If I use learn I can't change the predicates. If so, the learned motion doesn't have this value anymore. Catch 22 ;-)

Ok, I will set a limit anyway as it is very unlikely to use the e.g. right hand 20 times in only one saved move. But 6 or 8 times would be nice.

Here is the actual save-part:

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">

<topic name="SAVERH1">
<category><pattern># MOTION NAME IS #</pattern>
<template>Motion name is <star index="2"/>
<condition name="ALLSET">
<li><condition name="RH1SAVE" value="true">
<learn><category><pattern># SHOW MOTION <eval><star index="2"/></eval></pattern>
<template>This is the motion <eval><star index="2"/></eval>
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi1-1"/>,<get name="fi1-2"/>,<get name="fi1-3"/>,<get name="fi1-4"/>,<get name="fi1-5"/>,<get name="fi1-6"/>)
</param></mrl></oob></template></category></learn>
<think><set name="RH1SAVE">false</set></think></condition></li></condition></template>
</category></topic>

<topic name="SAVERH2">
<category><pattern># MOTION NAME IS #</pattern>
<template>Motion name is <star index="2"/>
<condition name="ALLSET">
<li><condition name="RH2SAVE">
<li value="true">
<learn><category><pattern># SHOW MOTION <eval><star index="2"/></eval></pattern>
<template>This is the motion <eval><star index="2"/></eval>
<condition name="RH1SAVE" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi1-1"/>,<get name="fi1-2"/>,<get name="fi1-3"/>,<get name="fi1-4"/>,<get name="fi1-5"/>,<get name="fi1-6"/>)
</param></mrl></oob></condition>
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi2-1"/>,<get name="fi2-2"/>,<get name="fi2-3"/>,<get name="fi2-4"/>,<get name="fi2-5"/>,<get name="fi2-6"/>)
</param></mrl></oob></template></category></learn>
</li></condition></li></condition></template>
</category></topic>

<topic name="SAVERH3">
<category><pattern># MOTION NAME IS #</pattern>
<template>Motion name is <star index="2"/>
<condition name="ALLSET">
<li><condition name="RH3SAVE">
<li value="true">
<learn><category><pattern># SHOW MOTION <eval><star index="2"/></eval></pattern>
<template>This is the motion <eval><star index="2"/></eval>
<condition name="RH2SAVE1" value="true">
<condition name="RH1SAVE" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi1-1"/>,<get name="fi1-2"/>,<get name="fi1-3"/>,<get name="fi1-4"/>,<get name="fi1-5"/>,<get name="fi1-6"/>)
</param></mrl></oob></condition>
<condition name="RH2SAVE" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi2-1"/>,<get name="fi2-2"/>,<get name="fi2-3"/>,<get name="fi2-4"/>,<get name="fi2-5"/>,<get name="fi2-6"/>)
</param></mrl></oob></condition></condition>
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi3-1"/>,<get name="fi3-2"/>,<get name="fi3-3"/>,<get name="fi3-4"/>,<get name="fi3-5"/>,<get name="fi3-6"/>)
</param></mrl></oob></template></category></learn><think><set name="RH3SAVE1">false</set></think>
</li></condition></li></condition></template>
</category></topic>

<topic name="SAVERH4">
<category><pattern># MOTION NAME IS #</pattern>
<template>Motion name is <star index="2"/>
<condition name="ALLSET">
<li><condition name="RH4SAVE">
<li value="true">
<learn><category><pattern># SHOW MOTION <eval><star index="2"/></eval></pattern>
<template>This is the motion <eval><star index="2"/></eval>
<condition name="RH2SAVE1" value="true">
<condition name="RH1SAVE" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi1-1"/>,<get name="fi1-2"/>,<get name="fi1-3"/>,<get name="fi1-4"/>,<get name="fi1-5"/>,<get name="fi1-6"/>)
</param></mrl></oob></condition>
<condition name="RH2SAVE" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi2-1"/>,<get name="fi2-2"/>,<get name="fi2-3"/>,<get name="fi2-4"/>,<get name="fi2-5"/>,<get name="fi2-6"/>)
</param></mrl></oob></condition></condition>
<condition name="RH3SAVE1" value="true">
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi3-1"/>,<get name="fi3-2"/>,<get name="fi3-3"/>,<get name="fi3-4"/>,<get name="fi3-5"/>,<get name="fi3-6"/>)
</param></mrl></oob></condition>
<oob><mrl><service>python</service><method>exec</method><param>
i01.moveHand("right",<get name="fi4-1"/>,<get name="fi4-2"/>,<get name="fi4-3"/>,<get name="fi4-4"/>,<get name="fi4-5"/>,<get name="fi4-6"/>)
</param></mrl></oob></template></category></learn><think><set name="RH4SAVE1">false</set></think>
</li></condition></li></condition></template>
</category></topic>

</aiml>

### Hi,   Can you tell me how to

Hi,

Can you tell me how to run this service ? I've tried the single exemple in the documentation -> Services page,

but i always get the error : core is not loaded .

I've created a folder named "ProgramAB" in the MRL folder and putted in the file "exemples.AIML" .

Thx

### Running ProgramAB

Hi beetle!

The MRL folder should already have a folder named ProgramAB with the Alice bot inside. No need to cretae a new one. I'm sure thats why you receive an error.

Locate the aiml folder and put the aiml files inside (e.g. C:\mrl\ProgramAB\bots\alice2\aiml).

Use these aiml files (agetest.aiml and birthday.aiml is not necessary):

https://github.com/MyRobotLab/pyrobotlab/tree/master/home/Mastablasta/aiml

And this is the Python script to start: https://github.com/MyRobotLab/pyrobotlab/blob/master/home/Mastablasta/st...

Hope it works for you, just keep on asking if you have trouble.

### Thx Mastabasta, but there

Thx Mastabasta, but there isn't the folder ProgramAB in my MRL folder, it's why i've tryed to create one ...

There isn't this service into the runtime tab of MRL, but it run well with pyhton . I get the tab of the service and the gui .

### Make a new folder like this

Make a new folder like this :

c:\mrl\1.0.95

runtime -> system -> install all

a ProgramAB folder should be installed in the process .. if not we'll have to fix it..

### Forget the prior aiml script

Finally I found a nice way to handle the situation. Much different so forget that confusion aiml file.

New video will be up soon.

### Hi, I've tried to run it from

Hi,

I've tried to run it from eclipse, and yoo-hoo ! the service is in the runtime tab and work well

With the last build version, it not work, even after "install all" .

Thx for your help, i will study a bit how all that work , but i must stop to try all lol !

Or Sweety will never advance !