Example #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;
                IntPtr        ptr;
                int           x__size;

                //current_joint_position
                if (current_joint_position == null)
                {
                    current_joint_position = new Messages.sensor_msgs.JointState();
                }
                pieces.Add(current_joint_position.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 byte[] Serialize(bool partofsomethingelse)
            {
                int  currentIndex = 0, length = 0;
                bool hasmetacomponents = false;

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

                //joints
                hasmetacomponents |= true;
                if (joints == null)
                {
                    joints = new Messages.sensor_msgs.JointState[0];
                }
                pieces.Add(BitConverter.GetBytes(joints.Length));
                for (int i = 0; i < joints.Length; i++)
                {
                    //joints[i]
                    if (joints[i] == null)
                    {
                        joints[i] = new Messages.sensor_msgs.JointState();
                    }
                    pieces.Add(joints[i].Serialize(true));
                }
                //isValid
                hasmetacomponents |= false;
                if (isValid == null)
                {
                    isValid = new bool[0];
                }
                pieces.Add(BitConverter.GetBytes(isValid.Length));
                for (int i = 0; i < isValid.Length; i++)
                {
                    //isValid[i]
                    thischunk    = new byte[1];
                    thischunk[0] = (byte)((bool)isValid[i] ? 1 : 0);
                    pieces.Add(thischunk);
                }
                //result_type
                hasmetacomponents |= false;
                if (result_type == null)
                {
                    result_type = new byte[0];
                }
                pieces.Add(BitConverter.GetBytes(result_type.Length));
                pieces.Add((byte[])result_type);
                //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);
            }
            //[System.Diagnostics.DebuggerStepThrough]
            public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex)
            {
                int  arraylength       = -1;
                bool hasmetacomponents = false;
                int  piecesize         = 0;

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

                //joints
                hasmetacomponents |= true;
                arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
                currentIndex      += Marshal.SizeOf(typeof(System.Int32));
                if (joints == null)
                {
                    joints = new Messages.sensor_msgs.JointState[arraylength];
                }
                else
                {
                    Array.Resize(ref joints, arraylength);
                }
                for (int i = 0; i < joints.Length; i++)
                {
                    //joints[i]
                    joints[i] = new Messages.sensor_msgs.JointState(SERIALIZEDSTUFF, ref currentIndex);
                }
                //isValid
                hasmetacomponents |= false;
                arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
                currentIndex      += Marshal.SizeOf(typeof(System.Int32));
                if (isValid == null)
                {
                    isValid = new bool[arraylength];
                }
                else
                {
                    Array.Resize(ref isValid, arraylength);
                }
                for (int i = 0; i < isValid.Length; i++)
                {
                    //isValid[i]
                    isValid[i] = SERIALIZEDSTUFF[currentIndex++] == 1;
                }
                //result_type
                hasmetacomponents |= false;
                arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
                currentIndex      += Marshal.SizeOf(typeof(System.Int32));
                if (result_type == null)
                {
                    result_type = new byte[arraylength];
                }
                else
                {
                    Array.Resize(ref result_type, arraylength);
                }
                Array.Copy(SERIALIZEDSTUFF, currentIndex, result_type, 0, result_type.Length);
                currentIndex += result_type.Length;
            }
            public override void Randomize()
            {
                int    arraylength = -1;
                Random rand        = new Random();
                int    strlength;

                byte[] strbuf, myByte;

                //joints
                arraylength = rand.Next(10);
                if (joints == null)
                {
                    joints = new Messages.sensor_msgs.JointState[arraylength];
                }
                else
                {
                    Array.Resize(ref joints, arraylength);
                }
                for (int i = 0; i < joints.Length; i++)
                {
                    //joints[i]
                    joints[i] = new Messages.sensor_msgs.JointState();
                    joints[i].Randomize();
                }
                //isValid
                arraylength = rand.Next(10);
                if (isValid == null)
                {
                    isValid = new bool[arraylength];
                }
                else
                {
                    Array.Resize(ref isValid, arraylength);
                }
                for (int i = 0; i < isValid.Length; i++)
                {
                    //isValid[i]
                    isValid[i] = rand.Next(2) == 1;
                }
                //result_type
                arraylength = rand.Next(10);
                if (result_type == null)
                {
                    result_type = new byte[arraylength];
                }
                else
                {
                    Array.Resize(ref result_type, arraylength);
                }
                for (int i = 0; i < result_type.Length; i++)
                {
                    //result_type[i]
                    myByte = new byte[1];
                    rand.NextBytes(myByte);
                    result_type[i] = myByte[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;

                //pose_stamp
                hasmetacomponents |= true;
                if (pose_stamp == null)
                {
                    pose_stamp = new PoseStamped[0];
                }
                pieces.Add(BitConverter.GetBytes(pose_stamp.Length));
                for (int i = 0; i < pose_stamp.Length; i++)
                {
                    //pose_stamp[i]
                    if (pose_stamp[i] == null)
                    {
                        pose_stamp[i] = new PoseStamped();
                    }
                    pieces.Add(pose_stamp[i].Serialize(true));
                }
                //seed_angles
                hasmetacomponents |= true;
                if (seed_angles == null)
                {
                    seed_angles = new Messages.sensor_msgs.JointState[0];
                }
                pieces.Add(BitConverter.GetBytes(seed_angles.Length));
                for (int i = 0; i < seed_angles.Length; i++)
                {
                    //seed_angles[i]
                    if (seed_angles[i] == null)
                    {
                        seed_angles[i] = new Messages.sensor_msgs.JointState();
                    }
                    pieces.Add(seed_angles[i].Serialize(true));
                }
                //seed_mode
                pieces.Add(new[] { (byte)seed_mode });
                //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 #6
0
            public override void Randomize()
            {
                int    arraylength = -1;
                Random rand        = new Random();
                int    strlength;

                byte[] strbuf, myByte;

                //current_joint_position
                current_joint_position = new Messages.sensor_msgs.JointState();
                current_joint_position.Randomize();
            }
Example #7
0
            public override void Deserialize(byte[] serializedMessage, ref int currentIndex)
            {
                int  arraylength       = -1;
                bool hasmetacomponents = false;
                int  piecesize         = 0;

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

                //current_joint_position
                current_joint_position = new Messages.sensor_msgs.JointState(serializedMessage, ref currentIndex);
            }
            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;

                //pose_stamp
                hasmetacomponents |= true;
                arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
                currentIndex      += Marshal.SizeOf(typeof(System.Int32));
                if (pose_stamp == null)
                {
                    pose_stamp = new PoseStamped[arraylength];
                }
                else
                {
                    Array.Resize(ref pose_stamp, arraylength);
                }
                for (int i = 0; i < pose_stamp.Length; i++)
                {
                    //pose_stamp[i]
                    pose_stamp[i] = new PoseStamped(SERIALIZEDSTUFF, ref currentIndex);
                }
                //seed_angles
                hasmetacomponents |= true;
                arraylength        = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex);
                currentIndex      += Marshal.SizeOf(typeof(System.Int32));
                if (seed_angles == null)
                {
                    seed_angles = new Messages.sensor_msgs.JointState[arraylength];
                }
                else
                {
                    Array.Resize(ref seed_angles, arraylength);
                }
                for (int i = 0; i < seed_angles.Length; i++)
                {
                    //seed_angles[i]
                    seed_angles[i] = new Messages.sensor_msgs.JointState(SERIALIZEDSTUFF, ref currentIndex);
                }
                //seed_mode
                seed_mode = SERIALIZEDSTUFF[currentIndex++];
            }
            public override void Randomize()
            {
                int    arraylength = -1;
                Random rand        = new Random();
                int    strlength;

                byte[] strbuf, myByte;

                //pose_stamp
                arraylength = rand.Next(10);
                if (pose_stamp == null)
                {
                    pose_stamp = new PoseStamped[arraylength];
                }
                else
                {
                    Array.Resize(ref pose_stamp, arraylength);
                }
                for (int i = 0; i < pose_stamp.Length; i++)
                {
                    //pose_stamp[i]
                    pose_stamp[i] = new PoseStamped();
                    pose_stamp[i].Randomize();
                }
                //seed_angles
                arraylength = rand.Next(10);
                if (seed_angles == null)
                {
                    seed_angles = new Messages.sensor_msgs.JointState[arraylength];
                }
                else
                {
                    Array.Resize(ref seed_angles, arraylength);
                }
                for (int i = 0; i < seed_angles.Length; i++)
                {
                    //seed_angles[i]
                    seed_angles[i] = new Messages.sensor_msgs.JointState();
                    seed_angles[i].Randomize();
                }
                //seed_mode
                myByte = new byte[1];
                rand.NextBytes(myByte);
                seed_mode = myByte[0];
            }