Beispiel #1
0
        /// <summary>
        /// Update this NaoState with new values retrieved from the Nao. This includes battery charge, robot position,
        /// robot rotation, et cetera.
        /// </summary>
        /// <exception cref="UnavailableConnectionException">NaoState is not connected to a Nao.</exception>
        public void Update()
        {
            try
            {
                List <float> vector = motion.getRobotPosition(true);
                Location = new PointF(vector[0], vector[1]);
                Rotation = vector[2];
                BatteryPercentageLeft = battery.getBatteryCharge();
                Temperature           = (float)memory.getData("Device/SubDeviceList/Battery/Temperature/Sensor/Value");

                // update idle
                Idle = EventQueue.Nao.Current == null;
            }
            catch (Exception e)
            {
                Logger.Log(this, "Failed Update(). Unknown exception occurred: " + e.ToString());
            }

            // Count the time between this update and the next.
            Stopwatch.Restart();
        }
Beispiel #2
0
        public List <float> getFacesInfo()
        {
            ArrayList faces = (ArrayList)mp.getData("FaceDetected");

            if (faces.Count >= 2)
            {
                string       timeStamp  = faces[0].ToString();
                ArrayList    faceInfo1  = faces[1] as ArrayList;
                ArrayList    faceInfo2  = faceInfo1[0] as ArrayList;//ova e toa sto ni treba
                ArrayList    shapeInfo  = faceInfo2[0] as ArrayList;
                List <float> faceOutput = new List <float>();

                float alpha = (float)shapeInfo[1];
                float beta  = (float)shapeInfo[2];
                float sizeX = (float)shapeInfo[3];
                float sizeY = (float)shapeInfo[4];
                faceOutput.Add(alpha);
                faceOutput.Add(beta);
                faceOutput.Add(sizeX);
                faceOutput.Add(sizeY);

                /*
                 * Console.WriteLine("Info = {");
                 * Console.WriteLine(alpha);
                 * Console.WriteLine(beta);
                 * Console.WriteLine(sizeX);
                 * Console.WriteLine(sizeY);
                 * Console.WriteLine("}");
                 */

                return(faceOutput);
            }
            else
            {
                //Console.WriteLine("No faces have been detected!");
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method that reads the LandmarkDetected memory and extracts the landmarks info into a dictionary
        /// </summary>
        /// <param name="memProxy"></param>
        /// <returns></returns>
        private Dictionary <int, ArrayList> TryGetLandMark(MemoryProxy memProxy)
        {
            Dictionary <int, ArrayList> ret = null;

            try
            {
                // get the LandmarkDetected memory
                var landMarkMemory = memProxy.getData("LandmarkDetected") as ArrayList;

                if (landMarkMemory != null)
                {
                    var landMarks = LandMarkHelper.Instance.GetLandMarksInfo(landMarkMemory) as ArrayList;
                    if (landMarks != null)
                    {
                        ret = new Dictionary <int, ArrayList>();
                        foreach (var landMark in landMarks)
                        {
                            var landMarkArr = landMark as ArrayList;
                            if (landMarkArr != null)
                            {
                                int?markId = LandMarkHelper.Instance.GetMarkID(landMarkArr) as int?;
                                if (markId.HasValue)
                                {
                                    ret.Add(markId.Value, landMarkArr);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Coult get marks. " + ex.ToString());
            }
            return(ret);
        }
Beispiel #4
0
 /// <summary>
 /// get value of sonar left
 /// </summary>
 /// <returns></returns>
 public float getSonarDataLeft()
 {
     return((float)memoryProxy.getData("Device/SubDeviceList/US/Left/Sensor/Value"));
 }
Beispiel #5
0
        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); 
            } 
        } 
Beispiel #6
0
 /// <summary>
 /// Retrieves the marker data from the Nao's memory.
 /// </summary>
 /// <returns>
 /// A list of the form:
 /// [TimeStamp, MarkerInformation[N], CameraPoseInNaoSpace, CameraPoseInWorldSpace, CurrentCameraName].
 /// </returns>
 public ArrayList GetMarkerData()
 {
     return((ArrayList)memory.getData("LandmarkDetected"));
 }