예제 #1
0
	static void Main(string[] args)
	{
	    Network.init();
	    BufferedPortBottle p = new BufferedPortBottle();
	    if (!p.open("/csharp")) System.Environment.Exit(1);
	    p.close();
	    Network.fini();
	}
예제 #2
0
파일: TestString.cs 프로젝트: JoErNanO/yarp
 static void Main(string[] args)
 {
     Network.init();
     BufferedPortBottle p = new BufferedPortBottle();
     p.open("/csharp");
     p.close();
     Network.fini();
 }
예제 #3
0
        public static void Main(string[] args)
        {
            var serviceProvider = BuildDIContainer();

            // Initialize Yarp
            Network.init();

            using (var videoSource = serviceProvider.GetRequiredService <IVideoSource>())
                using (var audioSource = serviceProvider.GetRequiredService <IAudioSource>())
                    using (var videoPort = new BufferedPortImageRgb())
                        using (var audioPort = new BufferedPortBottle())
                            using (var videoFrameRgbBuffer = new Image <Rgb, byte>(640, 480))
                            {
                                // Stream the video frames to a yarp port
                                videoPort.open("/camera");
                                videoSource.FrameReady += (_, frame) =>
                                {
                                    using (var msg = videoPort.prepare())
                                    {
                                        // Convert the incoming image which is BGR to RGB
                                        var bits = frame.Image.LockBits(new Rectangle(0, 0, frame.Image.Width, frame.Image.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                                        using (var videoFrameBgr = new Image <Bgr, byte>(frame.Image.Width, frame.Image.Height, bits.Stride, bits.Scan0))
                                            CvInvoke.CvtColor(videoFrameBgr, videoFrameRgbBuffer, ColorConversion.Bgr2Rgb);
                                        frame.Image.UnlockBits(bits);

                                        // Send the RGB image over yarp
                                        var handle = GCHandle.Alloc(videoFrameRgbBuffer.Bytes, GCHandleType.Pinned);
                                        msg.setExternal(new SWIGTYPE_p_void(handle.AddrOfPinnedObject(), true), (uint)frame.Image.Width, (uint)frame.Image.Height);
                                        videoPort.write();
                                        videoPort.waitForWrite();
                                        handle.Free();
                                    }
                                };

                                // Stream the audio samples to a yarp port
                                audioPort.open("/microphone");
                                audioSource.SampleReady += (_, sample) =>
                                {
                                    using (var bottle = audioPort.prepare())
                                    {
                                        var handle = GCHandle.Alloc(sample.Data, GCHandleType.Pinned);
                                        bottle.clear();
                                        bottle.add(Value.makeBlob(new SWIGTYPE_p_void(handle.AddrOfPinnedObject(), true), sample.Data.Length));
                                        audioPort.write();
                                        audioPort.waitForWrite();
                                        handle.Free();
                                    }
                                };

                                // Run the sample application
                                RunDemoApplication(videoSource, audioSource);
                            }

            // Explicitely shutdown NLog and Yarp
            Network.fini();
            NLog.LogManager.Shutdown();
        }
예제 #4
0
파일: TestString.cs 프로젝트: yuhuazou/yarp
        static void Main(string[] args)
        {
            Network.init();
            BufferedPortBottle p = new BufferedPortBottle();

            p.open("/csharp");
            p.close();
            Network.fini();
        }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        Network.init();
        p = new BufferedPortBottle();
        p.open ("/unityYarp");

        //		globalRed = 1.0f;
        //		globalBlue = 0.5f;
        //		globalGreen = 0.2f;
    }
    // Use this for initialization
    void Start()
    {
        Network.init();
        p = new BufferedPortBottle();

        //while(p.getOutputCount == 0)
        //{
            p.open ("/unityYarp");
        //}
        Network.connect("/unityYarp", destPortName);
    }
예제 #7
0
파일: TestString.cs 프로젝트: ste93/yarp
        static void Main(string[] args)
        {
            Network.init();
            BufferedPortBottle p = new BufferedPortBottle();

            if (!p.open("/csharp"))
            {
                System.Environment.Exit(1);
            }
            p.close();
            Network.fini();
        }
예제 #8
0
 public override void Initialise()
 {
     portReal      = new BufferedPortBottle();
     portPredicted = new BufferedPortBottle();
     portPerceived = new BufferedPortBottle();
     portReal.open("/" + mapName + "/" + name + "/real:i");
     portPredicted.open("/" + mapName + "/" + name + "/predicted:o");
     portPerceived.open("/" + mapName + "/" + name + "/perceived:o");
     if (autoconnect_source != null)
     {
         Network.connect(autoconnect_source, YarpModalityVector.getRealPortName(mapName, name));
     }
     base.Initialise();
 }
예제 #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="nameInputPort"></param>
        /// <param name="nameOutputPort"></param>
        public void openReceiver(string nameOutputPort,string nameInputPort) 
        {
            if (!String.IsNullOrEmpty(nameInputPort) && !String.IsNullOrEmpty(nameOutputPort))
            {
                Network.init();
                input = new BufferedPortBottle();       
                input.open(nameInputPort);
               
                style = new ContactStyle();
                style.persistent=true;

                if(Network.isConnected(nameOutputPort,nameInputPort,style))
                    Network.disconnect(nameOutputPort,nameInputPort,style);

                if (Network.connect(nameOutputPort, nameInputPort, style))
                    Console.WriteLine(nameInputPort + " port is connected to " + nameOutputPort);

            }
        }
예제 #10
0
파일: example.cs 프로젝트: Tiger66639/yarp
	static void Main(string[] args)
	{
	    Network.init();
	    BufferedPortBottle p = new BufferedPortBottle();
	    p.open("/csharp");
	    int top = 100;
	    for (int i=1; i<top; i++) {
		Bottle bottle = p.prepare();
		bottle.clear();
		bottle.addString("count");
		bottle.addInt(i);
		bottle.addString("of");
		bottle.addInt(top);
		Console.WriteLine("Sending " + bottle.toString());
		p.write();
		Time.delay(0.5);
	    }
	    p.close();
	    Network.fini();
	}
예제 #11
0
        static void Main(string[] args)
        {
            Network.init();
            BufferedPortBottle p = new BufferedPortBottle();

            p.open("/csharp");
            int top = 100;

            for (int i = 1; i < top; i++)
            {
                Bottle bottle = p.prepare();
                bottle.clear();
                bottle.addString("count");
                bottle.addInt32(i);
                bottle.addString("of");
                bottle.addInt32(top);
                Console.WriteLine("Sending " + bottle.toString());
                p.write();
                Time.delay(0.5);
            }
            p.close();
            Network.fini();
        }
예제 #12
0
 internal static HandleRef getCPtr(BufferedPortBottle obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #13
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BufferedPortBottle obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #14
0
 // Use this for initialization
 void Start()
 {
     Network.init();
     p = new BufferedPortBottle();
     p.open ("/unityYarp");
 }
    // Use this for initialization
    void Start()
    {
        //open all ports
        Network.init();

        rightLegState = new BufferedPortBottle();
        leftLegState = new BufferedPortBottle();

        rightArmState = new BufferedPortBottle();
        leftArmState = new BufferedPortBottle();

        headState = new BufferedPortBottle();
        torsoState = new BufferedPortBottle();

        rightLegState.open (rLegPortName);
        leftLegState.open (lLegPortName);

        rightArmState.open (rArmPortName);
        leftArmState.open (lArmPortName);

        headState.open (headPortName);
        torsoState.open (torsoPortName);

        portCheckIter = 0;

        bottleTagInt = yarp.BOTTLE_TAG_INT;
        bottleTagString = yarp.BOTTLE_TAG_STRING;
        bottleTagDouble = yarp.BOTTLE_TAG_DOUBLE;
        bottleTagList = yarp.BOTTLE_TAG_LIST;
        Debug.Log ("INT: " + bottleTagInt + " DOUBLE: " + bottleTagDouble + " STRING: " + bottleTagString);
    }
예제 #16
0
        public void openInputPort(string namePort)
        {
            if (!String.IsNullOrEmpty(namePort))
            {
                Network.init();
                input = new BufferedPortBottle();
                input.open(namePort);
            }

        }