emotion API structure

Following listing presents how robot's emotion modules were added to robot structure.

//setting PAD configuration
//we define four input ports for emotional system
PAD.setPort("anew",[[4,0,0],[0, 4, 0],[0,0,4]]); 
PAD.setPort("sentiwordnet",[[20,0],[0, 1],[0,0]]); 
PAD.setPort("weather",[[1,1,0,0],[0,0,1,0],[0,0,0,1]]); 
PAD.setPort("main",[[1,0,0],[0,1,0],[0,0,1]]); 
PAD.setK(1);
PAD.setT1(1);
PAD.setT2(0);
PAD.setKeepEmotion(false);
PAD.setBoredomRatio(0.995);
//we define set of attractors which affect robot emotional state
do(robot.emotion.attractor) { 
function ANEW()      {call.PADAttractorANEW();};
function SentiWordNet()    {call.PADAttractorSentiWordNet();};
function Weather()      {call.PADAttractorWeather();};
function ActNeutral(coefficient)  {call.PADAttractorActNeutral(coefficient);};
function ActBored(coefficient)  {call.PADAttractorActBored(coefficient);};
function UserLost()      {call.PADAttractorUserLost();};
function UserFound()      {call.PADAttractorUserFound();};
function GuessYes()      {call.PADAttractorGuessYes();};
function GuessNo()      {call.PADAttractorGuessNo();};
function DialogueTimeout()    {call.PADAttractorDialogueTimeout();};
function Content()      {call.PADAttractorContent();};
};
//example of simple attractor - robot gets happy after correct answer
function PADAttractorGuessYes(){
PAD.input("main",[0.4, 0.15,-0.25],0.1);
}|{}; 
//more complex example of attractor - current weather affects robot emotional state
function PADAttractorWeather(){
if (_RobotStructure.has("Network")) {
vr _temp = (robot.network.weather.condition.temperature-10)/20;
var _code = robot.network.weather.condition.code;
// fear
if ((_code>=0)&&(_code<=4)) PAD.input("weather",[-0.9,0.1,0.7,-0.8],0.1)
else if ((_code>=37)&&(_code<=39)) PAD.input("weather",[-0.9,0.1,0.7,-0.8],0.1)
// content
else if ((_code>=13)&&(_code<=15)) PAD.input("weather",[0.7,0.1,-0.6,0.2],0.1)
else if ((_code>=41)&&(_code<=43)) PAD.input("weather",[0.7,0.1,-0.6,0.2],0.1)
// sad
else if ((_code>=5)&&(_code<=12)) PAD.input("weather",[-0.7,0.1,-0.4,0.1],0.1)
else if ((_code>=35)&&(_code<=36)) PAD.input("weather",[-0.7,0.1,-0.4,0.1],0.1)
// only temperature
else PAD.input("weather",[0,1*_temp,-0.5,0.15],0.1);
};
}|{};

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation