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


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