EZ Robot Commands SIML Framework - New command creation step to step
To better illustrate , below are a step to step example some new commands Instructions are for English configuration.
Adding Take Photo Command
Think first at the phrase structure - can be : "photograph" , "take" or "shoot" or "do" "a photo" , and same ("take" or "shoot" or "do") with "photo" , "picture" ,"a picture" , "snapshot" , "a snapshot"
We have 4 verb forms - Do , Shoot , Take and Photograph Do is already configured - Shoot , Take and Photograph need to be created. We have a complement with several possible forms : picture , photo , a picture , a photo , a photography , ...... The best way is to create a complement with CAMERA prefix for exemple CAMERA_PHOTO
Lets go
map movement_verb_1_en
[MapItem Content="do" Value="%F NO DO" /]
[MapItem Content="shoot" Value="%F NO SHOOT" /]
[MapItem Content="take" Value="%F NO TAKE" /]
[MapItem Content="photograph" Value="%F COMP TAKE" /]
map synonym_movement_en
[MapItem Content="photograph" Value="a picture" /]
map movement_verb_group
[MapItem Content="DO" Value="% ACOMP_APOS EMPTY EMPTY NO ALL DO DO" /]
[MapItem Content="TAKE" Value="% MCOMP EMPTY EMPTY NO ALL TAKE TAKE" /]
[MapItem Content="SHOOT" Value="% ACOMP EMPTY EMPTY NO ALL SHOOT SHOOT" /]
map verb_complement_en
[MapItem Content="a snapshot" Value="picture" /]
[MapItem Content="snapshot" Value="picture" /]
[MapItem Content="a photography" Value="picture" /]
[MapItem Content="photography" Value="picture" /]
[MapItem Content="a photo" Value="picture" /]
[MapItem Content="photo" Value="picture" /]
[MapItem Content="a picture" Value="picture" /]
[MapItem Content="picture" Value="% CAMERA_PHOTO" /]
map verb_complement_group
[MapItem Content="0|CAMERA_PHOTO" Value="%F NO NO WITHCAM CAMERA_PHOTO CAMERA_PHOTO" /]
map combination_verb_comp_att_pos
[MapItem Content="0|SHOOT|CAMERA_PHOTO|EMPTY|EMPTY" Value="% NO NO EMPTY WITHCAM" /]
[MapItem Content="0|TAKE|CAMERA_PHOTO|EMPTY|EMPTY" Value="% NO NO EMPTY WITHCAM" /]
[MapItem Content="0|DO|CAMERA_PHOTO|EMPTY|EMPTY" Value="% NO NO EMPTY WITHCAM" /]
In EZ Robot request - Bot Response Message building SIML File Variable Workflag will be set to CAMERA_PHOTO_DO CAMERA_PHOTO_TAKE and CAMERA_PHOTO_SHOOT
We can configure synonyms in map synonym_action_robot
[MapItem Content="0|CAMERA_PHOTO_SHOOT" Value="% CAMERA_PHOTO_TAKE" /]
[MapItem Content="0|CAMERA_PHOTO_DO" Value="% CAMERA_PHOTO_TAKE" /]
And Add in the [Switch Var="Workflag"] code in Bot Response Message building SIML File the following lines
[Case Value="CAMERA_PHOTO_TAKE"]
[Var Set="flagcam"][x:EZvar Get="IsCameraActive" /][/Var]
[If Var="flagcam" Value="0"]
[Var Set="Aigui"]7[/Var]
[Var Set="idmesscamstopped"]Camera_inactive_[User Get="Userlanguage" /][/Var]
[Var Set="mess2"][Random Get="{Bind Var:idmesscamstopped}" /][/Var]
[/If]
[Else][Var Set="tempcommand"]ControlCommand("Camera", CameraSnapshot)[/Var][/Else]
[/Case]
And test first in the Synbot Studio Console then in SynBot Plugin And It's Working if camera is active......
In my Robot Pictures Folder :
Adding Command for verb Trample
Trample is walking at the same place - so we will generate EZ Builder AutoPosition Action SHIMMY Lets go
map movement_verb_1_en
[MapItem Content="trample" Value="%F NO TRAMPLE" /]
map movement_verb_group
[MapItem Content="TRAMPLE" Value="% DIRECT EMPTY EMPTY NO ALL TRAMPLE SHIMMY" /]
map combination_verb_comp_att_pos
[MapItem Content="0|TRAMPLE|EMPTY|EMPTY|EMPTY" Value="% NO NO EMPTY EMPTY" /]
Next add code in Bot Response Message building SIML File for value of WorkFlag SHIMMY
[Case Value="SHIMMY"][Var Set="EZaction"]Shimmy[/Var][/Case]
And test first in the Synbot Studio Console then in SynBot Plugin
And It's Working
Adding Commands to manage volume of sound
A little bit more tricky , We will add some commands to manage EZB sound volume :
Lower , decrease , reduce , lessen sound
Increase , augment , raise sound
Increase , augment , raise sound to the max , to a [volume level]
push sound to maximum , to a [volume level]
Lower , decrease , reduce , lessen sound to the min, to zero , to a [volume level]
Cut sound
Put , set sound to the max , to the mean , to zero , to the min , to a [volume level]
We will Set [Verb] [Complement] [FreeAttribute] structure with Up and Down [Movement Direction]
So we first create entry for a new Complement SOUND
adding keywords for sound in map verb_complement_en
[Map Name="verb_complement_en"] [MapItem Content="the volume of sound" Value="sound" /] [MapItem Content="your volume of sound" Value="sound" /] [MapItem Content="the volume" Value="sound" /] [MapItem Content="your volume" Value="sound" /] [MapItem Content="the sound" Value="sound" /] [MapItem Content="your sound" Value="sound" /] [MapItem Content="volume" Value="sound" /] [MapItem Content="sound" Value="%F SOUND" /]
and in map verb_complement_group
[MapItem Content="0|SOUND" Value="%F UD NO ALL SOUND SOUND" /]
We will use 3 maps to control free attribute values - one for global , one for max and one for min
[Map Name="Volumecomplement"] [MapItem Content="en|maximum" Value="%2 EMPTY MAX" /] [MapItem Content="en|max" Value="en|maximum" /] [MapItem Content="en|highest" Value="en|maximum" /] [MapItem Content="en|fullest" Value="en|maximum" /] [MapItem Content="en|utmost" Value="en|maximum" /] [MapItem Content="en|minimum" Value="%2 EMPTY MIN" /] [MapItem Content="en|min" Value="en|minimum" /] [MapItem Content="en|lowest" Value="en|minimum" /] [MapItem Content="en|zero" Value="en|minimum" /] [MapItem Content="en|mean" Value="%2 EMPTY MEAN" /] [MapItem Content="en|average" Value="en|mean" /] [MapItem Content="en|medium" Value="en|mean" /] [MapItem Content="fr|maximum" Value="%2 EMPTY MAX" /] [MapItem Content="fr|max" Value="fr|maximum" /] [MapItem Content="fr|fond" Value="fr|maximum" /] [MapItem Content="fr|plein tube" Value="fr|maximum" /] [MapItem Content="fr|minimum" Value="%2 EMPTY MIN" /] [MapItem Content="fr|mini" Value="fr|minimum" /] [MapItem Content="fr|plus bas" Value="fr|minimum" /] [MapItem Content="fr|zero" Value="fr|minimum" /] [MapItem Content="fr|medium" Value="%2 EMPTY MEAN" /] [/Map] [Map Name="Volumemaxcomplement"] [MapItem Content="en|maximum" Value="%2 EMPTY MAX" /] [MapItem Content="en|max" Value="en|maximum" /] [MapItem Content="en|highest" Value="en|maximum" /] [MapItem Content="en|fullest" Value="en|maximum" /] [MapItem Content="en|utmost" Value="en|maximum" /] [MapItem Content="fr|maximum" Value="%2 EMPTY MAX" /] [MapItem Content="fr|max" Value="fr|maximum" /] [MapItem Content="fr|fond" Value="fr|maximum" /] [MapItem Content="fr|plein tube" Value="fr|maximum" /] [MapItem Content="en|mean" Value="%2 EMPTY MEAN" /] [MapItem Content="en|average" Value="en|mean" /] [MapItem Content="en|medium" Value="en|mean" /] [MapItem Content="fr|medium" Value="%2 EMPTY MEAN" /] [/Map] [Map Name="Volumemincomplement"] [MapItem Content="en|minimum" Value="%2 EMPTY MIN" /] [MapItem Content="en|min" Value="en|minimum" /] [MapItem Content="en|lowest" Value="en|minimum" /] [MapItem Content="en|zero" Value="en|minimum" /] [MapItem Content="fr|minimum" Value="%2 EMPTY MIN" /] [MapItem Content="fr|mini" Value="fr|minimum" /] [MapItem Content="fr|plus bas" Value="fr|minimum" /] [MapItem Content="fr|zero" Value="fr|minimum" /] [MapItem Content="en|mean" Value="%2 EMPTY MEAN" /] [MapItem Content="en|average" Value="en|mean" /] [MapItem Content="en|medium" Value="en|mean" /] [MapItem Content="fr|medium" Value="%2 EMPTY MEAN" /] [/Map]
Note in the map content value "%2 EMPTY MAX" the third word which will be used in building command.
We need to be careful , because lower verb is already used with a synonym defined in map synonym_movement_en
[MapItem Content="LOWER" Value="% MCOMP EMPTY EMPTY NO EMPTY MOVE MOVE" /]
[MapItem Content="lower" Value="down" /]
As the AuthoID MOVE is shared with other verbs , we need first to change it to a not used MOVEDOWN
[MapItem Content="LOWER" Value="% MCOMP EMPTY EMPTY NO EMPTY MOVEDOWN MOVE" /]
and to add in combination map
[MapItem Content="0|MOVEDOWN|ARMS|EMPTY|EMPTY" Value="% MOVENEED EMPTY EMPTY EMPTY" /] [MapItem Content="0|MOVEDOWN|ARM|EMPTY|EMPTY" Value="% MOVENEED EMPTY EMPTY EMPTY" /] [MapItem Content="0|MOVEDOWN|HAND|EMPTY|EMPTY" Value="% MOVENEED EMPTY EMPTY EMPTY" /] [MapItem Content="0|MOVEDOWN|HEAD|EMPTY|EMPTY" Value="% MOVENEED EMPTY EMPTY EMPTY" /] [MapItem Content="0|MOVEDOWN|CAMERA|EMPTY|EMPTY" Value="% MOVENEED EMPTY EMPTY WITHMOVINGCAM" /] MapItem Content="0|MOVEDOWN|SOUND|EMPTY|EMPTY" Value="% MOVENEEDFREEPOSSIBLEDECODE1 EMPTY EMPTY EMPTY Volumemincomplement TO NOTHE NUMERIC EMPTY" /]
Note that in order to be able to understood "Lower sound to minimum" , we add FREEPOSSIBLE and control of free attribute in map Volumemincomplement
Note also than in order to be able to understand "Lower Sound to 67", we add a NUMERIC Control Keyword which means that if Free attribute value is not found in map Volumemincomplement
A numeric Control will be done to validate or not the free attribute value
Note the option DECODE1 used and the TO mnemonic for preposition authorization flags word and the NOTHE mnemonic for article authorization flag.
"Lower sound TO min" and "Lower sound TO THE min" will be accepted and will return "min" as free attribute value after decoding.
in map movement_verb1_en , we need to create entries for the new verbs
[MapItem Content="decrease" Value="%F DIR DECREASE" /] [MapItem Content="reduce" Value="decrease" /] [MapItem Content="lessen" Value="decrease" /] [MapItem Content="increase" Value="%F DIR INCREASE" /] [MapItem Content="raise" Value="increase" /] [MapItem Content="augment" Value="increase" /]
and to create synonyms in map synonym_movement_en
[MapItem Content="increase" Value="up" /] [MapItem Content="decrease" Value="down" /]
and to add entries in map movement_verb_group
[MapItem Content="INCREASE" Value="% MCOMP EMPTY EMPTY NO EMPTY MOVEDOWN MOVE" /] [MapItem Content="DECREASE" Value="% MCOMP EMPTY EMPTY NO EMPTY MOVEUP MOVE" /]
We add entry for MOVEUP Authoid in combination map with control of free attribute in map Volumemaxcomplement
[MapItem Content="0|MOVEUP|SOUND|EMPTY|EMPTY" Value="% MOVENEEDFREEPOSSIBLEDECODE1 EMPTY EMPTY EMPTY Volumemaxcomplement TO NOTHE NUMERIC EMPTY" /]
We create next verb entries in map movement_verb1_en for verbs put (Already existing) set , push and cut
[MapItem Content="set" Value="%F NO SET" /] [MapItem Content="push" Value="%F NO PUSH" /] [MapItem Content="cut" Value="%F NO CUT" /]
and in map movement_verb_group
[MapItem Content="SET" Value="% MCOMP EMPTY EMPTY NO EMPTY SET SET" /] [MapItem Content="PUSH" Value="% MCOMP EMPTY EMPTY NO EMPTY PUSH PUSH" /] [MapItem Content="CUT" Value="% MCOMP EMPTY EMPTY NO EMPTY CUT CUT" /]
We add entries to combination map for new verbs Authoid
[MapItem Content="0|PUT|SOUND|EMPTY|EMPTY" Value="% FREENEEDDECODE1 NO EMPTY EMPTY Volumecomplement TO NOTHE NUMERIC EMPTY" /] [MapItem Content="0|SET|SOUND|EMPTY|EMPTY" Value="% FREENEEDDECODE1 NO EMPTY EMPTY Volumecomplement TO NOTHE NUMERIC EMPTY" /] [MapItem Content="0|PUSH|SOUND|EMPTY|EMPTY" Value="% FREENEEDDECODE1 NO EMPTY EMPTY Volumemaxcomplement TO NOTHE NUMERIC EMPTY" /] [MapItem Content="0|CUT|SOUND|EMPTY|EMPTY" Value="% NO EMPTY EMPTY EMPTY" /]
As action will be similar , we gather in map synonym_action_robot the workflag value generated into one
[MapItem Content="0|SOUND_SET" Value="% SOUNDVOLUME" /] [MapItem Content="0|SOUND_PUT" Value="% SOUNDVOLUME" /] [MapItem Content="0|SOUND_PUSH" Value="% SOUNDVOLUME" /]
Now we need to create code for sound increasing and decreasing in EZ Robot request - Bot Response Message building SIML file with 3 new Workflag values : SOUND_U and SOUND_D and SOUNDVOLUME
[Case Value="SOUND_U"][Var Set="Aigui"]1[/Var][Var Set="Gotofunction"]SOUND_CHANGE UP [User Get="Complementactionfree" /][/Var][/Case] [Case Value="SOUND_D"][Var Set="Aigui"]1[/Var][Var Set="Gotofunction"]SOUND_CHANGE DOWN [User Get="Complementactionfree" /][/Var][/Case] [Case Value="SOUND_CUT"][Var Set="Aigui"]1[/Var][Var Set="Gotofunction"]SOUND_CHANGE SET 0[/Var][/Case] [Case Value="SOUNDVOLUME"][Var Set="Aigui"]1[/Var][Var Set="Gotofunction"]SOUND_CHANGE SET [User Get="Complementactionfree" /][/Var][/Case]
With redirections to model XXXXXXXPROCESSCOMMAND_SOUND_CHANGE first parameter (UP , DOWN , SET) and second parameter (MAX , MIN , MEAN or number)
Note that Variable Complementactionfree is automatically set in the framework either to the third word in entry content of map used to control the free attribute value or if entry not found in map to the decoded value of free attribute.
[Model]
[Pattern]XXXXXXXPROCESSCOMMAND_SOUND_CHANGE [MAP:KEYVOLUME] $[/Pattern]
[Response xml:space="preserve"]
[Think]
[!--Get first current volume of EZB Sound --]
[Var Set="currentvolume"][x:EZcmd]Print(GetVolume())[/x:EZcmd][/Var]
[If Var="currentvolume" Value=""][Var Set="currentvolume"]0[/Var][/If]
[Var Set="upordown"][Match /][/Var]
[Var Set="volumelevel"][Match At="2" /][/Var]
[If Var="upordown" Value="DOWN"][Var Set="newvolume"][Math][Var Get="currentvolume" /]-[Bot Get="Deltasoundvolume" /][/Math][/Var][Var Set="newvolumebis"]200[/Var][/If]
[If Var="upordown" Value="UP"][Var Set="newvolume"][Math][Var Get="currentvolume" /]+[Bot Get="Deltasoundvolume" /][/Math][/Var][Var Set="newvolumebis"]0[/Var][/If]
[Switch Var="volumelevel"]
[Case Value="MAX"][Var Set="newvolumebis"]200[/Var][/Case]
[Case Value="MIN"][Var Set="newvolumebis"]0[/Var][/Case]
[Case Value="MEAN"][Var Set="newvolumebis"]80[/Var][/Case]
[Case Value=""][Var Set="Nolevel"]1[/Var][/Case]
[Default][Var Set="newvolumebis"][Var Get="volumelevel" /][/Var][/Default]
[/Switch]
[Switch Var="Temperror"]
[Case Value=""]
[If Var="Nolevel" Value="1"][Var Set="newvolumebis"][Var Get="newvolume" /][/Var][/If]
[If Var="newvolumebis" LT="0"][Var Set="newvolumebis"]0[/Var][/If]
[If Var="newvolumebis" GT="200"][Var Set="newvolumebis"]200[/Var][/If]
[User Set="bot_event_response"][Var Get="mess1" /]Setvolume([Var Get="newvolumebis" /])[/User]
[/Case]
[Default]
[!--Case trying to Up to a value lower than current volume or Down to a value greater than current volume--]
[/Default]
[/Switch]
[/Think]
[/Response]
[/Model]
Where we first get the current EZB Sound volume , next compute the new volume to set depending on UP and Down parameter
next test the second parameter if present, and finally build the response message with the EZB Command Setvolume.
We will add some more commands :
Sing Less loud and Sing Louder
Speak Less loud and Speak louder
Here we will use structure [Verb] [Attribute]
We first create entries in map complement_attribut_en
[MapItem Content="louder" Value="%T SOUNDVOLUME UP" /] [MapItem Content="less loud" Value="%T SOUNDVOLUME DOWN" /]
We create SOUNDVOLUME entry in map complement_attribut_group
[MapItem Content="SOUNDVOLUME" Value="% SOUNDVOLUME1" /]
As speak verb is not existing we create it in maps movement_verb_1_en and in movement_verb_group
[MapItem Content="speak" Value="%F NO SPEAK" /]
[MapItem Content="SPEAK" Value="% DIRECT EMPTY EMPTY NO ALL SPEAK SPEAK" /]
We add next the combination map entries in map combination_verb_comp_att_pos
Note we add also a combination entry for Speak without attribute to enable the "speak" input - As ATTNEED - Bot will ask precision to the user
[MapItem Content="0|SING|EMPTY|SOUNDVOLUME1|EMPTY" Value="% ATTNEED NO EMPTY EMPTY" /] [MapItem Content="0|SPEAK|EMPTY|SOUNDVOLUME1|EMPTY" Value="% ATTNEED NO EMPTY EMPTY" /] [MapItem Content="0|SPEAK|EMPTY|EMPTY|EMPTY" Value="% ATTNEED NO EMPTY EMPTY" /]
We add code for workflag SOUNDVOLUME1 in Bot Response Message building SIML file.
[Case Value="SOUNDVOLUME1"][Var Set="Aigui"]1[/Var][Var Set="Gotofunction"]SOUND_CHANGE [User Get="attributeargument" /][/Var][/Case]
Note that variable attributeargument is automatically set with the third word of entry in map complement_attribut_en ( UP OR DOWN)
And finally , we want our bot to answer to question about the level of sound volume - For example What's your sound volume , give me the volume of your sound , ......
Just add entry values in map direct_question_object_en
[Map Name="direct_question_object_en"]
[MapItem Content="your sound volume" Value="%M SOUNDVOLUME" /]
[MapItem Content="the volume of your sound" Value="%M SOUNDVOLUME" /]
[MapItem Content="volume of your sound" Value="%M SOUNDVOLUME" /]
And create code with SOUNDVOLUME keyword in SIML file EZ Robot Request - Queries
[Model] [Pattern] [Item]XXXXXQUERYEZZZ SOUNDVOLUME[/Item] [/Pattern] [Response xml:space="preserve"] [Think] [Switch User="Userlanguage"] [Case Value="fr"][Var Think:Set="Libresponse"]Mon volume sonore est actuellement de [/Var][/Case] [Case Value="en"][Var Think:Set="Libresponse"]My Sound volume is actually to [/Var][/Case] [/Switch] [User Think:Set="bot_event_response"][Var Get="Libresponse" /][x:EZcmd]Print(GetVolume())[/x:EZcmd][/User] [/Think] [/Response] [/Model] [Model]
Everything is working fine ....