Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            //RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketSharpProtocol(uri));
            RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketNetProtocol(uri));

            // Publication:
            int ImageDataSize = 100;

            sensor_msgs.CompressedImage image = new sensor_msgs.CompressedImage();
            image.header.frame_id = "Test";
            string publication_id = rosSocket.Advertise <sensor_msgs.CompressedImage>("/test_image");

            Console.WriteLine("Press any key to start publication...");
            Console.ReadKey(true);
            for (int i = 0; i < 100000; i++)
            {
                image.header.seq += 1;
                image.data        = Enumerable.Repeat((byte)0x20, ImageDataSize).ToArray();
                rosSocket.Publish(publication_id, image);
            }

            Console.WriteLine("Press any key to close...");
            Console.ReadKey(true);
            rosSocket.Unadvertise(publication_id);
            rosSocket.Close();
        }
Exemplo n.º 2
0
    void Publish()
    {
        string message = "Hi " + count++;

        rosSocket.Publish("/chatter", new std_msgs.String(message));

        // Publication:
        int ImageDataSize = 100;

        sensor_msgs.CompressedImage image = new sensor_msgs.CompressedImage();
        image.header.frame_id = "Test";
        image.header.seq     += 1;
        image.data            = Enumerable.Repeat((byte)0x20, ImageDataSize).ToArray();
        rosSocket.Publish(publication_id, image);

        Debug.Log("Publish: " + message);
    }