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);
            }
Esempio n. 2
0
 public RecognizedObject(Header header, ObjectType type, float confidence, PointCloud2[] point_clouds, Mesh bounding_mesh, Point[] bounding_contours, PoseWithCovarianceStamped pose)
 {
     this.header            = header;
     this.type              = type;
     this.confidence        = confidence;
     this.point_clouds      = point_clouds;
     this.bounding_mesh     = bounding_mesh;
     this.bounding_contours = bounding_contours;
     this.pose              = pose;
 }
Esempio n. 3
0
 public RecognizedObject()
 {
     this.header            = new Header();
     this.type              = new ObjectType();
     this.confidence        = 0.0f;
     this.point_clouds      = new PointCloud2[0];
     this.bounding_mesh     = new Mesh();
     this.bounding_contours = new Point[0];
     this.pose              = new PoseWithCovarianceStamped();
 }
        public override void Randomize()
        {
            int    arraylength = -1;
            Random rand        = new Random();
            int    strlength;

            byte[] strbuf, myByte;

            //header
            header = new Header();
            header.Randomize();
            //type
            type = new Messages.object_recognition_msgs.ObjectType();
            type.Randomize();
            //confidence
            confidence = (float)(rand.Next() + rand.NextDouble());
            //point_clouds
            arraylength = rand.Next(10);
            if (point_clouds == null)
            {
                point_clouds = new Messages.sensor_msgs.PointCloud2[arraylength];
            }
            else
            {
                Array.Resize(ref point_clouds, arraylength);
            }
            for (int i = 0; i < point_clouds.Length; i++)
            {
                //point_clouds[i]
                point_clouds[i] = new Messages.sensor_msgs.PointCloud2();
                point_clouds[i].Randomize();
            }
            //bounding_mesh
            bounding_mesh = new Messages.shape_msgs.Mesh();
            bounding_mesh.Randomize();
            //bounding_contours
            arraylength = rand.Next(10);
            if (bounding_contours == null)
            {
                bounding_contours = new Point[arraylength];
            }
            else
            {
                Array.Resize(ref bounding_contours, arraylength);
            }
            for (int i = 0; i < bounding_contours.Length; i++)
            {
                //bounding_contours[i]
                bounding_contours[i] = new Point();
                bounding_contours[i].Randomize();
            }
            //pose
            pose = new PoseWithCovarianceStamped();
            pose.Randomize();
        }
            public override void Randomize()
            {
                int    arraylength = -1;
                Random rand        = new Random();
                int    strlength;

                byte[] strbuf, myByte;

                //map
                map = new Messages.nav_msgs.OccupancyGrid();
                map.Randomize();
                //initial_pose
                initial_pose = new PoseWithCovarianceStamped();
                initial_pose.Randomize();
            }
            public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
            {
                int  arraylength       = -1;
                bool hasmetacomponents = false;

                byte[] thischunk, scratch1, scratch2;
                object __thing;
                int    piecesize = 0;
                IntPtr h;

                //map
                map = new Messages.nav_msgs.OccupancyGrid(SERIALIZEDSTUFF, ref currentIndex);
                //initial_pose
                initial_pose = new PoseWithCovarianceStamped(SERIALIZEDSTUFF, ref currentIndex);
            }
Esempio n. 7
0
 public SetMapRequest(OccupancyGrid map, PoseWithCovarianceStamped initial_pose)
 {
     this.map          = map;
     this.initial_pose = initial_pose;
 }
Esempio n. 8
0
 public SetMapRequest()
 {
     this.map          = new OccupancyGrid();
     this.initial_pose = new PoseWithCovarianceStamped();
 }
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            int    arraylength       = -1;
            bool   hasmetacomponents = false;
            object __thing;
            int    piecesize = 0;

            byte[] thischunk, scratch1, scratch2;
            IntPtr h;

            //header
            header = new Header(SERIALIZEDSTUFF, ref currentIndex);
            //type
            type = new Messages.object_recognition_msgs.ObjectType(SERIALIZEDSTUFF, ref currentIndex);
            //confidence
            piecesize = Marshal.SizeOf(typeof(Single));
            h         = IntPtr.Zero;
            if (SERIALIZEDSTUFF.Length - currentIndex != 0)
            {
                h = Marshal.AllocHGlobal(piecesize);
                Marshal.Copy(SERIALIZEDSTUFF, currentIndex, h, piecesize);
            }
            if (h == IntPtr.Zero)
            {
                throw new Exception("Alloc failed");
            }
            confidence = (Single)Marshal.PtrToStructure(h, typeof(Single));
            Marshal.FreeHGlobal(h);
            currentIndex += piecesize;
            //point_clouds
            hasmetacomponents |= true;
            arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex      += Marshal.SizeOf(typeof(System.Int32));
            if (point_clouds == null)
            {
                point_clouds = new Messages.sensor_msgs.PointCloud2[arraylength];
            }
            else
            {
                Array.Resize(ref point_clouds, arraylength);
            }
            for (int i = 0; i < point_clouds.Length; i++)
            {
                //point_clouds[i]
                point_clouds[i] = new Messages.sensor_msgs.PointCloud2(SERIALIZEDSTUFF, ref currentIndex);
            }
            //bounding_mesh
            bounding_mesh = new Messages.shape_msgs.Mesh(SERIALIZEDSTUFF, ref currentIndex);
            //bounding_contours
            hasmetacomponents |= true;
            arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex      += Marshal.SizeOf(typeof(System.Int32));
            if (bounding_contours == null)
            {
                bounding_contours = new Point[arraylength];
            }
            else
            {
                Array.Resize(ref bounding_contours, arraylength);
            }
            for (int i = 0; i < bounding_contours.Length; i++)
            {
                //bounding_contours[i]
                bounding_contours[i] = new Point(SERIALIZEDSTUFF, ref currentIndex);
            }
            //pose
            pose = new PoseWithCovarianceStamped(SERIALIZEDSTUFF, ref currentIndex);
        }
        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);
        }