Ejemplo n.º 1
0
        public void robotOrderedGotoDockingArea(String textOrdered)
        {
            StandardString messages = new StandardString();

            messages.data = textOrdered;
            rosSocket.Publish(paramsRosSocket.publication_serverRobotGotToLineDockingArea, messages);
        }
Ejemplo n.º 2
0
        public static void visualizeLane(lane laneViz)
        {
            LaneArray wpLaneArray2 = new LaneArray();

            lane[] laneArraViz2 = new lane[1];
            laneArraViz2[0]   = laneViz;
            wpLaneArray2.lane = laneArraViz2;
            rosSocket.Publish(publish_laneArray, wpLaneArray2);
        }
Ejemplo n.º 3
0
 internal void Home_Click(object sender, RoutedEventArgs e)
 {
     if (rosSocket != null)
     {
         std_msgs.RosInt32 command = new std_msgs.RosInt32(0);
         rosSocket.Publish(commandPubId, command);
         UpdateCurrentTask("Going Home", "");
     }
 }
 public void rosMeasurementsMessager()
 {
     bm_msgs.bm_message measurements_message = new bm_msgs.bm_message
     {
         chest_size_msg    = Math.Round((chest_size * 100), 2),
         waist_size_msg    = Math.Round((waist_size * 100), 2),
         bottom_size_msg   = Math.Round((bottom_size * 100), 2),
         shoulder_size_msg = Math.Round((shoulder_front * 100), 2),
         sleeve_size_msg   = Math.Round((sleeve_front * 100), 2)
     };
     rosSocket.Publish(rosBMMeasurements_Id, measurements_message);
 }
Ejemplo n.º 5
0
 public void PublishJointsIIWA()
 {
     if (qList != null)
     {
         rosSocket.Publish(publicationIdIIWA, CreateJointsMessageIIWA(qList[c]));
         c++;
         if (c == qList.Length)
         {
             Flag = false;
             c    = 0;
         }
     }
 }
Ejemplo n.º 6
0
    public void AddObstacle(Vector3 position, bool isTarget)
    {
        var isTargetString = isTarget ? "true" : "false";
        var data           = $"{{" +
                             $"    \"position\": {{" +
                             $"        \"x\": {position.x}," +
                             $"        \"y\": {position.z}" +
                             $"    }}," +
                             $"    \"is_target\": {isTargetString}" +
                             $"}}";

        Debug.Log(data);

        socket.Publish(addObstaclePublisher, new String(data));
    }
Ejemplo n.º 7
0
 public void walkAhead()
 {
     msgs.Geometry.Vector3 linear  = new msgs.Geometry.Vector3();
     msgs.Geometry.Vector3 angular = new msgs.Geometry.Vector3();
     msgs.Geometry.Twist   message = new msgs.Geometry.Twist();
     linear.x        = 1.0f;
     linear.y        = 0.0f;
     linear.z        = 0.0f;
     angular.x       = 0.0f;
     angular.y       = 0.0f;
     angular.z       = 0.0f;
     message.linear  = linear;
     message.angular = angular;
     socket.Publish(publication_id, message);
 }
Ejemplo n.º 8
0
        public virtual void CommandActuator(double[] efforts)
        {
            /*
             *  new RosSharp.RosBridgeClient.MessageTypes.Std.Header(
             *      1, new RosSharp.RosBridgeClient.MessageTypes.Std.Time((uint)DateTime.Now.TimeOfDay.TotalSeconds, 40), "my frame")*/

            Actuators msg = new Actuators(
                new RosSharp.RosBridgeClient.MessageTypes.Std.Header(),
                new double[0],
                efforts,
                new double[0]);
            string json = JsonConvert.SerializeObject(msg);

            RosSocket.Publish(Topics.GetPublishId(nameof(CommandActuator)), msg);
            Console.WriteLine($"Publishing to {Topics.GetTopic(nameof(CommandActuator))}: {json}");
        }
Ejemplo n.º 9
0
    void Update()
    {
        //float[] randomInput = new float[6];
        //for (int i = 0; i < 6; i++)
        //{
        //    randomInput[i] = (float) (s_RandomInstance.NextDouble() * 2 - 1);
        //}

        //m_Socket.Publish("/processed_arm_controller_input", new ProcessedControllerInput
        //{
        //    ControllerInput = randomInput
        //});

        //m_Socket.Publish("/WheelSpeed", new WheelSpeed
        //{
        //    Wheel_Speed = new[] { 5.0f, 5.0f }
        //});

        m_Socket.Publish("/LidarData", new LidarData
        {
            distances = lidarSensor.getCurrentDistances(),
            angle     = lidarSensor.getCurrentAngle()
        });


        //m_Socket.Publish("/TestTopic", new Int32());
    }
Ejemplo n.º 10
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:
            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();
        }
Ejemplo n.º 11
0
    void Update()
    {
        tapk = taptrigger.tap;


        if (tapk == true)
        {
            /*if (moji == "true")
             * {
             *  moji = "false";
             * }
             * else if (moji == "false")
             * {
             *  moji= "true";
             * }
             * else
             * {
             *  moji = "trulse";
             * }*/
            moji         = "true";
            message.data = moji;
            rosSocket.Publish(advertise_id, message);
            taptrigger.tap = false;
            tapk           = false;
        }
    }
        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();
        }
Ejemplo n.º 13
0
    void YISubscribe()
    {
        for (int i = 0; i < dbsub.cnt; i++) //受け取った座標を更新
        {
            px[i] = newPlane[i].gameObject.transform.localPosition.x;
            py[i] = newPlane[i].gameObject.transform.localPosition.y;
            pz[i] = newPlane[i].gameObject.transform.localPosition.z;
            rx[i] = newPlane[i].gameObject.transform.localEulerAngles.x;
            ry[i] = newPlane[i].gameObject.transform.localEulerAngles.y;
            rz[i] = newPlane[i].gameObject.transform.localEulerAngles.z;
            sx[i] = newPlane[i].gameObject.transform.localScale.x;
            sy[i] = newPlane[i].gameObject.transform.localScale.y;
            sz[i] = newPlane[i].gameObject.transform.localScale.z;
        }
        transI.image_num  = dbsub.cnt;
        transI.position_x = px;
        transI.position_y = py;
        transI.position_z = pz;
        transI.rotation_x = rx;
        transI.rotation_y = ry;
        transI.rotation_z = rz;
        transI.scale_x    = sx;
        transI.scale_y    = sy;
        transI.scale_z    = sz;
        transI.TimeB      = dbsub.TimeB;
        transI.TimeT      = dbsub.TimeT;


        Debug.Log(Mynumber);
        //advertise_id = rosSocket.Advertise("/myinfo" + Mynumber, "detect_object/DBinfo");
        advertise_id = rosSocket.Advertise("/myinfo" + Mynumber, "detect_object/TransformInfo");
        rosSocket.Publish(advertise_id, transI);

        yourinfo_check_topic = false;
    }
Ejemplo n.º 14
0
    void Update()
    {
        laser2.defineParameters(maxLeftAngle, maxRightAngle, maxTopAngle, maxBottomAngle, verticalIncrement, horizontalIncrement, maxDistance, 1 << 8, repetitions);

        if (run)
        {
            //this function is resposible for push the correct points to the pcl cloud
            if (laser2.runCasterSequentialRep(ref pcl, this, drawRay))
            {
                //convert from pcl cloud to pcl cloud2
                pcl.convertToCloud2();

                //create a new mensage to be send
                SensorPointCloud2 pc = new SensorPointCloud2();

                //from the Pcl cloud2 converted to Ros cloud2 using marshal for better performance
                pcl.convertToRosCloud(ref pc, frame_id);

                //publish the ros cloud mensage
                rosSocket.Publish(publication_id, pc);

                //restart pcl cloud
                pc = new SensorPointCloud2();
                pcl.createPclCloud(0, 0, true);
            }
        }
    }
Ejemplo n.º 15
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);
    }
Ejemplo n.º 16
0
 // Update is called once per frame
 void Update()
 {
     if (run)
     {
         sensor = updateGPS();
         rosSocket.Publish(publication_id, sensor);
     }
 }
Ejemplo n.º 17
0
    void publishn()
    {
        //Debug.Log("Pub No");
        StandardString message = new StandardString();

        message.data = "Pick Position: " + primaryCubeOne.transform.position.x + ", " + primaryCubeOne.transform.position.y + ", " + primaryCubeOne.transform.position.z + "  |  " + "Pick Rotation: " + primaryCubeOne.transform.eulerAngles + "  |  " + "Place Position: " + primaryCubeOnePick.transform.position.x + ", " + primaryCubeOnePick.transform.position.y + ", " + primaryCubeOnePick.transform.position.z + "  |  " + "Place Position: " + primaryCubeOnePick.transform.eulerAngles + "  |  " + "World Center: " + WorldCenter.transform.position.x + ", " + WorldCenter.transform.position.y + ", " + WorldCenter.transform.position.z + "  |  " + "World Center is: " + WorldCenter.transform.eulerAngles;
        ros.Publish(publication_id, message);
    }
Ejemplo n.º 18
0
 // Update is called once per frame
 void Update()
 {
     if (run)
     {
         //get Imuvalue
         sensor = updateImu();
         rosSocket.Publish(publication_id, sensor);
     }
 }
Ejemplo n.º 19
0
 private static void ReceiveMessage(Clock msg)
 {
     LastMsg = "secs " + msg.clock.secs;
     Console.WriteLine(LastMsg);
     rosSocket.Publish(publishId, new Clock()
     {
         clock = new Time(10, 20),
     });
 }
Ejemplo n.º 20
0
        private void AddCollisionObjects(string _object, float _centerX, float _centerY, float _centerZ, bool _useSpecialBoxGeometry = false)
        {
            CollisionObject collisionObjectMsg = CollisionObjectHandler.AddCollisionObject(_object, _centerX, _centerY, _centerZ, _useSpecialBoxGeometry);

            // Publication:
            string publicationID = rosSocket.Advertise <CollisionObject>("collision_object");

            rosSocket.Publish(publicationID, collisionObjectMsg);
        }
Ejemplo n.º 21
0
 public void checkAliveTimeOut(Object sender, EventArgs e)
 {
     if (rosSocket != null)
     {
         if (!rosSocket.isConnected)
         {
             timerInterruptCheckAliveTimeOut.Stop();
             timerInterruptConnectionRosSocket.Start();
         }
         else
         {
             dynamic product = new JObject();
             product.count = GlobalVariables.EncodeTransmissionTimestamp();
             StandardString messages = new StandardString();
             messages.data = product.ToString();
             rosSocket.Publish(paramsRosSocket.publication_checkAliveTimeOut, messages);
         }
     }
 }
Ejemplo n.º 22
0
        public void CommandVelocity(Twist twist)
        {
            if (rosSocket == null)
            {
                return;
            }
            Console.WriteLine(nameof(CommandVelocity));

            rosSocket.Publish(publicationIds[topic_cmd_vel], twist);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        rosSocketIsAlive = rosSocket.protocol.IsAlive();

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

        std_msgs.String message = new std_msgs.String();
        message.data = "publication test message data";
        rosSocket.Publish(publication_id, message);
    }
Ejemplo n.º 25
0
    // Publish string to ROS
    public void PublishString(string topic, string msg)
    {
        // Create new standard string and set its data to msg
        std_msgs.String message = new std_msgs.String {
            data = msg
        };

        string publicationId = rosSocket.Advertise <std_msgs.String>(topic); // Topic must be in "/topic" format

        rosSocket.Publish(publicationId, message);
        Debug.Log("Sent:" + msg);
    }
    void Publish_to_ROS(byte[] image_data)
    {
        SensorCompressedImage publish_image = new SensorCompressedImage();

        publish_image.format = "jpeg";
        publish_image.data   = image_data;

        Debug.Log("ara:Publishing...");

        // ROSに画像を送信
        rosSocket.Publish(advertise_id, publish_image);
    }
Ejemplo n.º 27
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报错,未完成握手
        }
Ejemplo n.º 28
0
        public CompoundTerm DoAction(CompoundTerm action)
        {
            switch (action.Name)
            {
            case ("Tests"): return(null);

            case ("StartPosition"):
                xposition = 0;
                TurtlesimPose messageP = new TurtlesimPose();
                messageP.x                = 0;
                messageP.y                = 0;
                messageP.theta            = 0;
                messageP.angular_velocity = 0;
                messageP.linear_velocity  = 0;
                rosSocket.Publish(publication_id, messageP);


                return(null);

            case ("MoveTurtle"):
                GeometryTwist message = new GeometryTwist();
                float         speed   = (float)action[0];
                message.linear.x = speed;
                rosSocket.Publish(publication_id, message);
                return(null);

            case ("Goal_Start"):
                if (xposition > 0)
                {
                    return(NModel.Terms.Action.Create("Goal_Finish"));
                }
                else
                {
                    return(NModel.Terms.Action.Create("Goal_Failed"));
                }


            default: throw new Exception("Unexpected action " + action);
            }
        }
 public void PublishStatus()
 {
     if (actionStatus == ActionStatus.NO_GOAL)
     {
         rosSocket.Publish(statusPublicationID, new GoalStatusArray());
     }
     else
     {
         rosSocket.Publish(statusPublicationID,
                           new GoalStatusArray
         {
             status_list = new GoalStatus[]
             {
                 new GoalStatus {
                     status = (byte)actionStatus,
                     text   = actionStatusText
                 }
             }
         }
                           );
     }
 }
Ejemplo n.º 30
0
    void Update()
    {
        TUCtap = tapto.tap;

        if (TUCtap == true) //ユーザカウントボタンが押されたら要求
        {
            counter      = "whatNo";
            message.data = counter;
            rosSocket.Publish(advertise_id, message);
            this.GetComponent <CreateUsersButton>().enabled = true;
            tapto.tap = false;
            TUCtap    = false;
        }
    }