public void Terminate()
 {
     rosSocket.Unadvertise(statusPublicationID);
     rosSocket.Unadvertise(feedbackPublicationID);
     rosSocket.Unadvertise(resultPublicationID);
     rosSocket.Unsubscribe(cancelSubscriptionID);
     rosSocket.Unsubscribe(goalSubscriptionID);
 }
        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();
        }
        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:
            std_msgs.String message = new std_msgs.String("publication test message data");

            string publication_id = rosSocket.Advertise <std_msgs.String>("publication_test");

            rosSocket.Publish(publication_id, message);


            // Subscription:
            string subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler);

            subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler);

            // Service Call:
            rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default"));
            rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default"));

            // Service Response:
            string service_id = rosSocket.AdvertiseService <std_srvs.TriggerRequest, std_srvs.TriggerResponse>("/service_response_test", ServiceResponseHandler);

            Console.WriteLine("Press any key to unsubscribe...");
            Console.ReadKey(true);
            rosSocket.Unadvertise(publication_id);
            rosSocket.Unsubscribe(subscription_id);
            rosSocket.UnadvertiseService(service_id);

            Console.WriteLine("Press any key to close...");
            Console.ReadKey(true);
            rosSocket.Close();
        }
Example #4
0
        public void PublicationTest()
        {
            string id = RosSocket.Advertise <std_msgs.String>("/publication_test");

            std_msgs.String message = new std_msgs.String("publication test message data");
            RosSocket.Publish(id, message);
            RosSocket.Unadvertise(id);
            Thread.Sleep(100);
            Assert.IsTrue(true);
        }
Example #5
0
        private void btnForward_Click(object sender, EventArgs e)
        {
            string  id      = RosSocket.Advertise <Twist>("/cmd_vel");
            Vector3 linear  = new Vector3(0.5, 0.0, 0.0);
            Vector3 angular = new Vector3(0.0, 0.0, 0.0);
            Twist   forward = new Twist(linear, angular);

            RosSocket.Publish(id, forward); //发布
            RosSocket.Unadvertise(id);      //取消发布
            Thread.Sleep(100);
            //System.Net.WebSockets.WebSocketException 一方关闭webSocket报错,未完成握手
        }
Example #6
0
        private void button13_Click(object sender, EventArgs e)
        {
            rosSocket.Unsubscribe(zm_robot_pose);
            rosSocket.Unsubscribe(zm_robot_vel);
            rosSocket.Unadvertise(zm_robot_vel_pub);

            thr_subscriber.Abort();

            rosSocket.Close();
            label20.Text     = "Disconection success.";
            button1.Enabled  = true;
            button13.Enabled = false;
            button14.Enabled = false;
        }
Example #7
0
        public void PublicationTest()
        {
            string id = RosSocket.Advertise <std_msgs.String>("/publication_test");

            std_msgs.String message = new std_msgs.String
            {
                data = "publication test message data"
            };
            try
            {
                RosSocket.Publish(id, message);
                RosSocket.Unadvertise(id);
                Thread.Sleep(100);
                Assert.IsTrue(true);
            }
            catch (System.Exception)
            {
                Assert.IsTrue(false);
                throw;
            }
        }
Example #8
0
 private void OnDestroy()
 {
     rosSocket.Unadvertise(publicationIdIIWA);
 }