Esempio n. 1
0
        /// <summary> 
        /// Connects to the camera on the NAO robot 
        /// </summary> 
        /// <param name="ip"> the ip address of the robot </param> 
        /// <param name="format"> the video format desired </param> 
        /// <param name="ColorSpace"> the video color space </param> 
        /// <param name="FPS"> the FPS of the video </param> 
        public void connect(string ip, NaoCamImageFormat format, int ColorSpace, int FPS) 
        { 
            try 
            { 
                if (naoCamera != null) 
                { 
                    Disconnect(); 
                } 
 
                naoCamera = new VideoDeviceProxy(ip, 9559); 
 
                // Attempt to unsubscribe incase program was not shut down properly 
                try 
                { 
                    naoCamera.unsubscribe("NAO Camera"); 
                } 
                catch (Exception) 
                { 
                } 
 
                // subscribe to NAO Camera for easier access to camera memory 
                naoCamera.subscribe("NAO Camera", format.id, ColorSpace, FPS); 
            } 
            catch (Exception e) 
            { 
                // display error message and write exceptions to a file 
                MessageBox.Show("Exception occurred, error log in C:\\NAOcam\\exception.txt"); 
                naoCamera = null; 
                System.IO.File.WriteAllText(@"C:\\NAOcam\\exception.txt",e.ToString()); 
            } 
        } 
        /// <summary>
        /// Connects to the camera on the NAO robot
        /// </summary>
        /// <param name="ip"> the ip address of the robot </param>
        /// <param name="format"> the video format desired </param>
        /// <param name="ColorSpace"> the video color space </param>
        /// <param name="FPS"> the FPS of the video </param>
        public void connect(string ip, NaoCamImageFormat format, int ColorSpace, int FPS)
        {
            try
            {
                if (naoCamera != null)
                {
                    Disconnect();
                }

                naoCamera = new VideoDeviceProxy(ip, 9559);

                // Attempt to unsubscribe incase program was not shut down properly
                try
                {
                    naoCamera.unsubscribe("NAO Camera");
                }
                catch (Exception)
                {
                }

                // subscribe to NAO Camera for easier access to camera memory
                naoCamera.subscribe("NAO Camera", format.id, ColorSpace, FPS);
            }
            catch (Exception e)
            {
                // display error message and write exceptions to a file
                MessageBox.Show("Exception occurred, error log in C:\\NAOserver\\exception.txt");
                naoCamera = null;
                System.IO.File.WriteAllText(@"C:\\NAOserver\\exception.txt", e.ToString());
            }
        }
                 /// <summary> 
                 /// Disconnects from the NAO camera 
                 /// </summary> 
                public void Disconnect()  
                
        {
             
                        try 
                         {
                 
                                if (naoCamera  !=  null)  
                                
                {
                     
                                        // unsubscribe so the NAO knows we do not need data from the camera anymore 
                                        naoCamera.unsubscribe("NAO Camera");  

                                        
                }

                 
                                    
            }  
                        catch 
                         {
                  
            }  
             
                                    naoCamera  =  null;  

                        
        }
Esempio n. 4
0
        public void initializeProxies()
        {
            fdp = new FaceDetectionProxy(this.ip, 9559);
            fdp.enableTracking(true);
            vdp = new VideoDeviceProxy(this.ip, 9559);

            mp = new MemoryProxy(this.ip, 9559);
        }
                 /// <summary> 
                 /// Connects to the camera on the NAO robot 
                 /// </summary> 
                 /// <param name="ip"> the ip address of the robot </param> 
                 /// <param name="format"> the video format desired </param> 
                 /// <param name="ColorSpace"> the video color space </param> 
                 /// <param name="FPS"> the FPS of the video </param> 
                public void connect(string ip,  NaoCamImageFormat format,  int ColorSpace,  
                                    int FPS)  
                
        {
             
                        try 
                         {
                 
                                if (naoCamera  !=  null)  
                                
                {
                     
                                        Disconnect();  
                                        
                }

                 
                 
                                        naoCamera  =  new VideoDeviceProxy(ip,  9559);
                 
                                // Attempt to unsubscribe incase program was not shut down properly 
                                try 
                                 {
                     
                                        naoCamera.unsubscribe("NAO Camera");  

                                        
                }  
                                catch (Exception)  
                                
                {
                     
                                        
                }

                 
                 
                                // subscribe to NAO Camera for easier access to camera memory 
                                naoCamera.subscribe("NAO Camera",  format.id,  ColorSpace,  FPS);

                // naoCamera.subscribe("NAO Camera", format.id, ColorSpace, FPS);
                            
            }  
                        catch (Exception e)  
                        
            {
                 
                                 // display error message and write exceptions to a file 
                                 // MessageBox.Show("Exception occurred, error log in C:\\NAOcam\\exception.txt"); 
                                    naoCamera  =  null;  

                                System.IO.File.WriteAllText(@"C:\\NAOcam\\exception.txt",  
                                                            e.ToString());  
                                
            }

                     
        }
        /// <summary>
        /// Disconnects from the NAO camera
        /// </summary>
        public void Disconnect()
        {
            try
            {
                if (naoCamera != null)
                {
                    // unsubscribe so the NAO knows we do not need data from the camera anymore
                    naoCamera.unsubscribe("NAO Camera");
                }
            }
            catch
            {  }

            naoCamera = null;
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        /// <summary> 
        /// Disconnects from the NAO camera 
        /// </summary> 
        public void Disconnect() 
        { 
            try 
            { 
                if (naoCamera != null) 
                { 
                    // unsubscribe so the NAO knows we do not need data from the camera anymore 
                    naoCamera.unsubscribe("NAO Camera"); 
                } 
            } 
            catch 
            {  } 
 
            naoCamera = null; 
        } 
Esempio n. 9
0
 /// <summary>
 /// Creates a new instance using given subscriber-ID.
 /// </summary>
 /// <param name="subID">The ID under which to subscribe to the Nao's video proxy.</param>
 /// <exception cref="UnavailableConnectionException">If not connected to any Nao.</exception>
 public Camera(string subID)
 {
     subscriberID = subID;
     videoProxy = Proxies.GetProxy<VideoDeviceProxy>();
     Unsubscribe();  //Make sure that there is no other subscriber with this ID
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new instance using given subscriber-ID.
 /// </summary>
 /// <param name="subID">The ID under which to subscribe to the Nao's video proxy.</param>
 /// <exception cref="UnavailableConnectionException">If not connected to any Nao.</exception>
 public Camera(string subID)
 {
     subscriberID = subID;
     videoProxy   = Proxies.GetProxy <VideoDeviceProxy>();
     Unsubscribe();  //Make sure that there is no other subscriber with this ID
 }
Esempio n. 11
0
        /// <summary> 
        /// Disconnects from the NAO camera 
        /// </summary> 
        public void Disconnect() 
        { 
            try 
            { 
                if (naoCameraUpper != null ) 
                { 
                    // unsubscribe so the NAO knows we do not need data from the camera anymore 
                    naoCameraUpper.unsubscribe(subsNameUpper);
                    
                } 
            } 
            catch 
            {  } 
 
            naoCameraUpper = null;
            
        }