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

            //header
            header = new Messages.std_msgs.Header();
            header.Randomize();
            //status_list
            arraylength = rand.Next(10);
            if (status_list == null)
            {
                status_list = new Messages.actionlib_msgs.GoalStatus[arraylength];
            }
            else
            {
                Array.Resize(ref status_list, arraylength);
            }
            for (int i = 0; i < status_list.Length; i++)
            {
                //status_list[i]
                status_list[i] = new Messages.actionlib_msgs.GoalStatus();
                status_list[i].Randomize();
            }
        }
Example #2
0
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header  = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            on      = SERIALIZEDSTUFF [currentIndex++] != 0;
            running = SERIALIZEDSTUFF [currentIndex++] != 0;
            // voltage
            int count = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            voltage       = new float[count];
            for (int i = 0; i < count; i++)
            {
                voltage [i]   = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // frequency
            count         = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            frequency     = new float[count];
            for (int i = 0; i < count; i++)
            {
                frequency [i] = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // current
            count         = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            current       = new float[count];
            for (int i = 0; i < count; i++)
            {
                current [i]   = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
        }
Example #3
0
        public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
        {
            int  arraylength       = -1;
            bool hasmetacomponents = false;

            //header
            header = new Messages.std_msgs.Header(serializedMessage, ref currentIndex);
            //status_list
            hasmetacomponents |= true;
            arraylength        = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex      += Marshal.SizeOf(typeof(System.Int32));
            if (status_list == null)
            {
                status_list = new Messages.actionlib_msgs.GoalStatus[arraylength];
            }
            else
            {
                Array.Resize(ref status_list, arraylength);
            }
            for (int i = 0; i < status_list.Length; i++)
            {
                //status_list[i]
                status_list[i] = new Messages.actionlib_msgs.GoalStatus(serializedMessage, ref currentIndex);
            }
        }
Example #4
0
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     source = SERIALIZEDSTUFF [currentIndex++];
     mode   = SERIALIZEDSTUFF [currentIndex++];
     state  = SERIALIZEDSTUFF [currentIndex++];
 }
Example #5
0
        public override void Randomize()
        {
            Random rand = new Random();
            int    strlength;

            byte[] strbuf;

            //header
            header = new Messages.std_msgs.Header();
            header.Randomize();
            //child_frame_id
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            child_frame_id        = Encoding.ASCII.GetString(strbuf);
            //transform
            transform = new Messages.geometry_msgs.Transform();
            transform.Randomize();
        }
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header           = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     magnetic_heading = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex    += sizeof(float);
     declination      = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex    += sizeof(float);
 }
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header        = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     x             = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex += sizeof(float);
     y             = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex += sizeof(float);
 }
Example #8
0
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     for (int i = 0; i < 3; i++)
     {
         channel [i]   = BitConverter.ToDouble(SERIALIZEDSTUFF, currentIndex);
         currentIndex += 8;
     }
 }
Example #9
0
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header        = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     aileron       = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex += 4;
     elevator      = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex += 4;
     rudder        = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
     currentIndex += 4;
 }
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            int count = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            pwm           = new byte[count];
            for (int i = 0; i < count; i++)
            {
                pwm [i] = SERIALIZEDSTUFF [currentIndex++];
            }
        }
Example #11
0
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            int length = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            value         = new ushort[length];
            for (int i = 0; i < length; i++)
            {
                value [i]     = BitConverter.ToUInt16(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 2;
            }
        }
Example #12
0
 public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
 {
     header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
     for (int i = 0; i < 3; i++)
     {
         angular_velocity [i] = BitConverter.ToInt16(SERIALIZEDSTUFF, currentIndex);
         currentIndex        += 2;
     }
     for (int i = 0; i < 3; i++)
     {
         linear_acceleration [i] = BitConverter.ToInt16(SERIALIZEDSTUFF, currentIndex);
         currentIndex           += 2;
     }
 }
Example #13
0
        public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
        {
            int piecesize = 0;

            //header
            header = new Messages.std_msgs.Header(serializedMessage, ref currentIndex);
            //child_frame_id
            child_frame_id = "";
            piecesize      = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex  += 4;
            child_frame_id = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
            currentIndex  += piecesize;
            //transform
            transform = new Messages.geometry_msgs.Transform(serializedMessage, ref currentIndex);
        }
Example #14
0
 public override void Randomize()
 {
     header = new Header_t();
     header.Randomize();
     on        = UnityEngine.Random.value > 0.5f;
     running   = on;
     voltage   = new float[10];
     frequency = new float[10];
     current   = new float[10];
     for (int i = 0; i < 10; i++)
     {
         voltage [i]   = UnityEngine.Random.value;
         frequency [i] = UnityEngine.Random.value;
         current [i]   = UnityEngine.Random.value;
     }
 }
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            // force
            int length = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            force         = new float[length];
            for (int i = 0; i < length; i++)
            {
                force [i]     = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // torque
            length        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            torque        = new float[length];
            for (int i = 0; i < length; i++)
            {
                torque [i]    = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // frequency
            length        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            frequency     = new float[length];
            for (int i = 0; i < length; i++)
            {
                frequency [i] = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // voltage
            length        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            voltage       = new float[length];
            for (int i = 0; i < length; i++)
            {
                voltage [i]   = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
        }
Example #16
0
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            status = SERIALIZEDSTUFF [currentIndex++];
            valid  = SERIALIZEDSTUFF [currentIndex++] != 0;
            // axis
            int length = System.BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            axis          = new List <float> (length);
            for (int i = 0; i < length; i++)
            {
                axis.Add(System.BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex));
                currentIndex += 4;
            }
            // axis function
            length        = System.BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            axis_function = new List <uint8> (length);
            for (int i = 0; i < length; i++)
            {
                axis_function.Add(SERIALIZEDSTUFF [currentIndex++]);
            }
            // swit
            length        = System.BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            axis_function = new List <uint8> (length);
            for (int i = 0; i < length; i++)
            {
                axis_function.Add(SERIALIZEDSTUFF [currentIndex++]);
            }
            // swit function
            length        = System.BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            axis_function = new List <uint8> (length);
            for (int i = 0; i < length; i++)
            {
                axis_function.Add(SERIALIZEDSTUFF [currentIndex++]);
            }
        }
Example #17
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            byte[]        thischunk, scratch1, scratch2;
            List <byte[]> pieces = new List <byte[]>();

            //header
            if (header == null)
            {
                header = new Messages.std_msgs.Header();
            }
            pieces.Add(header.Serialize(true));
            //child_frame_id
            if (child_frame_id == null)
            {
                child_frame_id = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)child_frame_id);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //transform
            if (transform == null)
            {
                transform = new Messages.geometry_msgs.Transform();
            }
            pieces.Add(transform.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);
        }
Example #18
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            bool          hasmetacomponents = false;
            List <byte[]> pieces            = new List <byte[]>();

            //header
            if (header == null)
            {
                header = new Messages.std_msgs.Header();
            }
            pieces.Add(header.Serialize(true));
            //status_list
            hasmetacomponents |= true;
            if (status_list == null)
            {
                status_list = new Messages.actionlib_msgs.GoalStatus[0];
            }
            pieces.Add(BitConverter.GetBytes(status_list.Length));
            for (int i = 0; i < status_list.Length; i++)
            {
                //status_list[i]
                if (status_list[i] == null)
                {
                    status_list[i] = new Messages.actionlib_msgs.GoalStatus();
                }
                pieces.Add(status_list[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);
        }
        public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
        {
            header = new Header_t(SERIALIZEDSTUFF, ref currentIndex);
            // voltage
            int length = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);

            currentIndex += 4;
            voltage       = new float[length];
            for (int i = 0; i < length; i++)
            {
                voltage[i]    = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
            // current
            length        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
            currentIndex += 4;
            current       = new float[length];
            for (int i = 0; i < length; i++)
            {
                current[i]    = BitConverter.ToSingle(SERIALIZEDSTUFF, currentIndex);
                currentIndex += 4;
            }
        }
Example #20
0
        public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
        {
            int    arraylength       = -1;
            bool   hasmetacomponents = false;
            int    piecesize         = 0;
            IntPtr h;

            //header
            header = new Messages.std_msgs.Header(serializedMessage, ref currentIndex);
            //level
            level = serializedMessage[currentIndex++];
            //name
            name          = "";
            piecesize     = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex += 4;
            name          = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
            currentIndex += piecesize;
            //msg
            msg           = "";
            piecesize     = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex += 4;
            msg           = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
            currentIndex += piecesize;
            //file
            file          = "";
            piecesize     = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex += 4;
            file          = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
            currentIndex += piecesize;
            //function
            function      = "";
            piecesize     = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex += 4;
            function      = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
            currentIndex += piecesize;
            //line
            piecesize = Marshal.SizeOf(typeof(uint));
            h         = IntPtr.Zero;
            if (serializedMessage.Length - currentIndex != 0)
            {
                h = Marshal.AllocHGlobal(piecesize);
                Marshal.Copy(serializedMessage, currentIndex, h, piecesize);
            }
            if (h == IntPtr.Zero)
            {
                throw new Exception("Memory allocation failed");
            }
            line = (uint)Marshal.PtrToStructure(h, typeof(uint));
            Marshal.FreeHGlobal(h);
            currentIndex += piecesize;
            //topics
            hasmetacomponents |= false;
            arraylength        = BitConverter.ToInt32(serializedMessage, currentIndex);
            currentIndex      += Marshal.SizeOf(typeof(System.Int32));
            if (topics == null)
            {
                topics = new string[arraylength];
            }
            else
            {
                Array.Resize(ref topics, arraylength);
            }
            for (int i = 0; i < topics.Length; i++)
            {
                //topics[i]
                topics[i]     = "";
                piecesize     = BitConverter.ToInt32(serializedMessage, currentIndex);
                currentIndex += 4;
                topics[i]     = Encoding.ASCII.GetString(serializedMessage, currentIndex, piecesize);
                currentIndex += piecesize;
            }
        }
Example #21
0
        public override void Randomize()
        {
            int    arraylength = -1;
            Random rand        = new Random();
            int    strlength;

            byte[] strbuf, myByte;

            //header
            header = new Messages.std_msgs.Header();
            header.Randomize();
            //level
            myByte = new byte[1];
            rand.NextBytes(myByte);
            level = myByte[0];
            //name
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            name = Encoding.ASCII.GetString(strbuf);
            //msg
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            msg = Encoding.ASCII.GetString(strbuf);
            //file
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            file = Encoding.ASCII.GetString(strbuf);
            //function
            strlength = rand.Next(100) + 1;
            strbuf    = new byte[strlength];
            rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
            for (int __x__ = 0; __x__ < strlength; __x__++)
            {
                if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                {
                    strbuf[__x__] = (byte)(rand.Next(254) + 1);
                }
            }
            strbuf[strlength - 1] = 0; //null terminate
            function = Encoding.ASCII.GetString(strbuf);
            //line
            line = (uint)rand.Next();
            //topics
            arraylength = rand.Next(10);
            if (topics == null)
            {
                topics = new string[arraylength];
            }
            else
            {
                Array.Resize(ref topics, arraylength);
            }
            for (int i = 0; i < topics.Length; i++)
            {
                //topics[i]
                strlength = rand.Next(100) + 1;
                strbuf    = new byte[strlength];
                rand.NextBytes(strbuf);  //fill the whole buffer with random bytes
                for (int __x__ = 0; __x__ < strlength; __x__++)
                {
                    if (strbuf[__x__] == 0) //replace null chars with non-null random ones
                    {
                        strbuf[__x__] = (byte)(rand.Next(254) + 1);
                    }
                }
                strbuf[strlength - 1] = 0; //null terminate
                topics[i]             = Encoding.ASCII.GetString(strbuf);
            }
        }
Example #22
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            bool hasmetacomponents = false;

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

            //header
            if (header == null)
            {
                header = new Messages.std_msgs.Header();
            }
            pieces.Add(header.Serialize(true));
            //level
            pieces.Add(new[] { (byte)level });
            //name
            if (name == null)
            {
                name = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)name);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //msg
            if (msg == null)
            {
                msg = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)msg);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //file
            if (file == null)
            {
                file = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)file);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //function
            if (function == null)
            {
                function = "";
            }
            scratch1  = Encoding.ASCII.GetBytes((string)function);
            thischunk = new byte[scratch1.Length + 4];
            scratch2  = BitConverter.GetBytes(scratch1.Length);
            Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
            Array.Copy(scratch2, thischunk, 4);
            pieces.Add(thischunk);
            //line
            scratch1 = new byte[Marshal.SizeOf(typeof(uint))];
            h        = GCHandle.Alloc(scratch1, GCHandleType.Pinned);
            Marshal.StructureToPtr(line, h.AddrOfPinnedObject(), false);
            h.Free();
            pieces.Add(scratch1);
            //topics
            hasmetacomponents |= false;
            if (topics == null)
            {
                topics = new string[0];
            }
            pieces.Add(BitConverter.GetBytes(topics.Length));
            for (int i = 0; i < topics.Length; i++)
            {
                //topics[i]
                if (topics[i] == null)
                {
                    topics[i] = "";
                }
                scratch1  = Encoding.ASCII.GetBytes((string)topics[i]);
                thischunk = new byte[scratch1.Length + 4];
                scratch2  = BitConverter.GetBytes(scratch1.Length);
                Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length);
                Array.Copy(scratch2, thischunk, 4);
                pieces.Add(thischunk);
            }
            // 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);
        }
 public MotorPWM()
 {
     header = new Header_t();
     pwm    = new byte[0];
 }