00001 """autogenerated by genmsg_py from Arrays.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import roslib.rostime
00006
00007 class Arrays(roslib.message.Message):
00008 _md5sum = "c5a1f18379b10bdd4df210944f6007a4"
00009 _type = "test_rostopic/Arrays"
00010 _has_header = False
00011 _full_text = """int8[] int8_arr
00012 uint8[] uint8_arr
00013 int32[] int32_arr
00014 uint32[] uint32_arr
00015 string[] string_arr
00016 time[] time_arr
00017
00018 """
00019 __slots__ = ['int8_arr','uint8_arr','int32_arr','uint32_arr','string_arr','time_arr']
00020 _slot_types = ['int8[]','uint8[]','int32[]','uint32[]','string[]','time[]']
00021
00022 def __init__(self, *args, **kwds):
00023 """
00024 Constructor. Any message fields that are implicitly/explicitly
00025 set to None will be assigned a default value. The recommend
00026 use is keyword arguments as this is more robust to future message
00027 changes. You cannot mix in-order arguments and keyword arguments.
00028
00029 The available fields are:
00030 int8_arr,uint8_arr,int32_arr,uint32_arr,string_arr,time_arr
00031
00032 @param args: complete set of field values, in .msg order
00033 @param kwds: use keyword arguments corresponding to message field names
00034 to set specific fields.
00035 """
00036 if args or kwds:
00037 super(Arrays, self).__init__(*args, **kwds)
00038
00039 if self.int8_arr is None:
00040 self.int8_arr = []
00041 if self.uint8_arr is None:
00042 self.uint8_arr = ''
00043 if self.int32_arr is None:
00044 self.int32_arr = []
00045 if self.uint32_arr is None:
00046 self.uint32_arr = []
00047 if self.string_arr is None:
00048 self.string_arr = []
00049 if self.time_arr is None:
00050 self.time_arr = []
00051 else:
00052 self.int8_arr = []
00053 self.uint8_arr = ''
00054 self.int32_arr = []
00055 self.uint32_arr = []
00056 self.string_arr = []
00057 self.time_arr = []
00058
00059 def _get_types(self):
00060 """
00061 internal API method
00062 """
00063 return self._slot_types
00064
00065 def serialize(self, buff):
00066 """
00067 serialize message into buffer
00068 @param buff: buffer
00069 @type buff: StringIO
00070 """
00071 try:
00072 length = len(self.int8_arr)
00073 buff.write(_struct_I.pack(length))
00074 pattern = '<%sb'%length
00075 buff.write(struct.pack(pattern, *self.int8_arr))
00076 _x = self.uint8_arr
00077 length = len(_x)
00078
00079 if type(_x) in [list, tuple]:
00080 buff.write(struct.pack('<I%sB'%length, length, *_x))
00081 else:
00082 buff.write(struct.pack('<I%ss'%length, length, _x))
00083 length = len(self.int32_arr)
00084 buff.write(_struct_I.pack(length))
00085 pattern = '<%si'%length
00086 buff.write(struct.pack(pattern, *self.int32_arr))
00087 length = len(self.uint32_arr)
00088 buff.write(_struct_I.pack(length))
00089 pattern = '<%sI'%length
00090 buff.write(struct.pack(pattern, *self.uint32_arr))
00091 length = len(self.string_arr)
00092 buff.write(_struct_I.pack(length))
00093 for val1 in self.string_arr:
00094 length = len(val1)
00095 buff.write(struct.pack('<I%ss'%length, length, val1))
00096 length = len(self.time_arr)
00097 buff.write(_struct_I.pack(length))
00098 for val1 in self.time_arr:
00099 _x = val1
00100 buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00101 except struct.error, se: self._check_types(se)
00102 except TypeError, te: self._check_types(te)
00103
00104 def deserialize(self, str):
00105 """
00106 unpack serialized message in str into this message instance
00107 @param str: byte array of serialized message
00108 @type str: str
00109 """
00110 try:
00111 end = 0
00112 start = end
00113 end += 4
00114 (length,) = _struct_I.unpack(str[start:end])
00115 pattern = '<%sb'%length
00116 start = end
00117 end += struct.calcsize(pattern)
00118 self.int8_arr = struct.unpack(pattern, str[start:end])
00119 start = end
00120 end += 4
00121 (length,) = _struct_I.unpack(str[start:end])
00122 start = end
00123 end += length
00124 self.uint8_arr = str[start:end]
00125 start = end
00126 end += 4
00127 (length,) = _struct_I.unpack(str[start:end])
00128 pattern = '<%si'%length
00129 start = end
00130 end += struct.calcsize(pattern)
00131 self.int32_arr = struct.unpack(pattern, str[start:end])
00132 start = end
00133 end += 4
00134 (length,) = _struct_I.unpack(str[start:end])
00135 pattern = '<%sI'%length
00136 start = end
00137 end += struct.calcsize(pattern)
00138 self.uint32_arr = struct.unpack(pattern, str[start:end])
00139 start = end
00140 end += 4
00141 (length,) = _struct_I.unpack(str[start:end])
00142 self.string_arr = []
00143 for i in xrange(0, length):
00144 start = end
00145 end += 4
00146 (length,) = _struct_I.unpack(str[start:end])
00147 start = end
00148 end += length
00149 val1 = str[start:end]
00150 self.string_arr.append(val1)
00151 start = end
00152 end += 4
00153 (length,) = _struct_I.unpack(str[start:end])
00154 self.time_arr = []
00155 for i in xrange(0, length):
00156 val1 = roslib.rostime.Time()
00157 _x = val1
00158 start = end
00159 end += 8
00160 (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00161 self.time_arr.append(val1)
00162 return self
00163 except struct.error, e:
00164 raise roslib.message.DeserializationError(e)
00165
00166
00167 def serialize_numpy(self, buff, numpy):
00168 """
00169 serialize message with numpy array types into buffer
00170 @param buff: buffer
00171 @type buff: StringIO
00172 @param numpy: numpy python module
00173 @type numpy module
00174 """
00175 try:
00176 length = len(self.int8_arr)
00177 buff.write(_struct_I.pack(length))
00178 pattern = '<%sb'%length
00179 buff.write(self.int8_arr.tostring())
00180 _x = self.uint8_arr
00181 length = len(_x)
00182
00183 if type(_x) in [list, tuple]:
00184 buff.write(struct.pack('<I%sB'%length, length, *_x))
00185 else:
00186 buff.write(struct.pack('<I%ss'%length, length, _x))
00187 length = len(self.int32_arr)
00188 buff.write(_struct_I.pack(length))
00189 pattern = '<%si'%length
00190 buff.write(self.int32_arr.tostring())
00191 length = len(self.uint32_arr)
00192 buff.write(_struct_I.pack(length))
00193 pattern = '<%sI'%length
00194 buff.write(self.uint32_arr.tostring())
00195 length = len(self.string_arr)
00196 buff.write(_struct_I.pack(length))
00197 for val1 in self.string_arr:
00198 length = len(val1)
00199 buff.write(struct.pack('<I%ss'%length, length, val1))
00200 length = len(self.time_arr)
00201 buff.write(_struct_I.pack(length))
00202 for val1 in self.time_arr:
00203 _x = val1
00204 buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00205 except struct.error, se: self._check_types(se)
00206 except TypeError, te: self._check_types(te)
00207
00208 def deserialize_numpy(self, str, numpy):
00209 """
00210 unpack serialized message in str into this message instance using numpy for array types
00211 @param str: byte array of serialized message
00212 @type str: str
00213 @param numpy: numpy python module
00214 @type numpy: module
00215 """
00216 try:
00217 end = 0
00218 start = end
00219 end += 4
00220 (length,) = _struct_I.unpack(str[start:end])
00221 pattern = '<%sb'%length
00222 start = end
00223 end += struct.calcsize(pattern)
00224 self.int8_arr = numpy.frombuffer(str[start:end], dtype=numpy.int8, count=length)
00225 start = end
00226 end += 4
00227 (length,) = _struct_I.unpack(str[start:end])
00228 start = end
00229 end += length
00230 self.uint8_arr = str[start:end]
00231 start = end
00232 end += 4
00233 (length,) = _struct_I.unpack(str[start:end])
00234 pattern = '<%si'%length
00235 start = end
00236 end += struct.calcsize(pattern)
00237 self.int32_arr = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00238 start = end
00239 end += 4
00240 (length,) = _struct_I.unpack(str[start:end])
00241 pattern = '<%sI'%length
00242 start = end
00243 end += struct.calcsize(pattern)
00244 self.uint32_arr = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00245 start = end
00246 end += 4
00247 (length,) = _struct_I.unpack(str[start:end])
00248 self.string_arr = []
00249 for i in xrange(0, length):
00250 start = end
00251 end += 4
00252 (length,) = _struct_I.unpack(str[start:end])
00253 start = end
00254 end += length
00255 val1 = str[start:end]
00256 self.string_arr.append(val1)
00257 start = end
00258 end += 4
00259 (length,) = _struct_I.unpack(str[start:end])
00260 self.time_arr = []
00261 for i in xrange(0, length):
00262 val1 = roslib.rostime.Time()
00263 _x = val1
00264 start = end
00265 end += 8
00266 (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00267 self.time_arr.append(val1)
00268 return self
00269 except struct.error, e:
00270 raise roslib.message.DeserializationError(e)
00271
00272 _struct_I = roslib.message.struct_I
00273 _struct_2I = struct.Struct("<2I")