コード例 #1
0
            public override byte[] Serialize(bool partofsomethingelse)
            {
                int  currentIndex = 0, length = 0;
                bool hasmetacomponents = false;

                byte[]        thischunk, scratch1, scratch2;
                List <byte[]> pieces = new List <byte[]>();
                GCHandle      h;

                //map
                if (map == null)
                {
                    map = new Messages.nav_msgs.OccupancyGrid();
                }
                pieces.Add(map.Serialize(true));
                //initial_pose
                if (initial_pose == null)
                {
                    initial_pose = new PoseWithCovarianceStamped();
                }
                pieces.Add(initial_pose.Serialize(true));
                //combine every array in pieces into one array and return it
                int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
                int __a_b__e = 0;

                byte[] __a_b__d = new byte[__a_b__f];
                foreach (var __p__ in pieces)
                {
                    Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                    __a_b__e += __p__.Length;
                }
                return(__a_b__d);
            }
コード例 #2
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            int  currentIndex = 0, length = 0;
            bool hasmetacomponents = false;

            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();
            GCHandle      h;

            //header
            if (header == null)
            {
                header = new Header();
            }
            pieces.Add(header.Serialize(true));
            //type
            if (type == null)
            {
                type = new Messages.object_recognition_msgs.ObjectType();
            }
            pieces.Add(type.Serialize(true));
            //confidence
            scratch1 = new byte[Marshal.SizeOf(typeof(Single))];
            h        = GCHandle.Alloc(scratch1, GCHandleType.Pinned);
            Marshal.StructureToPtr(confidence, h.AddrOfPinnedObject(), false);
            h.Free();
            pieces.Add(scratch1);
            //point_clouds
            hasmetacomponents |= true;
            if (point_clouds == null)
            {
                point_clouds = new Messages.sensor_msgs.PointCloud2[0];
            }
            pieces.Add(BitConverter.GetBytes(point_clouds.Length));
            for (int i = 0; i < point_clouds.Length; i++)
            {
                //point_clouds[i]
                if (point_clouds[i] == null)
                {
                    point_clouds[i] = new Messages.sensor_msgs.PointCloud2();
                }
                pieces.Add(point_clouds[i].Serialize(true));
            }
            //bounding_mesh
            if (bounding_mesh == null)
            {
                bounding_mesh = new Messages.shape_msgs.Mesh();
            }
            pieces.Add(bounding_mesh.Serialize(true));
            //bounding_contours
            hasmetacomponents |= true;
            if (bounding_contours == null)
            {
                bounding_contours = new Point[0];
            }
            pieces.Add(BitConverter.GetBytes(bounding_contours.Length));
            for (int i = 0; i < bounding_contours.Length; i++)
            {
                //bounding_contours[i]
                if (bounding_contours[i] == null)
                {
                    bounding_contours[i] = new Point();
                }
                pieces.Add(bounding_contours[i].Serialize(true));
            }
            //pose
            if (pose == null)
            {
                pose = new PoseWithCovarianceStamped();
            }
            pieces.Add(pose.Serialize(true));
            //combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }