/// <summary> /// TODO: load from XML files /// </summary> private void LoadBehaviors() { // Pointing // Forward X = 400D; Y = 0D; Z = 0D; // Up right X = 400D; Y = -500D; Z = 600D; //IBehaviorProfile Pointing = new BehaviorProfilePointing(); IBehaviorProfile Pointing = new BehaviorProfilePointingOmni(400D, -500D, 600D); // up right IBehaviorProfile PointingForward = new BehaviorProfilePointingOmni(400D, 0, 0); IBehaviorProfile PointingRight = new BehaviorProfilePointingOmni(400D, -600D, -150D); // x should not small, z should not big IBehaviorProfile PointingUp = new BehaviorProfilePointingOmni(100D, -200D, 400D); IBehaviorProfile PointingFrontDown = new BehaviorProfilePointingOmni(400D, 50D, -200D); // Direction/Position/Shape IBehaviorProfile FromAToB = new BehaviorProfileFromAToB(); IBehaviorProfile OneTheOther = new BehaviorProfileOneTheOther(); IBehaviorProfile LRUD = new BehaviorProfileLRUD(); IBehaviorProfile Tiny = new BehaviorProfileTiny(); // Social IBehaviorProfile Waving = new BehaviorProfileWaving(); IBehaviorProfile Clap = new BehaviorProfileClap(); // Abstract IBehaviorProfile Capisce = new BehaviorProfileCapisce(); IBehaviorProfile CapisceRotate = new BehaviorProfileCapisceRotate(); IBehaviorProfile State = new BehaviorProfileState(); // ReverseCapisce (originally is left arm) IBehaviorProfile Propose = new BehaviorProfilePropose(); IBehaviorProfile HandOver = new BehaviorProfileHandOver(); IBehaviorProfile PushAside = new BehaviorProfilePushAside(); IBehaviorProfile Spread = new BehaviorProfileSpread(); IBehaviorProfile PressDown = new BehaviorProfilePressDown(); IBehaviorProfile ShowSide = new BehaviorProfileShowSide(); IBehaviorProfile Motivate = new BehaviorProfileMotivate(); // ShakeHands IBehaviorProfile Weigh = new BehaviorProfileWeigh(); IBehaviorProfile Convince = new BehaviorProfileConvince(); IBehaviorProfile ConvergeHands = new BehaviorProfileConvergeHands(); IBehaviorProfile Applaud = new BehaviorProfileApplaud(); // I; You IBehaviorProfile FirstMe = new BehaviorProfileFirstMe(); // raise hand + Me/I IBehaviorProfile First = new BehaviorProfileFirst(); IBehaviorProfile Me = new BehaviorProfileMe(); // Me/I IBehaviorProfile YouAndMe = new BehaviorProfileYouAndMe(); IBehaviorProfile MeAndYou = new BehaviorProfileMeAndYou(); // head-oriented movements IBehaviorProfile Nod = new BehaviorProfileNod(); IBehaviorProfile NoShakeHead = new BehaviorProfileNoShakeHead(); IBehaviorProfile LookAround = new BehaviorProfileLookAround(); IBehaviorProfile Think = new BehaviorProfileThink(); IBehaviorProfile PhotoHeadPose = new BehaviorProfilePhotoHeadPose(); // Leg movements IBehaviorProfile Balance = new BehaviorProfileBalance(); IBehaviorProfile LeanRight = new BehaviorProfileLeanRight(); // Torso IBehaviorProfile Bow = new BehaviorProfileBow(); IBehaviorProfile SmallBow = new BehaviorProfileSmallBow(); IBehaviorProfile StandHead = new BehaviorProfileStandHead(); IBehaviorProfile HeadPose = new BehaviorProfileHeadPose(); // Show sensors IBehaviorProfile ShowSonars = new BehaviorProfileShowSonars(); IBehaviorProfile ShowMic = new BehaviorProfileShowMic(); IBehaviorProfile ShowArmJoints = new BehaviorProfileRArmDOF(); IBehaviorProfile ShowArmJointsOneByOne = new BehaviorProfileRArmDOFOneByOne(); IBehaviorProfile ShowBody = new BehaviorProfileShowBody(); IBehaviorProfile ShowBiceps = new BehaviorProfileShowBiceps(); // Idle behavior IBehaviorProfile LegRandomMove = new BehaviorProfileLegRandomMove(); IBehaviorProfile HeadRandomScan = new BehaviorProfileHeadRandomScan(); // BehaviorGenerator = new Dictionary<string, IBehaviorProfile>(); // // Deictic AddBehavior("Pointing", Pointing); AddBehavior("PointForward", PointingForward); // pointing omni AddBehavior("PointLeft", PointingRight); // pointing omni; mirror right AddBehavior("PointRight", PointingRight); // pointing omni AddBehavior("PointUpRight", Pointing); // pointing omni AddBehavior("PointUpLeft", Pointing); // pointing omni AddBehavior("PointUp", PointingUp); AddBehavior("PointFrontDown", PointingFrontDown); // Direction/position/Shape AddBehavior("LRUD", LRUD); AddBehavior("FromAToB", FromAToB); AddBehavior("FromAToBLeft", FromAToB); AddBehavior("OneTheOther", OneTheOther); // used for comparing two AddBehavior("Tiny", Tiny); AddBehavior("WavyShape", PressDown); // TODO: not implemented yet // Social AddBehavior("Waving", Waving); AddBehavior("HelloEverybody", Waving); // just waving AddBehavior("Clap", Clap); AddBehavior("Applaud", Applaud); // Head-oriented AddBehavior("Nod", Nod); AddBehavior("No", NoShakeHead); AddBehavior("LookAround", LookAround); // Quiz AddBehavior("Think", Think); AddBehavior("PhotoHeadPose", PhotoHeadPose); // for taking a photo // Abstract AddBehavior("HandOver", HandOver); AddBehavior("HandOverLeft", HandOver); AddBehavior("HandOverBoth", HandOver); AddBehavior("PushAside", PushAside); AddBehavior("PushAsideLeft", PushAside); AddBehavior("PushAsideBoth", PushAside); AddBehavior("ShowSide", ShowSide); // avoid Hitler gestre; AddBehavior("ShowSideLeft", ShowSide); AddBehavior("Spread", Spread); // Can be used to point right bottom AddBehavior("SpreadLeft", Spread); // Can be used to point left bottom AddBehavior("SpreadBoth", Spread); AddBehavior("PressDown", PressDown); AddBehavior("PressDownLeft", PressDown); AddBehavior("PressDownBoth", PressDown); AddBehavior("State", State); // ReverseCapisce (originally is left arm) AddBehavior("StateLeft", State); // ReverseCapisce AddBehavior("Propose", Propose); // Propose an idea AddBehavior("ProposeLeft", Propose); // Propose an idea AddBehavior("Capisce", Capisce); // nip 捏手指; emphasize AddBehavior("CapisceLeft", Capisce); // nip 捏手指; emphasize AddBehavior("RotatingCapisce", CapisceRotate); // AddBehavior("RotatingCapisceLeft", CapisceRotate); // // Abstract double hands only AddBehavior("Motivate", Motivate); // originally ShakeHands AddBehavior("Weigh", Weigh); // AddBehavior("Convince", Convince); AddBehavior("ConvergeHands", ConvergeHands); // // Self-related; You AddBehavior("Intro", Me); // TODO: add leg movements AddBehavior("First", First); AddBehavior("FirstMe", FirstMe); AddBehavior("Me", Me); AddBehavior("MeLeft", Me); AddBehavior("YouAndMe", YouAndMe); AddBehavior("YouAndMeLeft", YouAndMe); AddBehavior("MeAndYou", MeAndYou); AddBehavior("MeAndYouLeft", MeAndYou); AddBehavior("You", PointingForward); // Show sensors/effectors/functions AddBehavior("ShowArmJoints", ShowArmJoints); AddBehavior("ShowArmJointsOneByOne", ShowArmJointsOneByOne); AddBehavior("ShowChest", ShowSonars); AddBehavior("ShowMic", ShowMic); AddBehavior("ShowMicLeft", ShowMic); // used for showing Tactile sensors on the head AddBehavior("ShowBiceps", ShowBiceps); AddBehavior("ShowBody", ShowBody); // Torso AddBehavior("Bow", Bow); AddBehavior("SmallBow", SmallBow); AddBehavior("StandHead", StandHead); AddBehavior("HeadPose", HeadPose); // Leg AddBehavior("LeanRight", LeanRight); AddBehavior("Balance", Balance); // IdleBehavior AddBehavior("LegRandomMove", LegRandomMove); AddBehavior("HeadRandomScan", HeadRandomScan); LoadCrgBehaviors(); }
public MessageEventArgs MessageHandler(string sendfrom, MessageEventArgs message) { if(message.MsgType==MessageEventArgs.MessageType.COMMAND) { if (message.Cmd == "Say") { string texttosay = message.CmdArgs[0]; // Change robot mood if (this.NaoAffect.SentiAffect.SentiTextEnabled) // a CheckBox needs to be checked manually { //SendMessage("TextSentiment", new MessageEventArgs("TextSenti", new string [] {texttosay})); MessageEventArgs backdata = this.NaoAffect.SentiAffect.MessageHandler(this.ID, new MessageEventArgs("TextSenti", new string[] { texttosay })); double valence = (double)backdata.DataReturn; } NaoClient.Say(texttosay); } else if (message.Cmd == "ChangeRobotMood") { string moodstr = message.CmdArgs[0]; string[] vad = moodstr.Split(','); string valence = vad[0]; //string arousal = vad[1]; //string dominance = vad[2]; Invoke((MethodInvoker)delegate(){ this.NaoAffect.Valence = double.Parse(valence); }); this.NaoAffect.SentiAffect.MessageHandler(this.ID, new MessageEventArgs("ChangeRobotMood", new string[] { valence })); } else if (message.Cmd == "PointToRaisedHands") // respond to students' raising hands { double y = Convert.ToDouble(message.CmdArgs[0]), z = Convert.ToDouble(message.CmdArgs[1]), x = 400; IBehaviorProfile prh = new BehaviorProfilePointingOmni(x, y, z); MotionTimeline mtl = prh.LoadBehavior(0); NaoClient.ExecuteBehaviorInQueue(mtl); } else if (message.Cmd == "CheckBehavior") { string behaviorname = message.CmdArgs[0]; bool b = false; if (behaviorname == "Twinkle" || behaviorname == "GangnamLong" || behaviorname == "Wink" || behaviorname == "Kick" || behaviorname == "StandHead" || behaviorname == "AllOn" || behaviorname == "AllOff" || behaviorname == "EyesOn" || behaviorname == "EyesOff" || behaviorname == "RandomEyes" || behaviorname == "Walk" || behaviorname == "StandUp" || behaviorname == "Squat" || behaviorname == "Pushups" || behaviorname == "Macarena") b = true; // temp solution else b= this.BehaviorGenerator.ContainsKey(behaviorname); return new MessageEventArgs(b as object); } else if (message.Cmd == "ExecuteBehavior") { string behaviorname = message.CmdArgs[0]; HandleBehavior(behaviorname); } else if (message.Cmd == "CapturePhoto") { string imgfile = HandleCameraPhoto(); return new MessageEventArgs(imgfile); } else if (message.Cmd == "Config") { string config = message.CmdArgs[0]; if (config == "text_senti_enabled") // maybe put into SentiAffect itself { this.NaoAffect.SentiAffect.MessageHandler(this.ID, new MessageEventArgs("TextSentiStart", new string[] { })); } else if (config == "constant_head") { this.NaoClient.RecoverHead = false; } else if (config == "forwardlooking_head") { this.NaoClient.HeadYawInhibition = true; } else if (config == "freelooking_head") { this.NaoClient.HeadYawInhibition = false; } else { ConfigRobot(config); } } else if (message.Cmd == "CheckIdleMoveConflicts") { string behaviorname = message.CmdArgs[0]; if (IsLegInvolved(behaviorname)) { if (this.NaoIdleMoveLeg != null) this.NaoIdleMoveLeg.Stop(); } //if (IsHeadInvolved(behaviorname)) //{ // if (this.NaoIdleMoveHead != null) this.NaoIdleMoveHead.Stop(); //} } } else if(message.MsgType == MessageEventArgs.MessageType.TEXT) { if (message.TextMsg == "ScriptEnded") { if (this.NaoIdleMoveLeg != null) this.NaoIdleMoveLeg.Stop(); } else if (message.TextMsg == "ScriptPaused") { if (this.NaoIdleMoveLeg != null) this.NaoIdleMoveLeg.Stop(); Debug.WriteLine("{0}: Script paused!", this.ID); } } return null; }