コード例 #1
0
        //--------------------------------------------------------------------------------------------------------------
        // TODO: extending this for more messages
//		{"topic": "/camera/rgb/image_rect_color/compressed",
//			"msg": {
//				"header": {
//					"stamp": {
//						"secs": 1479891554,
//						"nsecs": 542033426},
//					"frame_id": "camera_rgb_optical_frame",
//					"seq": 10393},
//				"data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODw}}
        private void DeserializeJSONstring(string message)
        {
            Debug.Log("Try to deserialize: " + message);
            rosPublishIncoming = (RosPublish)JsonConvert.DeserializeObject <RosMessage>(message, rosMessageConverter);
            //Debug.Log (rosPublish.topic);
            if (rosPublishIncoming.topic.Equals("/joint_states"))
            {
                //Debug.Log ("received joint states");
                latestJointState = (JointState)rosPublishIncoming.msg;

                // TODO latency evaluation
                //if(testLatency){
                //	if(latestJointState.header.frame_id == "Latency Test"){
                // TODO storing this information to a file
                DateTime currentTime = DateTime.Now;
                int      secs        = currentTime.Second;
                int      nsecs       = currentTime.Millisecond;
                //Debug.Log(""+latestJointState.header.frame_id+" "+latestJointState.header.seq+" "+latestJointState.header.stamp.secs+":"+latestJointState.header.stamp.nsecs );
                //Debug.Log ("received: " + secs + ":" + nsecs);
                string dataLine = "" + (latestJointState.header.stamp.secs * 1000 + latestJointState.header.stamp.nsecs) + "," + (secs * 1000 + nsecs) + "," + ((secs * 1000 + nsecs) - (latestJointState.header.stamp.secs * 1000 + latestJointState.header.stamp.nsecs));
                //Debug.Log ("dataline " + dataLine);
                latencyData.Add(dataLine);
                //streamWriter.WriteLine ("" + latestJointState.header.stamp.secs * 1000 + latestJointState.header.stamp.nsecs + "," + secs * 1000 + nsecs + "," + ((secs * 1000 + nsecs) - (latestJointState.header.stamp.secs * 1000 + latestJointState.header.stamp.nsecs)));
                //streamWriter.Close ();
                //	}
                //}
            }
            // else if (rosPublishIncoming.topic.Equals("/camera/rgb/image_rect_color/compressed")) {
            else if (rosPublishIncoming.topic.Equals("/usb_cam/image_raw/compressed"))
            {
                latestImage = (CompressedImage)rosPublishIncoming.msg;
            }
        }
コード例 #2
0
        // die andere Richtung wäre auch schön, damit man auch Nachrichten an ROS senden kann
        public string startSerializing(RosMessage message)
        {
            //todo
            JointState js = new JointState();

            RosPublish publishMessage = (RosPublish)message;

            MessageData msg = publishMessage.msg;

            if (msg.GetType() == typeof(JointState))
            {
                js = (JointState)msg;
            }

            return(serializeJointState(js));
        }
コード例 #3
0
        // die andere Richtung wäre auch schön, damit man auch Nachrichten an ROS senden kann
        public string startSerializing(RosMessage message)
        {
            //todo
            JointTrajectory jt = new JointTrajectory();

            RosPublish publishMessage = (RosPublish)message;

            MessageData msg = publishMessage.msg;

            if (msg.GetType() == typeof(JointTrajectory))
            {
                jt = (JointTrajectory)msg;
            }

            return(serializeJointTrajectory(jt));
        }