/// <summary> /// Resets the audio connection /// </summary> public void Disconnect() { if(isRecording) stopRecording(); tts = null; audio = null; }
private static bool IsNao(string ip) { TextToSpeechProxy proxy = new TextToSpeechProxy(ip, 9559); proxy.say("Connected"); return(true); }
public Bewegen(RobotPostureProxy rpp, MotionProxy motion, MainWindow mw, TextToSpeechProxy tts) { this.rpp = rpp; this.motion = motion; this.mw = mw; this.tts = tts; }
public MainWindow() { InitializeComponent(); this.TextToSpeechProxy = new TextToSpeechProxy(NAO_IP_ADDRESS, NAO_PORT); this.BehaviorManagerProxy = new BehaviorManagerProxy(NAO_IP_ADDRESS, NAO_PORT); this.LedsProxy = new LedsProxy(NAO_IP_ADDRESS, NAO_PORT); }
public bool connect(string ip, bool onlymotion = false) { this.IP = ip; bool b = false; try { proxyMotion = new MotionProxy(ip, Port); if (onlymotion == false) { bool bc = proxyMotion.setCollisionProtectionEnabled("Arms", false); if (!bc) Console.WriteLine("Failed to disable collision protection"); StartMotorMonitor(); proxyBehaviorManager = new BehaviorManagerProxy(ip, Port); // Turn off the LEDs proxyLed = new LedsProxy(ip, Port); List<string> ledgroups = proxyLed.listGroups(); foreach (string ledgroup in ledgroups) { proxyLed.off(ledgroup); } // Speech proxyTTS = new TextToSpeechProxy(ip, Port); if (ip != "127.0.0.1") { // Sentinel proxySentinel = new SentinelProxy(ip, Port); // Turning off "Motor hot!" proxySentinel.enableHeatMonitoring(false); } // camera proxyCamera = new VideoDeviceProxy(ip, Port); // IdleMovement InitIdleMovement(); } b = true; } catch (Exception e) { Console.WriteLine("MotionProxy.Connect Exception: " + e); b = false; } IsConnected = b; return b; }
private void button_connect_to_IP_Click(object sender, EventArgs e) { this.tts = new TextToSpeechProxy(this.textBox_IP.Text, 9559); this.motion = new MotionProxy(this.textBox_IP.Text, 9559); this.BackColor = Color.AliceBlue; this.tts.say("connected."); this.motion.setStiffnesses("Body", 0); }
public void Initialisierung(String ip, Int32 port) { motion = new MotionProxy(ip, port); rpp = new RobotPostureProxy(ip, port); tts = new TextToSpeechProxy(ip, port); Bewegen = new Bewegen(rpp, motion, mw, tts); Start Start = new Start(); //Nao geht in die Startposition Start.Startposition(rpp, tts); }
public void Initialisierung(String ip, Int32 port) { motion = new MotionProxy(ip, port); rpp = new RobotPostureProxy(ip, port); tts = new TextToSpeechProxy(ip, port); Nao_Start Nao_Start = new Nao_Start(); //Nao geht in die Startposition Nao_Start.Startposition(rpp, tts); }
public void Startposition(RobotPostureProxy rpp, TextToSpeechProxy tts) { try { rpp.goToPosture("StandZero", 1); tts.say("Herzlich Willkommen zum Spiel."); } catch (Exception e) { Console.WriteLine("Startposition Fehler" + e.Message); } }
private void button_connect_Click(object sender, EventArgs e) { string ip = this.textBox1.Text; this.tts = new TextToSpeechProxy(ip, 9559); this.motion = new MotionProxy(ip, 9559); this.posture = new RobotPostureProxy(ip, 9559); this.navigation = new NavigationProxy(ip, 9559); Console.Beep(); this.label1.Text += "\nconnected."; }
public void startNAO() { try { tts = new TextToSpeechProxy("192.168.0.102", 9559); connectedToNAO = true; } catch (Exception e) { connectedToNAO = false; ErrorLabel.Text = "No Connection to NAO"; } }
//connect to the Nao robot private void ConnectToNao(string nao_ip_address, int nao_port) { bool success = true; try { TextToSpeechProxy = new TextToSpeechProxy(nao_ip_address, nao_port); BehaviorManagerProxy = new BehaviorManagerProxy(nao_ip_address, nao_port); LedsProxy = new LedsProxy(nao_ip_address, nao_port); VideoRecorderProxy = new VideoRecorderProxy(nao_ip_address, nao_port); MotionProxy = new MotionProxy(nao_ip_address, nao_port); AudioProxy = new AudioDeviceProxy(nao_ip_address, nao_port); } catch (Exception) { success = false; } ConnectButton.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new UpdateInterfaceAfterConnectDelegate(UpdateUserInterfaceAfterConnect), success); }
public MainWindow(string ip, int port, int condition) { count = 1; this.ip = ip; this.port = port; this.condition = condition; ready = true; this.Background = new SolidColorBrush(Colors.LightGreen); InitializeComponent(); this.tts = new TextToSpeechProxy(ip, port); gazeControl = new GazeControl(ip, port); this.led = new LedsProxy(ip, port); led.off("ChestLeds"); led.on("ChestLedsGreen"); started = false; }
public NaoController(string ip, MainController main) { try { this.main = main; this.ip = ip; prevAng = PI; proxy = new MotionProxy(ip, 9559); if (this.ip != "127.0.0.1") { tts = new TextToSpeechProxy(this.ip, 9559); } else { tts = null; } //this.setStiffness(1.0f); } catch (Exception e) { Console.Out.WriteLine("Connect exception: " + e); } }
public MainWindow(string ip, int port, int condition) { this.ip = ip; this.port = port; this.condition = condition; InitializeComponent(); completeCheck = new Check.Check(); ready = true; this.Background = new SolidColorBrush(Colors.LightGreen); gazeControl = new GazeControl(ip, port); kinect = new HCI.GAS.Kinect.KinectAudio("XMLs\\Thoughtfulness_Grammar.xml",ip,port); led = new LedsProxy(ip, port); led.off("ChestLeds"); led.on("ChestLedsGreen"); //TODO: check if auto has been depreciated. kinect.auto = false; end = false; tts = new TextToSpeechProxy(ip, port); }
/// <summary> /// Connects to the NAO robot /// </summary> /// <param name="ip"> ip address of the robot </param> public void connect(string ip) { // if audio or tts is not null it then was not properly disconnected if (audio != null || tts != null) { Disconnect(); } // attempt to connect try { ipString = ip; audio = new AudioDeviceProxy(ip, 9559); tts = new TextToSpeechProxy(ip, 9559); } catch (Exception e) { // display error message and write exceptions to a file MessageBox.Show("Exception occurred, error log in C:\\NAOcam\\exception.txt"); System.IO.File.WriteAllText(@"C:\\NAOcam\\exception.txt", e.ToString()); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { //Initialize the motion proxy using the text in the ipBox MotionProxy mp = new MotionProxy(ipBox.Text, 9559); //Initialize the text to speech proxy using the text in the ipBox ttsp = new TextToSpeechProxy(ipBox.Text, 9559); //Initialize the robots posture proxy using the text in the ipBox RobotPostureProxy rpp = new RobotPostureProxy(ipBox.Text, 9559); //Wakes the robot up, tells the robot to stand and say hello mp.wakeUp(); rpp.goToPosture("StandInit", .5f); ttsp.say("Hola"); //Sets up lighting of the camera with a white color and directs it in the appropriate direction DirectionalLight DirLight1 = new DirectionalLight(); DirLight1.Color = Colors.White; DirLight1.Direction = new Vector3D(1, 1, 1); //Setting up the camera so that the picture we see is in a good position PerspectiveCamera Camera1 = new PerspectiveCamera(); Camera1.FarPlaneDistance = 16000; Camera1.NearPlaneDistance = 10; //Zoomed in with a 45 degree field of view Camera1.FieldOfView = 45; //50 mm away from the point cloud and centered in the middle Camera1.Position = new Point3D(320, 240, -50); //Flips the camera so that we see everything right side up Camera1.LookDirection = new Vector3D(0, 0, 1); Camera1.UpDirection = new Vector3D(0, -1, 0); //Creates a new model 3D group to hold the sets of 3D models Model3DGroup modelGroup = new Model3DGroup(); //builds the 3D model int i = 0; for (int y = 0; y < 480; y += pointDen) { for (int x = 0; x < 640; x += pointDen) { points[i] = Triangle(x, y, pointDen); points[i].Transform = new TranslateTransform3D(0, 0, 0); modelGroup.Children.Add(points[i]); i++; } } //Adds the directional light to the model group modelGroup.Children.Add(DirLight1); ModelVisual3D modelsVisual = new ModelVisual3D(); modelsVisual.Content = modelGroup; Viewport3D myViewport = new Viewport3D(); myViewport.IsHitTestVisible = false; myViewport.Camera = Camera1; myViewport.Children.Add(modelsVisual); canvas1.Children.Add(myViewport); myViewport.Height = canvas1.Height; myViewport.Width = canvas1.Width; Canvas.SetTop(myViewport, 0); Canvas.SetLeft(myViewport, 0); sensor = KinectSensor.KinectSensors[0]; sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); sensor.DepthFrameReady += DepthFrameReady; sensor.Start(); }
private void ConnectToNao(string nao_ip_address, int nao_port) { bool success = true; try { TextToSpeechProxy = new TextToSpeechProxy(nao_ip_address, nao_port); BehaviorManagerProxy = new BehaviorManagerProxy(nao_ip_address, nao_port); LedsProxy = new LedsProxy(nao_ip_address, nao_port); VideoRecorderProxy = new VideoRecorderProxy(nao_ip_address, nao_port); } catch (Exception) { success = false; } ConnectButton.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new UpdateInterfaceAfterConnectDelegate(UpdateUserInterfaceAfterConnect), success); }
static void bicara() { TextToSpeechProxy tts = new TextToSpeechProxy("167.205.66.80", 9559); tts.say("Hallo buddy"); }
static void Main(string[] args) { bool guessed = false; // used to determine if the user has guessed the right number int wordAsInt = -1; // used to translate recongized word in to an integer value List<string> words = new List<string>(); // create list of words to sent to Nao bot // Create a connection to the text to speech engine on the Nao bot TextToSpeechProxy tts = new TextToSpeechProxy("172.28.78.228", 9559); // Create a connection to the speech recognition on the Nao bot SpeechRecognitionProxy speechR = new SpeechRecognitionProxy("172.28.78.228", 9559); // create connection to robot memory MemoryProxy m = new MemoryProxy("172.28.78.228", 9559); // random number generator Random rnd = new Random(); // generates number between 1‐5 int rndNum = rnd.Next(6); // check for rndNum being 0 if(rndNum == 0) { wordAsInt++; } // add words we want recognized to word list words.Add("one"); words.Add("two"); words.Add("three"); words.Add("four"); words.Add("five"); speechR.setVocabulary(words, false); // send the word list to robot Console.WriteLine("Guessing game running on NAO"); // loop until number is guessed while (!guessed) { // user instructions tts.say("I have picked a number between one and five, try to guess it"); System.Threading.Thread.Sleep(1500); // wait 1.5 seconds speechR.subscribe("Main", 50, 50); // Start speech recognition engine System.Threading.Thread.Sleep(5000); // wait 5 seconds speechR.unsubscribe("Main"); // stop speech recognition engine // get lastwordrecognized from memory object wordObj = m.getData("LastWordRecognized"); string word = (string)((ArrayList)wordObj)[0]; // convert word to a integer switch (word) { case "one": wordAsInt = 1; break; case "two": wordAsInt = 2; break; case "three": wordAsInt = 3; break; case "four": wordAsInt = 4; break; case "five": wordAsInt = 5; break; default: wordAsInt = -1; break; } // if else block to determine if user guessed too high, too low, or correctly if (wordAsInt > rndNum) { tts.say("You guessed too high"); } else if (wordAsInt == rndNum) { tts.say("You guessed correctly!"); guessed = true; } else if (wordAsInt < rndNum) { tts.say("You guessed too low"); } // debug output Console.WriteLine("/nNumber guessed was "); Console.Write(word); Console.WriteLine("/n Actual number is "); Console.Write(rndNum); } }
public void speak(String context) { tts = new TextToSpeechProxy(this.ip, 9559); tts.say(context); }
static void Main(string[] args) { string mIp = "127.0.0.1"; //string mIp = "192.168.1.134"; int mPort = 9559; GamePadState state; state = GamePad.GetState(PlayerIndex.One); MotionProxy motion = new MotionProxy(mIp, mPort); Console.WriteLine("MotionProxy connecté à {0}:{1}", mIp, mPort); TextToSpeechProxy tts = new TextToSpeechProxy(mIp, mPort); Console.WriteLine("TextToSpeechProxy connecté à {0}:{1}", mIp, mPort); RobotPostureProxy posture = new RobotPostureProxy(mIp,mPort); Console.WriteLine("RobotPostureProxy connecté à {0}:{1}", mIp, mPort); tts.setLanguage("French"); motion.setStiffnesses("Body", 1f); Console.WriteLine(); Console.WriteLine("En attente de connection de la manette"); while (!state.IsConnected) { state = GamePad.GetState(PlayerIndex.One); } Console.WriteLine("Manette connectée"); Object[] headJoints = { "HeadYaw", "HeadPitch" }; Object[] rshoulderJoints = { "RShoulderRoll", "RShoulderPitch" }; Object[] lelbowJoints = { "LElbowYaw", "LElbowRoll" }; Object[] handsJoints = { "LHand", "RHand" }; Object[] handAngles = new Object[2]; Object[] Angles = new Object[2]; float horizontal = 0f; float parallel = 0f; float theta = 0f; float percentMaxSpeed = 0.5f; while (state.IsConnected && state.Buttons.Back == ButtonState.Released ) { state = GamePad.GetState(PlayerIndex.One); if (state.Buttons.A == ButtonState.Pressed) { tts.setLanguage("French"); tts.say("Bonjour"); } if(state.Buttons.B == ButtonState.Pressed) { tts.setLanguage("English"); tts.say("Hello"); } if (state.Buttons.X == ButtonState.Pressed) posture.goToPosture("Crouch", 1f) ; if (state.Buttons.Y == ButtonState.Pressed) posture.goToPosture("Stand", 1f); if (state.Buttons.Start == ButtonState.Pressed) posture.goToPosture("StandZero", 1f); if (state.DPad.Up == ButtonState.Pressed) posture.goToPosture("LyingBelly", 1f); if (state.DPad.Down == ButtonState.Pressed) posture.goToPosture("LyingBack", 1f); if (state.DPad.Left == ButtonState.Pressed) posture.goToPosture("SitRelax", 1f); if (state.DPad.Right == ButtonState.Pressed) posture.goToPosture("Sit", 1f); float modX = 1.75f; float modY = 2f; Angles = new Object[] { -state.ThumbSticks.Right.X * modX, -state.ThumbSticks.Right.Y * modY }; if (state.ThumbSticks.Left.Y <= -0.1f || state.ThumbSticks.Left.Y >= 0.1f) horizontal = state.ThumbSticks.Left.Y; else horizontal = 0f; if (state.ThumbSticks.Left.X <= -0.1f || state.ThumbSticks.Left.X >= 0.1f) theta = -state.ThumbSticks.Left.X; else theta = 0f; if (state.Triggers.Left >= 0.1f) parallel = state.Triggers.Left; else if (state.Buttons.LeftShoulder == ButtonState.Pressed) parallel = -state.Triggers.Right; else parallel = 0f; handAngles = new Object[] { state.Buttons.LeftShoulder == ButtonState.Pressed ? 0f : 1f, state.Buttons.RightShoulder == ButtonState.Pressed ? 0f : 1f }; motion.move(horizontal, parallel, theta); //motion.setAngles(rshoulderJoints, Angles, percentMaxSpeed); motion.setAngles(headJoints, Angles, percentMaxSpeed); //motion.setAngles(lelbowJoints, Angles, percentMaxSpeed); motion.setAngles(handsJoints, handAngles, 1f); } }
static void Main(string[] args) { TextToSpeechProxy tts = new TextToSpeechProxy("<IP OF YOUR ROBOT>", 9559); tts.say("Hello World"); }
private static bool IsNao(string ip) { TextToSpeechProxy proxy = new TextToSpeechProxy(ip, 9559); proxy.say("Connected"); return true; }
// Chaque client à son propre "main" public void Thread() { //on demande au client de s'authentifier sw.WriteLine("NICK!"); sw.Flush(); string nickString = null; try { nickString = sr.ReadLine(); } catch(Exception e) { Fermerconnexion(); return; } string[] commande = null; //on décortique la commande commande = GetCommande(nickString); //Le protocole dit : on doit envoyer NICK!LeNick - si ce n'est pas le cas on envoie le message d'erreur conséquent if (!commande[0].Equals("NICK") || commande[1] == null ) { //le client n'a pas fourni son nom if (commande[1] == null) { commande[1] = "Mauvaise authentification: NICK!Authentifiant attendu"; } //on se garde une trace sur la console serveur Console.WriteLine(commande[1]); //on envoie l'erreur au client Erreur(commande[1]); // on ferme la connexion Fermerconnexion(); // on sort de la méthode - tuer le thread. return; } if (!Regex.IsMatch(commande[1], @"^[a-zA-Z0-9_]+$")) { //on se garde une trace sur la console serveur Console.WriteLine(commande[1] + " ne contient pas uniquement des caractère alphanumérique et des soulignés"); //on envoie l'erreur au client Erreur("votre nom contient des caractère proscrit : uniquement A-Z a-z 0-9 _ sont authorisés"); // on ferme la connexion Fermerconnexion(); // on sort de la méthode - tuer le thread. return; } //Si le nom est déjà dans la liste, erreur foreach (Client client in listeClient) { if (client.nick.ToUpper().Equals(commande[1].ToUpper())) { Erreur("Ce nom est déjà présent"); Fermerconnexion(); return; } } //enregistrer le nom dans l'objet du client. this.nick = commande[1]; //on se garde une trace Console.WriteLine(this.nick + " vient de se connecter"); //on ajoute le client à la liste AjouterClient(this); //on repond au client avec HELO!. Ecrire("HELO!" + nick); //On doit diffuser que le client vient de se connecter DiffuserCommande(this, "JOIN"); //tant que le client est actif (l'état va changer avec la commande QUIT!) bool active = true; //tant que le socket est connecté. while (ClientConnecte() && active) { //bloquant - jusqu'à ce qu'une ligne arrive ou encore une déconnexion violente string message = null; try{ message = sr.ReadLine(); } catch (Exception e) { Console.WriteLine("message null, on déconnecte ce socket : "+e.Message); } //lorsque le socket se fait débrancher, sr.ReadLine() va débloquer et message va être à null if (message == null) { //on se garde une trace dans la console pour indiquer que le client vient de se déconnecter. Console.WriteLine(this.nick + " vient de se déconnecter"); // on demande à etre retirer de la liste; RetirerClient(this); //On doit diffuser que le client vient de se déconnecter. Diffuser(this, "QUIT", "Socket terminé"); //on ferme les tream Fermerconnexion(); //on sors de la méthode ce qui va tuer le thread. fermeture propre. return; } Console.WriteLine(" message explicite >> " + message); //maintenant que les erreurs de deconnexions ont été géré. //on décortique la commande recu. commande = GetCommande(message); switch (commande[0]) { //message d'erreur case "MSGE": { Erreur(commande[1]); break; } //message à tous case "MSGA": { if (commande[1] != null) { Diffuser(this, "MSGA", commande[1]); } else { Erreur("Le message ne peut pas être vide"); } break; } //message privé case "MSGP": { commande[1] = (commande[1] == null) ? "" : commande[1]; string[] destinataireMessage = AnalyseSousCommande(commande[1]); if (destinataireMessage[0].Length == 0) { Erreur("Aucun destinataire spéficié"); } else if (destinataireMessage[1].Length == 0) { Erreur("Aucun message spécifié"); } else { Console.WriteLine("Tentative de message privé à envoyer à: " + destinataireMessage[0]); bool envoye = false; foreach (Client client in listeClient) { if (client.nick.ToUpper().Equals(destinataireMessage[0].ToUpper())) { Ecrire("SUCC!" + commande[0]); client.Ecrire(commande[0] + "!" + this.nick + "!" + destinataireMessage[1]); envoye = true; } } if (!envoye) { this.Erreur("aucun destinataire trouvé"); } } break; } /* * Le protocol dit que le serveur doit répondre avec * LIST!nom1,nom2,nom3,nom4.....nomN * vous devez implémenter cette méthode * */ case "LIST": { StringBuilder sb = new StringBuilder(); sb.Append("LIST!"); bool append = false; foreach (Client client in listeClient) { sb.Append(client.nick + ","); append = true; } //enleve la dernière virgule; if (append) { sb.Length -= 1; } Ecrire(sb.ToString()); break; } case "QUIT": { Ecrire("SUCC!" + commande[0]); if (commande[1] == null) { Diffuser(this, commande[0], "bye bye !"); } else { Diffuser(this, commande[0], commande[1]); } active = false; break; } case "CONN": { if (naoTts == null || naoMotion == null || naoPosture == null) { Console.WriteLine("Connection à NAO"); //naoTts = new TextToSpeechProxy("192.168.2.134", 9559); naoTts = new TextToSpeechProxy("127.0.0.1", 9559); Console.WriteLine("TextToSpeechProxy connecté"); naoTts.setLanguage("FRENCH"); naoTts.setVolume(0.3f); //naoMotion = new MotionProxy("192.168.2.134", 9559); naoMotion = new MotionProxy("127.0.0.1", 9559); Console.WriteLine("MotionProxy connecté"); //naoPosture = new RobotPostureProxy("192.168.2.134", 9559); naoPosture = new RobotPostureProxy("127.0.0.1", 9559); Console.WriteLine("RobotPostureProxy connecté"); Console.WriteLine("CONN terminé"); } else Console.WriteLine("Déjà connecté"); break; } case "INIT": { if (naoTts != null && naoMotion != null && naoPosture != null) { naoMotion.setStiffnesses("Body", 1f); if (naoPosture.goToPosture("StandZero", 1f)) naoTts.say("Initialisation terminée"); Console.WriteLine("Initialisation terminée"); } else Console.WriteLine("CONN nécessaire avant INIT"); break; } case "TALK": { if (commande.Length > 1) { naoTts.say(commande[1]); Console.WriteLine("NAO TextToSpeechProxy : {0}", commande[1]); } break; } case "STIF": { if(commande.Length > 1) { try { naoMotion.setStiffnesses("Body", float.Parse(commande[1])); } catch(Exception e) { Diffuser(this, "MSGA", "La commande STIF requiert un parametre valide"); } } else { Diffuser(this, "MSGA", "La commande STIF requiert un parametre"); } break; } case "POST": { if(commande.Length == 2) { try { naoPosture.goToPosture(commande[1], 1f); } catch(Exception) { Diffuser(this, "MSGA", "Argument du POST invalide"); } } else { Diffuser(this, "MSGA", "POST requiert un argument"); } break; } case "MOVE": { if(commande[1] != null) { string[] args = commande[1].Split('!'); args = args.Select(x => x.Replace(".", ",")).ToArray(); if(args.Length > 1) { string joint = args[0]; float angle = 0; float.TryParse(args[1], out angle); float vitesse = 0.1f; try { naoMotion.setAngles(joint, angle, vitesse); } catch(Exception e) { Console.WriteLine(e); } } } break; } case "TEST": { if (commande.Length > 1) { string[] args = commande[1].Split('!'); args = args.Select(x => x.Replace(".", ",")).ToArray(); if (args.Length > 6) { string chainName = args[0]; int space = 0; float[] position = { float.Parse(args[1]), float.Parse(args[2]), float.Parse(args[3]), float.Parse(args[4]), float.Parse(args[5]), float.Parse(args[6]), }; int axisMask = 63; naoMotion.setPosition(chainName, space, position.ToList<float>(), 0.4f, axisMask); } } break; } case "RGHT": { if (commande.Length > 1) { string[] args = commande[1].Split('!'); args = args.Select(x => x.Replace(".", ",")).ToArray(); if (args.Length > 2) { float[] position = { float.Parse(args[0]), float.Parse(args[1]), float.Parse(args[2]), 0f, 0f, 0f }; float[] currPosition = naoMotion.getPosition("RArm",0,true).ToArray(); float[] deltaPosition = new float[6]; for(int i = 0; i < 6; i++) { deltaPosition[i] = (position[i] - currPosition[i]) / 10; } Diffuser(this, "MSGA", message); naoMotion.changePosition("RArm", 0, position.ToList<float>(), 0.8f, 63); } } break; } default: { Erreur("Commande non implémenté sur le serveur"); break; } } } Console.WriteLine(this.nick + " vient de se deconnecter"); // on se retire soi-même de la liste; RetirerClient(this); //on ferme les socket et les streams Fermerconnexion(); //le thread va mourrir... sniff sniff }
public void task() { this.Background = new SolidColorBrush(Colors.LightBlue); motion = new MotionProxy(ip, port); tts = new TextToSpeechProxy(ip, port); bezierMotion = new Bezier(ip, port); string filename = "Task1--" + DateTime.Now.ToString("MM-dd-hh-mm") + ".txt"; logfile = new Log(filename, "Task 1 -- Thinking"); logfile.logCondition(condition); try { gazeControl = new GazeControl(ip, port); //The file should be in the output box kinect = new KinectAudio("XMLs\\Thinking_Grammar.xml", ip, port); } catch (IOException) { Console.WriteLine("Kinect Not Connected"); } taskThread = new Thread(new ThreadStart(startTask)); end = false; taskThread.Start(); }
/*XboxController cuntroller; * * void button_pressed(object sender, XboxControllerStateChangedEventArgs e) * { * if(cuntroller.IsAPressed) * Console.WriteLine(); * }*/ static void Main(string[] args) { //cuntroller = XboxController.RetrieveController(0); //cuntroller.StateChanged += button_pressed; string IP = "192.168.0.1"; //string IP = "169.254.226.148"; //string IP = "127.0.0.1"; int port = 9559; /*List<float> RAngle = new List<float>{-0.4662941f, -0.4632261f, -0.558418f, 1.326952f, -0.628898f, 0.3977605f}; * List<float> LAngle = new List<float> { -0.4662941f, 0.009245962f, -0.866668f, 0.6427041f, 0.371186f, -0.07205604f }; * List<float> LLeg = new List<float> { -0.02143404f, 0.02765396f, -1.53589f, -0.09232792f, 0.233126f, -0.01683204f };*/ //ARE THE ROTATIONS IN RADIANS? List <float> RLeg = new List <float> { -0.461692f, -0.5092461f, -0.208666f, 0.6903419f, -0.21932f, 0.3977605f }; List <float> LLeg = new List <float> { -0.461692f, 0.174918f, -0.400332f, 0.57214f, 0.118076f, -0.147222f }; List <float> RArm = new List <float> { 0.22554f, 0.151824f, 1.17807f, 1.544616f, 1.263974f, 0.322f }; List <float> LArm = new List <float> { 0.4463521f, -0.280764f, -1.075376f, -1.544616f, -0.736362f, 0.3216f }; List <float> LPunch = new List <float> { -0.190258f, -0.05679996f, 0.191708f, -0.16563f, -0.44797f, 0.3216f }; List <float> RPunch = new List <float> { -0.02296804f, 0.3141593f, -0.85448f, 0.04299396f, -0.05373196f, 0.03f }; List <float> RHookA = new List <float> { 0.162646f, -1.16128f, 0.294486f, 1.5141f, 0.277612f, 0.2f }; List <float> RHookB = new List <float> { -0.27301f, 0.3141593f, 0.200912f, 0.259288f, -1.127532f, 0.1996f }; List <float> RHookL = new List <float> { -0.27301f, 0.3141593f, 0.200912f, 0.259288f, -1.127532f, 0.1996f }; List <float> LHookA = new List <float> { 0.8329201f, 1.233294f, -1.112192f, -1.524754f, 0.004560038f, 0.3216f }; List <float> LHookB = new List <float> { -0.23321f, -0.21787f, -0.467912f, -0.122678f, 0.38039f, 0.3216f }; List <float> LuA = new List <float> { 1.246329f, -0.2638353f, -1.11164f, -1.202817f, -1.6675f, 0.3252f }; List <float> LuB = new List <float> { 0.08279404f, -0.29457f, -1.247184f, -0.8221821f, -1.810162f, 0.3256f }; List <float> STimeA = new List <float> { .1f, .1f, .1f, .1f, .1f, .1f }; List <float> RTimeA = new List <float> { .3f, .3f, .3f, .3f, .3f, .3f }; List <float> LTimeA = new List <float> { .7f, .7f, .7f, .7f, .7f, .7f }; List <float> LDrop = new List <float> { -0.05986796f, -0.285366f, -1.807094f, -0.16563f, -1.241048f, 0.4088f }; List <float> RDrop = new List <float> { -0.07359004f, 0.06592004f, 1.360616f, 0.09975196f, 1.056884f, 0.3212f }; List <float> Rsmash = new List <float> { -0.66418f, 0.231592f, 1.518618f, 0.07520796f, 1.245566f, 0.3224f }; List <float> Lsmash = new List <float> { -0.64739f, -0.3141593f, -1.40672f, -0.03490658f, -0.85448f, 1f }; List <float> ROut = new List <float> { 0.57836f, -1.303942f, 1.958876f, 0.09668396f, 0.6319661f, 0.3224f }; List <float> LOut = new List <float> { 0.7654241f, 1.156594f, -2.00498f, -0.118076f, -0.730226f, 0.322f }; GamePadState cs; GamePadState ps = new GamePadState(); Boolean upper = false; Boolean hook = false; Boolean jab = false; Boolean high = false; Random random = new Random(); int rNum = 0; TextToSpeechProxy tts = new TextToSpeechProxy(IP, port); MotionProxy motion = new MotionProxy(IP, port); RobotPostureProxy pos = new RobotPostureProxy(IP, port); LedsProxy led = new LedsProxy(IP, port); Console.WriteLine("hello"); motion.setStiffnesses("Body", 1.0f); //pos.goToPosture("Sit", 1.0f); pos.goToPosture("Stand", 1.0f); //pos.goToPosture("StandZero", 1f); pos.stopMove(); motion.setWalkArmsEnable(false, false); //motion.walkInit(); motion.post.setAngles("RArm", RArm, 0.2f); motion.setAngles("LArm", LArm, 0.2f); motion.post.angleInterpolation("RLeg", RLeg, new List <float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); motion.post.angleInterpolation("LLeg", LLeg, new List <float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); //motion.post.setAngles("RLeg", RLeg, 0.1f); //motion.setAngles("LLeg", LLeg, 0.1f); //Console.ReadKey(); Console.WriteLine(); //motion.setAngles("LLeg", LLeg, 0.2f); //motion.setStiffnesses("Body", 0.0f); Console.WriteLine("Set Stiffness"); string enter = null;// = Console.ReadLine().ToLower(); #region GAMELOOP cs = GamePad.GetState(PlayerIndex.One); while (cs.Buttons.Start != ButtonState.Pressed) { cs = GamePad.GetState(PlayerIndex.One); if (!cs.IsConnected) { Console.WriteLine("Cuntroller ain't connected"); } #region DEVTOOLS if (enter == "stiff") { motion.setStiffnesses("Body", 0.5f); //motion.setStiffnesses("RArm", 0.1f); //motion.setStiffnesses("LArm", 0.1f); } if (enter == "unstiff") { //motion.setStiffnesses("Body", 0.0f); motion.setStiffnesses("RLeg", 0.0f); //motion.setStiffnesses("LArm", 0.0f); } if (enter == "cool") { motion.setStiffnesses("Body", 0.0f); } if (enter == "RLeg") { foreach (float x in motion.getAngles("RLeg", false)) { Console.Write("{0}f, ", x); } } if (enter == "LLeg") { foreach (float x in motion.getAngles("LLeg", false)) { Console.Write("{0}f, ", x); } } if (enter == "RArm") { foreach (float x in motion.getAngles("RArm", false)) { Console.Write("{0}f, ", x); } } if (enter == "LArm") { foreach (float x in motion.getAngles("LArm", false)) { Console.Write("{0}f, ", x); } } #endregion #region POSTURES //POSITION BLOCKS if (enter == "b") { motion.setAngles("LArm", LArm, 0.2f); motion.setAngles("RArm", RArm, 0.2f); } if (cs.Buttons.Back == ButtonState.Pressed && ps.Buttons.Back != cs.Buttons.Back) { pos.goToPosture("Sit", .5f); motion.setStiffnesses("Body", 0.0f); } if (cs.Buttons.LeftStick == ButtonState.Pressed && ps.Buttons.LeftStick != cs.Buttons.LeftStick) { //tts.post.say("No one makes me bleed my own blood"); motion.stopMove(); motion.moveInit(); //pos.goToPosture("Stand", .8f); //pos.stopMove(); motion.post.angleInterpolation("RLeg", RLeg, new List <float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); motion.post.angleInterpolation("LLeg", LLeg, new List <float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } #endregion #region COMBAT //COMBAT BLOCKS if (cs.Buttons.A == ButtonState.Pressed && ps.Buttons.A != cs.Buttons.A) { upper = false; hook = false; jab = true; high = false; } if (cs.Buttons.B == ButtonState.Pressed && ps.Buttons.B != cs.Buttons.B) { upper = true; hook = false; jab = false; high = false; } if (cs.Buttons.X == ButtonState.Pressed && ps.Buttons.X != cs.Buttons.X) { upper = false; hook = true; jab = false; high = false; } if (cs.Buttons.Y == ButtonState.Pressed && ps.Buttons.Y != cs.Buttons.Y) { upper = false; hook = false; jab = false; high = true; } if (cs.Triggers.Left != 0 && jab) { //Console.WriteLine("lt pressed"); motion.angleInterpolation("LArm", LPunch, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); //motion.post.setAngles("RArm", RPunch, 0.5f); ps = cs; } if (cs.Triggers.Right != 0 && jab) { motion.post.angleInterpolation("RArm", RPunch, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if (cs.Triggers.Right != 0 && hook) { //motion.post.setAngles("RArm", RHookA, 0.3f); // motion.angleInterpolation("RLeg", RHookL, RTimeA, true); motion.angleInterpolation("RArm", RHookA, RTimeA, true); motion.angleInterpolation("RArm", RHookB, RTimeA, true); //motion.angleInterpolation("RLeg", RLeg, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if (cs.Triggers.Left != 0 && hook) { //motion.post.setAngles("RArm", RHookA, 0.3f); motion.angleInterpolation("LArm", LHookA, RTimeA, true); motion.angleInterpolation("LArm", LHookB, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if ((cs.Triggers.Right != 0 || cs.Triggers.Left != 0) && upper) { //motion.post.setAngles("RArm", RHookA, 0.3f); motion.angleInterpolation("LArm", LuA, RTimeA, true); motion.angleInterpolation("LArm", LuB, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if (cs.Buttons.RightShoulder == ButtonState.Pressed && ps.Buttons.RightShoulder != cs.Buttons.RightShoulder) { //motion.post.setAngles("RArm", RHookA, 0.3f); motion.post.angleInterpolation("LArm", LDrop, RTimeA, true); motion.angleInterpolation("RArm", RDrop, RTimeA, true); motion.post.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if (cs.Buttons.LeftShoulder == ButtonState.Pressed && ps.Buttons.LeftShoulder != cs.Buttons.LeftShoulder) { //motion.post.setAngles("RArm", RHookA, 0.3f); motion.post.angleInterpolation("LArm", LOut, RTimeA, true); motion.angleInterpolation("RArm", ROut, RTimeA, true); motion.post.angleInterpolation("LArm", LDrop, RTimeA, true); motion.angleInterpolation("RArm", RDrop, RTimeA, true); motion.post.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } if (cs.Triggers.Left != 0 && high) { motion.angleInterpolation("LArm", Lsmash, RTimeA, true); motion.angleInterpolation("LArm", LDrop, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); //motion.post.setAngles("RArm", RPunch, 0.5f); } if (cs.Triggers.Right != 0 && high) { motion.angleInterpolation("RArm", Rsmash, RTimeA, true); motion.angleInterpolation("RArm", RDrop, RTimeA, true); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } #endregion #region MOVEMMENT //MOVEMENT BLOCKS if (enter == "walk") { motion.moveInit(); motion.move(3f, 0f, 0f); Console.ReadKey(); motion.stopMove(); motion.post.angleInterpolation("RLeg", RLeg, new List <float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); motion.post.angleInterpolation("LLeg", LLeg, new List <float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); } if (cs.ThumbSticks.Left.Y > .8) { if (ps.ThumbSticks.Left.Y <= 0) { motion.stopMove(); } if (ps.ThumbSticks.Left.Y == 0) { motion.moveInit(); } motion.move(.1f, 0f, 0f); //motion.post.angleInterpolation("RLeg", RLeg, new List<float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); //motion.post.angleInterpolation("LLeg", LLeg, new List<float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); } if (cs.ThumbSticks.Left.Y < -.8) { if (ps.ThumbSticks.Left.Y >= 0) { motion.stopMove(); } if (ps.ThumbSticks.Left.Y == 0) { motion.moveInit(); } motion.move(-.15f, 0f, 0f); //motion.post.angleInterpolation("RLeg", RLeg, new List<float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); //motion.post.angleInterpolation("LLeg", LLeg, new List<float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); } if (cs.ThumbSticks.Left.X > .8) { Console.WriteLine(cs.ThumbSticks.Left.X); if (ps.ThumbSticks.Left.X <= 0) { motion.stopMove(); } if (ps.ThumbSticks.Left.X == 0) { motion.moveInit(); } motion.move(0f, -.15f, 0f); //motion.post.angleInterpolation("RLeg", RLeg, new List<float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); //motion.post.angleInterpolation("LLeg", LLeg, new List<float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); } if (cs.ThumbSticks.Left.X < -.8) { if (ps.ThumbSticks.Left.X >= 0) { motion.stopMove(); } if (ps.ThumbSticks.Left.X == 0) { motion.moveInit(); } motion.move(0f, .15f, 0f); //motion.post.angleInterpolation("RLeg", RLeg, new List<float> { 1.5f, 1.5f, 1f, 1f, 1f, 1f }, true); //motion.post.angleInterpolation("LLeg", LLeg, new List<float> { 1f, 1f, 1f, 1f, 1f, 1f }, true); } if ((cs.ThumbSticks.Left.Y == 0 && ps.ThumbSticks.Left.Y != 0) || (cs.ThumbSticks.Left.X == 0 && ps.ThumbSticks.Left.X != 0)) { motion.stopMove(); } if (cs.ThumbSticks.Right.X < -.75) { if (ps.ThumbSticks.Right.X >= 0) { motion.stopMove(); motion.moveInit(); } motion.move(0f, 0f, .3f); } if (cs.ThumbSticks.Right.X > .75) { if (ps.ThumbSticks.Right.X <= 0) { motion.stopMove(); motion.moveInit(); } motion.move(0f, 0f, -.3f); } if (cs.ThumbSticks.Right.X == 0 && ps.ThumbSticks.Right.X != 0) { motion.stopMove(); } if (cs.DPad.Up == ButtonState.Pressed && ps.DPad.Up != cs.DPad.Up) { //tts.post.say("No one makes me bleed my own blood"); motion.stopMove(); motion.moveInit(); pos.goToPosture("Stand", .8f); pos.stopMove(); } if (cs.DPad.Right == ButtonState.Pressed && ps.DPad.Right != cs.DPad.Right) { //tts.post.say("No one makes me bleed my own blood"); motion.setWalkArmsEnabled(true, true); } if (cs.DPad.Left == ButtonState.Pressed && ps.DPad.Left != cs.DPad.Left) { //tts.post.say("No one makes me bleed my own blood"); motion.angleInterpolation("RArm", RArm, RTimeA, true); motion.angleInterpolation("LArm", LArm, RTimeA, true); } #endregion #region TRASHTALKING if (cs.Buttons.RightStick == ButtonState.Pressed && ps.Buttons.RightStick != cs.Buttons.RightStick) { led.post.rasta(5f); rNum = random.Next(0, 14); switch (rNum) { case 0: tts.post.say("I'm going to put my hard drive in your floopy disk"); break; case 1: tts.post.say("I will haunt your dreams, fool. See you tonite."); break; case 2: tts.post.say("Mess with us and we will dismember you"); break; case 3: tts.post.say("Everyone Must Die!!!!"); break; case 4: tts.post.say("FOOLS"); break; case 5: tts.post.say("Meow"); break; case 6: tts.post.say("DIE"); break; case 7: tts.post.say("Hi I'm Catbug"); break; case 8: tts.post.say("I'll bash yer head in, I swear on my mum"); break; case 9: tts.post.say("I am I Robot"); break; case 10: tts.post.say("Rawr"); break; case 11: tts.post.say("Gas Powered Stick"); break; case 12: tts.post.say("Locally Grown Butter Lettuce. Butter Lettuce PARTY"); break; case 13: tts.post.say("Cake and grief counseling will be available after the fight."); break; } } #endregion //Console.Write("\n"); //Console.WriteLine(motion.getAngles("RArm", false)); //enter = Console.ReadLine(); ps = cs; } #endregion }
public void speak(String context) { tts = new TextToSpeechProxy("128.208.4.225", 9559); tts.say(context); }
static void Main(string[] args) { TextToSpeechProxy tts = new TextToSpeechProxy("192.168.100.4", 9559); tts.say("Koko"); }