Beispiel #1
0
        public override void Randomize()
        {
            int    arraylength = -1;
            Random rand        = new Random();
            int    strlength;

            byte[] strbuf, myByte;

            //points
            arraylength = rand.Next(10);
            if (points == null)
            {
                points = new Point32[arraylength];
            }
            else
            {
                Array.Resize(ref points, arraylength);
            }
            for (int i = 0; i < points.Length; i++)
            {
                //points[i]
                points[i] = new Point32();
                points[i].Randomize();
            }
        }
Beispiel #2
0
        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;

            //points
            hasmetacomponents |= true;
            arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex      += Marshal.SizeOf(typeof(System.Int32));
            if (points == null)
            {
                points = new Point32[arraylength];
            }
            else
            {
                Array.Resize(ref points, arraylength);
            }
            for (int i = 0; i < points.Length; i++)
            {
                //points[i]
                points[i] = new Point32(SERIALIZEDSTUFF, ref currentIndex);
            }
        }
Beispiel #3
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;

            //points
            hasmetacomponents |= true;
            if (points == null)
            {
                points = new Point32[0];
            }
            pieces.Add(BitConverter.GetBytes(points.Length));
            for (int i = 0; i < points.Length; i++)
            {
                //points[i]
                if (points[i] == null)
                {
                    points[i] = new Point32();
                }
                pieces.Add(points[i].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);
        }
Beispiel #4
0
        /// <summary>
        /// 订阅更新话题
        /// </summary>
        /// <param name="topic"></param>
        public void SubscribeToFootprint(string topic)
        {
            lock (this)
            {
                if (foothandle == null)
                {
                    foothandle = new NodeHandle();
                }
                if (footSub != null && footSub.topic != topic)
                {
                    footSub.shutdown();
                    footSub = null;
                }
                if (footSub != null)
                {
                    return;
                }
                if (tfer == null)
                {
                    tfer = new Transformer(false);
                }

                Console.WriteLine("Subscribing to footprint at:= " + topic);
                footSub = foothandle.subscribe <gm.PolygonStamped>(topic, 1, i => owner.BeginInvoke(new Action(() =>
                {
                    if (i.polygon.points.Length == 0)
                    {
                        return;
                    }

                    //if (!tfer.waitForTransform("/map", "/base", i.header.stamp, new m.Duration(new Messages.TimeData(1, 0)), null))
                    //    return ;

                    //tfer.transformVector("/map",)
                    //emTransform ret = new emTransform();
                    //if (tfer.lookupTransform("/map", "/base", i.header.stamp, out ret))
                    //{

                    pointArray.Clear();
                    int length = i.polygon.points.Length;
                    for (int index = 0; index < length; index++)
                    {
                        gm.Point32 p = i.polygon.points[index];

                        //Stamped<emVector3> stampVector_in = new Stamped<emVector3>(i.header.stamp, i.header.frame_id, new emVector3(p.x,p.y,p.z));
                        //Stamped<emVector3> stamVector_out = new Stamped<emVector3>();
                        //tfer.transformVector("map", stampVector_in, ref stamVector_out);

                        Point worldPoint = owner.Map2World(new PointF(p.x, p.y));
                        pointArray.Add(worldPoint);
                    }
                    pointArray.Add(pointArray[0]);
                    if (length > 0)
                    {
                        startPoint = (Point)pointArray[0];
                        endPoint   = (Point)pointArray[length - 1];
                    }
                    Invalidate();
                    owner.LastDataUpdateTime = DateTime.Now;
                    //owner.Invalidate();
                    //}
                })));
            }
        }