00001 """autogenerated by genpy from srs_knowledge/PerceptionAction.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007 import srs_knowledge.msg
00008
00009 class PerceptionAction(genpy.Message):
00010 _md5sum = "815ae920af48073fc94b8835cc3d5ea6"
00011 _type = "srs_knowledge/PerceptionAction"
00012 _has_header = False
00013 _full_text = """# if detect an object or a class: object:class:none
00014 string detectType
00015
00016 ABoxObject aboxObject
00017 TBoxObject tboxClass
00018 ================================================================================
00019 MSG: srs_knowledge/ABoxObject
00020 int32 object_id
00021 string name
00022 string description
00023
00024 ================================================================================
00025 MSG: srs_knowledge/TBoxObject
00026 int32 class_id
00027 string name
00028 string description
00029 string[] properties
00030 int32[] subjects
00031 """
00032 __slots__ = ['detectType','aboxObject','tboxClass']
00033 _slot_types = ['string','srs_knowledge/ABoxObject','srs_knowledge/TBoxObject']
00034
00035 def __init__(self, *args, **kwds):
00036 """
00037 Constructor. Any message fields that are implicitly/explicitly
00038 set to None will be assigned a default value. The recommend
00039 use is keyword arguments as this is more robust to future message
00040 changes. You cannot mix in-order arguments and keyword arguments.
00041
00042 The available fields are:
00043 detectType,aboxObject,tboxClass
00044
00045 :param args: complete set of field values, in .msg order
00046 :param kwds: use keyword arguments corresponding to message field names
00047 to set specific fields.
00048 """
00049 if args or kwds:
00050 super(PerceptionAction, self).__init__(*args, **kwds)
00051
00052 if self.detectType is None:
00053 self.detectType = ''
00054 if self.aboxObject is None:
00055 self.aboxObject = srs_knowledge.msg.ABoxObject()
00056 if self.tboxClass is None:
00057 self.tboxClass = srs_knowledge.msg.TBoxObject()
00058 else:
00059 self.detectType = ''
00060 self.aboxObject = srs_knowledge.msg.ABoxObject()
00061 self.tboxClass = srs_knowledge.msg.TBoxObject()
00062
00063 def _get_types(self):
00064 """
00065 internal API method
00066 """
00067 return self._slot_types
00068
00069 def serialize(self, buff):
00070 """
00071 serialize message into buffer
00072 :param buff: buffer, ``StringIO``
00073 """
00074 try:
00075 _x = self.detectType
00076 length = len(_x)
00077 if python3 or type(_x) == unicode:
00078 _x = _x.encode('utf-8')
00079 length = len(_x)
00080 buff.write(struct.pack('<I%ss'%length, length, _x))
00081 buff.write(_struct_i.pack(self.aboxObject.object_id))
00082 _x = self.aboxObject.name
00083 length = len(_x)
00084 if python3 or type(_x) == unicode:
00085 _x = _x.encode('utf-8')
00086 length = len(_x)
00087 buff.write(struct.pack('<I%ss'%length, length, _x))
00088 _x = self.aboxObject.description
00089 length = len(_x)
00090 if python3 or type(_x) == unicode:
00091 _x = _x.encode('utf-8')
00092 length = len(_x)
00093 buff.write(struct.pack('<I%ss'%length, length, _x))
00094 buff.write(_struct_i.pack(self.tboxClass.class_id))
00095 _x = self.tboxClass.name
00096 length = len(_x)
00097 if python3 or type(_x) == unicode:
00098 _x = _x.encode('utf-8')
00099 length = len(_x)
00100 buff.write(struct.pack('<I%ss'%length, length, _x))
00101 _x = self.tboxClass.description
00102 length = len(_x)
00103 if python3 or type(_x) == unicode:
00104 _x = _x.encode('utf-8')
00105 length = len(_x)
00106 buff.write(struct.pack('<I%ss'%length, length, _x))
00107 length = len(self.tboxClass.properties)
00108 buff.write(_struct_I.pack(length))
00109 for val1 in self.tboxClass.properties:
00110 length = len(val1)
00111 if python3 or type(val1) == unicode:
00112 val1 = val1.encode('utf-8')
00113 length = len(val1)
00114 buff.write(struct.pack('<I%ss'%length, length, val1))
00115 length = len(self.tboxClass.subjects)
00116 buff.write(_struct_I.pack(length))
00117 pattern = '<%si'%length
00118 buff.write(struct.pack(pattern, *self.tboxClass.subjects))
00119 except struct.error as se: self._check_types(se)
00120 except TypeError as te: self._check_types(te)
00121
00122 def deserialize(self, str):
00123 """
00124 unpack serialized message in str into this message instance
00125 :param str: byte array of serialized message, ``str``
00126 """
00127 try:
00128 if self.aboxObject is None:
00129 self.aboxObject = srs_knowledge.msg.ABoxObject()
00130 if self.tboxClass is None:
00131 self.tboxClass = srs_knowledge.msg.TBoxObject()
00132 end = 0
00133 start = end
00134 end += 4
00135 (length,) = _struct_I.unpack(str[start:end])
00136 start = end
00137 end += length
00138 if python3:
00139 self.detectType = str[start:end].decode('utf-8')
00140 else:
00141 self.detectType = str[start:end]
00142 start = end
00143 end += 4
00144 (self.aboxObject.object_id,) = _struct_i.unpack(str[start:end])
00145 start = end
00146 end += 4
00147 (length,) = _struct_I.unpack(str[start:end])
00148 start = end
00149 end += length
00150 if python3:
00151 self.aboxObject.name = str[start:end].decode('utf-8')
00152 else:
00153 self.aboxObject.name = str[start:end]
00154 start = end
00155 end += 4
00156 (length,) = _struct_I.unpack(str[start:end])
00157 start = end
00158 end += length
00159 if python3:
00160 self.aboxObject.description = str[start:end].decode('utf-8')
00161 else:
00162 self.aboxObject.description = str[start:end]
00163 start = end
00164 end += 4
00165 (self.tboxClass.class_id,) = _struct_i.unpack(str[start:end])
00166 start = end
00167 end += 4
00168 (length,) = _struct_I.unpack(str[start:end])
00169 start = end
00170 end += length
00171 if python3:
00172 self.tboxClass.name = str[start:end].decode('utf-8')
00173 else:
00174 self.tboxClass.name = str[start:end]
00175 start = end
00176 end += 4
00177 (length,) = _struct_I.unpack(str[start:end])
00178 start = end
00179 end += length
00180 if python3:
00181 self.tboxClass.description = str[start:end].decode('utf-8')
00182 else:
00183 self.tboxClass.description = str[start:end]
00184 start = end
00185 end += 4
00186 (length,) = _struct_I.unpack(str[start:end])
00187 self.tboxClass.properties = []
00188 for i in range(0, length):
00189 start = end
00190 end += 4
00191 (length,) = _struct_I.unpack(str[start:end])
00192 start = end
00193 end += length
00194 if python3:
00195 val1 = str[start:end].decode('utf-8')
00196 else:
00197 val1 = str[start:end]
00198 self.tboxClass.properties.append(val1)
00199 start = end
00200 end += 4
00201 (length,) = _struct_I.unpack(str[start:end])
00202 pattern = '<%si'%length
00203 start = end
00204 end += struct.calcsize(pattern)
00205 self.tboxClass.subjects = struct.unpack(pattern, str[start:end])
00206 return self
00207 except struct.error as e:
00208 raise genpy.DeserializationError(e)
00209
00210
00211 def serialize_numpy(self, buff, numpy):
00212 """
00213 serialize message with numpy array types into buffer
00214 :param buff: buffer, ``StringIO``
00215 :param numpy: numpy python module
00216 """
00217 try:
00218 _x = self.detectType
00219 length = len(_x)
00220 if python3 or type(_x) == unicode:
00221 _x = _x.encode('utf-8')
00222 length = len(_x)
00223 buff.write(struct.pack('<I%ss'%length, length, _x))
00224 buff.write(_struct_i.pack(self.aboxObject.object_id))
00225 _x = self.aboxObject.name
00226 length = len(_x)
00227 if python3 or type(_x) == unicode:
00228 _x = _x.encode('utf-8')
00229 length = len(_x)
00230 buff.write(struct.pack('<I%ss'%length, length, _x))
00231 _x = self.aboxObject.description
00232 length = len(_x)
00233 if python3 or type(_x) == unicode:
00234 _x = _x.encode('utf-8')
00235 length = len(_x)
00236 buff.write(struct.pack('<I%ss'%length, length, _x))
00237 buff.write(_struct_i.pack(self.tboxClass.class_id))
00238 _x = self.tboxClass.name
00239 length = len(_x)
00240 if python3 or type(_x) == unicode:
00241 _x = _x.encode('utf-8')
00242 length = len(_x)
00243 buff.write(struct.pack('<I%ss'%length, length, _x))
00244 _x = self.tboxClass.description
00245 length = len(_x)
00246 if python3 or type(_x) == unicode:
00247 _x = _x.encode('utf-8')
00248 length = len(_x)
00249 buff.write(struct.pack('<I%ss'%length, length, _x))
00250 length = len(self.tboxClass.properties)
00251 buff.write(_struct_I.pack(length))
00252 for val1 in self.tboxClass.properties:
00253 length = len(val1)
00254 if python3 or type(val1) == unicode:
00255 val1 = val1.encode('utf-8')
00256 length = len(val1)
00257 buff.write(struct.pack('<I%ss'%length, length, val1))
00258 length = len(self.tboxClass.subjects)
00259 buff.write(_struct_I.pack(length))
00260 pattern = '<%si'%length
00261 buff.write(self.tboxClass.subjects.tostring())
00262 except struct.error as se: self._check_types(se)
00263 except TypeError as te: self._check_types(te)
00264
00265 def deserialize_numpy(self, str, numpy):
00266 """
00267 unpack serialized message in str into this message instance using numpy for array types
00268 :param str: byte array of serialized message, ``str``
00269 :param numpy: numpy python module
00270 """
00271 try:
00272 if self.aboxObject is None:
00273 self.aboxObject = srs_knowledge.msg.ABoxObject()
00274 if self.tboxClass is None:
00275 self.tboxClass = srs_knowledge.msg.TBoxObject()
00276 end = 0
00277 start = end
00278 end += 4
00279 (length,) = _struct_I.unpack(str[start:end])
00280 start = end
00281 end += length
00282 if python3:
00283 self.detectType = str[start:end].decode('utf-8')
00284 else:
00285 self.detectType = str[start:end]
00286 start = end
00287 end += 4
00288 (self.aboxObject.object_id,) = _struct_i.unpack(str[start:end])
00289 start = end
00290 end += 4
00291 (length,) = _struct_I.unpack(str[start:end])
00292 start = end
00293 end += length
00294 if python3:
00295 self.aboxObject.name = str[start:end].decode('utf-8')
00296 else:
00297 self.aboxObject.name = str[start:end]
00298 start = end
00299 end += 4
00300 (length,) = _struct_I.unpack(str[start:end])
00301 start = end
00302 end += length
00303 if python3:
00304 self.aboxObject.description = str[start:end].decode('utf-8')
00305 else:
00306 self.aboxObject.description = str[start:end]
00307 start = end
00308 end += 4
00309 (self.tboxClass.class_id,) = _struct_i.unpack(str[start:end])
00310 start = end
00311 end += 4
00312 (length,) = _struct_I.unpack(str[start:end])
00313 start = end
00314 end += length
00315 if python3:
00316 self.tboxClass.name = str[start:end].decode('utf-8')
00317 else:
00318 self.tboxClass.name = str[start:end]
00319 start = end
00320 end += 4
00321 (length,) = _struct_I.unpack(str[start:end])
00322 start = end
00323 end += length
00324 if python3:
00325 self.tboxClass.description = str[start:end].decode('utf-8')
00326 else:
00327 self.tboxClass.description = str[start:end]
00328 start = end
00329 end += 4
00330 (length,) = _struct_I.unpack(str[start:end])
00331 self.tboxClass.properties = []
00332 for i in range(0, length):
00333 start = end
00334 end += 4
00335 (length,) = _struct_I.unpack(str[start:end])
00336 start = end
00337 end += length
00338 if python3:
00339 val1 = str[start:end].decode('utf-8')
00340 else:
00341 val1 = str[start:end]
00342 self.tboxClass.properties.append(val1)
00343 start = end
00344 end += 4
00345 (length,) = _struct_I.unpack(str[start:end])
00346 pattern = '<%si'%length
00347 start = end
00348 end += struct.calcsize(pattern)
00349 self.tboxClass.subjects = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00350 return self
00351 except struct.error as e:
00352 raise genpy.DeserializationError(e)
00353
00354 _struct_I = genpy.struct_I
00355 _struct_i = struct.Struct("<i")