_ObjectState.py
Go to the documentation of this file.
00001 """autogenerated by genpy from wire_msgs/ObjectState.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 wire_msgs.msg
00008 import problib.msg
00009 
00010 class ObjectState(genpy.Message):
00011   _md5sum = "68e5e23a02875f3c610161fde54dc1c3"
00012   _type = "wire_msgs/ObjectState"
00013   _has_header = False #flag to mark the presence of a Header object
00014   _full_text = """uint32 ID
00015 float64 probability # probability that this object is actually in the world
00016 
00017 Property[] properties
00018 
00019 ================================================================================
00020 MSG: wire_msgs/Property
00021 string attribute
00022 problib/PDF pdf
00023 
00024 ================================================================================
00025 MSG: problib/PDF
00026 uint8 EXACT=0     # Is here for easier msg creation, but is actually a specialized case:
00027                   # - continuous: is a Gaussian with zero covariance
00028                   # - discrete: is a Discrete pdf with one entry with P=1                
00029 uint8 GAUSSIAN=1
00030 uint8 UNIFORM=2
00031 uint8 PARTICLES=3
00032 uint8 MIXTURE=4
00033 uint8 DISCRETE=5
00034 uint8 HYBRID=6
00035 
00036 uint8 type
00037 uint32 dimensions
00038 
00039 # For continuous pdf's
00040 float64[] data
00041 
00042 # For discrete pdf's (pmf)
00043 int32 domain_size
00044 string[] values
00045 float64[] probabilities
00046 
00047 # For exact values, either a string or a vector
00048 string exact_value_str
00049 float64[] exact_value_vec
00050 
00051 """
00052   __slots__ = ['ID','probability','properties']
00053   _slot_types = ['uint32','float64','wire_msgs/Property[]']
00054 
00055   def __init__(self, *args, **kwds):
00056     """
00057     Constructor. Any message fields that are implicitly/explicitly
00058     set to None will be assigned a default value. The recommend
00059     use is keyword arguments as this is more robust to future message
00060     changes.  You cannot mix in-order arguments and keyword arguments.
00061 
00062     The available fields are:
00063        ID,probability,properties
00064 
00065     :param args: complete set of field values, in .msg order
00066     :param kwds: use keyword arguments corresponding to message field names
00067     to set specific fields.
00068     """
00069     if args or kwds:
00070       super(ObjectState, self).__init__(*args, **kwds)
00071       #message fields cannot be None, assign default values for those that are
00072       if self.ID is None:
00073         self.ID = 0
00074       if self.probability is None:
00075         self.probability = 0.
00076       if self.properties is None:
00077         self.properties = []
00078     else:
00079       self.ID = 0
00080       self.probability = 0.
00081       self.properties = []
00082 
00083   def _get_types(self):
00084     """
00085     internal API method
00086     """
00087     return self._slot_types
00088 
00089   def serialize(self, buff):
00090     """
00091     serialize message into buffer
00092     :param buff: buffer, ``StringIO``
00093     """
00094     try:
00095       _x = self
00096       buff.write(_struct_Id.pack(_x.ID, _x.probability))
00097       length = len(self.properties)
00098       buff.write(_struct_I.pack(length))
00099       for val1 in self.properties:
00100         _x = val1.attribute
00101         length = len(_x)
00102         if python3 or type(_x) == unicode:
00103           _x = _x.encode('utf-8')
00104           length = len(_x)
00105         buff.write(struct.pack('<I%ss'%length, length, _x))
00106         _v1 = val1.pdf
00107         _x = _v1
00108         buff.write(_struct_BI.pack(_x.type, _x.dimensions))
00109         length = len(_v1.data)
00110         buff.write(_struct_I.pack(length))
00111         pattern = '<%sd'%length
00112         buff.write(struct.pack(pattern, *_v1.data))
00113         buff.write(_struct_i.pack(_v1.domain_size))
00114         length = len(_v1.values)
00115         buff.write(_struct_I.pack(length))
00116         for val3 in _v1.values:
00117           length = len(val3)
00118           if python3 or type(val3) == unicode:
00119             val3 = val3.encode('utf-8')
00120             length = len(val3)
00121           buff.write(struct.pack('<I%ss'%length, length, val3))
00122         length = len(_v1.probabilities)
00123         buff.write(_struct_I.pack(length))
00124         pattern = '<%sd'%length
00125         buff.write(struct.pack(pattern, *_v1.probabilities))
00126         _x = _v1.exact_value_str
00127         length = len(_x)
00128         if python3 or type(_x) == unicode:
00129           _x = _x.encode('utf-8')
00130           length = len(_x)
00131         buff.write(struct.pack('<I%ss'%length, length, _x))
00132         length = len(_v1.exact_value_vec)
00133         buff.write(_struct_I.pack(length))
00134         pattern = '<%sd'%length
00135         buff.write(struct.pack(pattern, *_v1.exact_value_vec))
00136     except struct.error as se: self._check_types(se)
00137     except TypeError as te: self._check_types(te)
00138 
00139   def deserialize(self, str):
00140     """
00141     unpack serialized message in str into this message instance
00142     :param str: byte array of serialized message, ``str``
00143     """
00144     try:
00145       if self.properties is None:
00146         self.properties = None
00147       end = 0
00148       _x = self
00149       start = end
00150       end += 12
00151       (_x.ID, _x.probability,) = _struct_Id.unpack(str[start:end])
00152       start = end
00153       end += 4
00154       (length,) = _struct_I.unpack(str[start:end])
00155       self.properties = []
00156       for i in range(0, length):
00157         val1 = wire_msgs.msg.Property()
00158         start = end
00159         end += 4
00160         (length,) = _struct_I.unpack(str[start:end])
00161         start = end
00162         end += length
00163         if python3:
00164           val1.attribute = str[start:end].decode('utf-8')
00165         else:
00166           val1.attribute = str[start:end]
00167         _v2 = val1.pdf
00168         _x = _v2
00169         start = end
00170         end += 5
00171         (_x.type, _x.dimensions,) = _struct_BI.unpack(str[start:end])
00172         start = end
00173         end += 4
00174         (length,) = _struct_I.unpack(str[start:end])
00175         pattern = '<%sd'%length
00176         start = end
00177         end += struct.calcsize(pattern)
00178         _v2.data = struct.unpack(pattern, str[start:end])
00179         start = end
00180         end += 4
00181         (_v2.domain_size,) = _struct_i.unpack(str[start:end])
00182         start = end
00183         end += 4
00184         (length,) = _struct_I.unpack(str[start:end])
00185         _v2.values = []
00186         for i in range(0, length):
00187           start = end
00188           end += 4
00189           (length,) = _struct_I.unpack(str[start:end])
00190           start = end
00191           end += length
00192           if python3:
00193             val3 = str[start:end].decode('utf-8')
00194           else:
00195             val3 = str[start:end]
00196           _v2.values.append(val3)
00197         start = end
00198         end += 4
00199         (length,) = _struct_I.unpack(str[start:end])
00200         pattern = '<%sd'%length
00201         start = end
00202         end += struct.calcsize(pattern)
00203         _v2.probabilities = struct.unpack(pattern, str[start:end])
00204         start = end
00205         end += 4
00206         (length,) = _struct_I.unpack(str[start:end])
00207         start = end
00208         end += length
00209         if python3:
00210           _v2.exact_value_str = str[start:end].decode('utf-8')
00211         else:
00212           _v2.exact_value_str = str[start:end]
00213         start = end
00214         end += 4
00215         (length,) = _struct_I.unpack(str[start:end])
00216         pattern = '<%sd'%length
00217         start = end
00218         end += struct.calcsize(pattern)
00219         _v2.exact_value_vec = struct.unpack(pattern, str[start:end])
00220         self.properties.append(val1)
00221       return self
00222     except struct.error as e:
00223       raise genpy.DeserializationError(e) #most likely buffer underfill
00224 
00225 
00226   def serialize_numpy(self, buff, numpy):
00227     """
00228     serialize message with numpy array types into buffer
00229     :param buff: buffer, ``StringIO``
00230     :param numpy: numpy python module
00231     """
00232     try:
00233       _x = self
00234       buff.write(_struct_Id.pack(_x.ID, _x.probability))
00235       length = len(self.properties)
00236       buff.write(_struct_I.pack(length))
00237       for val1 in self.properties:
00238         _x = val1.attribute
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         _v3 = val1.pdf
00245         _x = _v3
00246         buff.write(_struct_BI.pack(_x.type, _x.dimensions))
00247         length = len(_v3.data)
00248         buff.write(_struct_I.pack(length))
00249         pattern = '<%sd'%length
00250         buff.write(_v3.data.tostring())
00251         buff.write(_struct_i.pack(_v3.domain_size))
00252         length = len(_v3.values)
00253         buff.write(_struct_I.pack(length))
00254         for val3 in _v3.values:
00255           length = len(val3)
00256           if python3 or type(val3) == unicode:
00257             val3 = val3.encode('utf-8')
00258             length = len(val3)
00259           buff.write(struct.pack('<I%ss'%length, length, val3))
00260         length = len(_v3.probabilities)
00261         buff.write(_struct_I.pack(length))
00262         pattern = '<%sd'%length
00263         buff.write(_v3.probabilities.tostring())
00264         _x = _v3.exact_value_str
00265         length = len(_x)
00266         if python3 or type(_x) == unicode:
00267           _x = _x.encode('utf-8')
00268           length = len(_x)
00269         buff.write(struct.pack('<I%ss'%length, length, _x))
00270         length = len(_v3.exact_value_vec)
00271         buff.write(_struct_I.pack(length))
00272         pattern = '<%sd'%length
00273         buff.write(_v3.exact_value_vec.tostring())
00274     except struct.error as se: self._check_types(se)
00275     except TypeError as te: self._check_types(te)
00276 
00277   def deserialize_numpy(self, str, numpy):
00278     """
00279     unpack serialized message in str into this message instance using numpy for array types
00280     :param str: byte array of serialized message, ``str``
00281     :param numpy: numpy python module
00282     """
00283     try:
00284       if self.properties is None:
00285         self.properties = None
00286       end = 0
00287       _x = self
00288       start = end
00289       end += 12
00290       (_x.ID, _x.probability,) = _struct_Id.unpack(str[start:end])
00291       start = end
00292       end += 4
00293       (length,) = _struct_I.unpack(str[start:end])
00294       self.properties = []
00295       for i in range(0, length):
00296         val1 = wire_msgs.msg.Property()
00297         start = end
00298         end += 4
00299         (length,) = _struct_I.unpack(str[start:end])
00300         start = end
00301         end += length
00302         if python3:
00303           val1.attribute = str[start:end].decode('utf-8')
00304         else:
00305           val1.attribute = str[start:end]
00306         _v4 = val1.pdf
00307         _x = _v4
00308         start = end
00309         end += 5
00310         (_x.type, _x.dimensions,) = _struct_BI.unpack(str[start:end])
00311         start = end
00312         end += 4
00313         (length,) = _struct_I.unpack(str[start:end])
00314         pattern = '<%sd'%length
00315         start = end
00316         end += struct.calcsize(pattern)
00317         _v4.data = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00318         start = end
00319         end += 4
00320         (_v4.domain_size,) = _struct_i.unpack(str[start:end])
00321         start = end
00322         end += 4
00323         (length,) = _struct_I.unpack(str[start:end])
00324         _v4.values = []
00325         for i in range(0, length):
00326           start = end
00327           end += 4
00328           (length,) = _struct_I.unpack(str[start:end])
00329           start = end
00330           end += length
00331           if python3:
00332             val3 = str[start:end].decode('utf-8')
00333           else:
00334             val3 = str[start:end]
00335           _v4.values.append(val3)
00336         start = end
00337         end += 4
00338         (length,) = _struct_I.unpack(str[start:end])
00339         pattern = '<%sd'%length
00340         start = end
00341         end += struct.calcsize(pattern)
00342         _v4.probabilities = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00343         start = end
00344         end += 4
00345         (length,) = _struct_I.unpack(str[start:end])
00346         start = end
00347         end += length
00348         if python3:
00349           _v4.exact_value_str = str[start:end].decode('utf-8')
00350         else:
00351           _v4.exact_value_str = str[start:end]
00352         start = end
00353         end += 4
00354         (length,) = _struct_I.unpack(str[start:end])
00355         pattern = '<%sd'%length
00356         start = end
00357         end += struct.calcsize(pattern)
00358         _v4.exact_value_vec = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00359         self.properties.append(val1)
00360       return self
00361     except struct.error as e:
00362       raise genpy.DeserializationError(e) #most likely buffer underfill
00363 
00364 _struct_I = genpy.struct_I
00365 _struct_i = struct.Struct("<i")
00366 _struct_Id = struct.Struct("<Id")
00367 _struct_BI = struct.Struct("<BI")


wire_msgs
Author(s): Sjoerd van den Dries
autogenerated on Tue Jan 7 2014 11:42:56