_Plot.py
Go to the documentation of this file.
00001 """autogenerated by genpy from pr2_self_test_msgs/Plot.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 
00008 class Plot(genpy.Message):
00009   _md5sum = "7b2b3d1ff7d1699544a2479e9175f3fb"
00010   _type = "pr2_self_test_msgs/Plot"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# Plot data, used for PR2 self tests
00013 string title
00014 byte[] image
00015 string image_format
00016 
00017 """
00018   __slots__ = ['title','image','image_format']
00019   _slot_types = ['string','byte[]','string']
00020 
00021   def __init__(self, *args, **kwds):
00022     """
00023     Constructor. Any message fields that are implicitly/explicitly
00024     set to None will be assigned a default value. The recommend
00025     use is keyword arguments as this is more robust to future message
00026     changes.  You cannot mix in-order arguments and keyword arguments.
00027 
00028     The available fields are:
00029        title,image,image_format
00030 
00031     :param args: complete set of field values, in .msg order
00032     :param kwds: use keyword arguments corresponding to message field names
00033     to set specific fields.
00034     """
00035     if args or kwds:
00036       super(Plot, self).__init__(*args, **kwds)
00037       #message fields cannot be None, assign default values for those that are
00038       if self.title is None:
00039         self.title = ''
00040       if self.image is None:
00041         self.image = []
00042       if self.image_format is None:
00043         self.image_format = ''
00044     else:
00045       self.title = ''
00046       self.image = []
00047       self.image_format = ''
00048 
00049   def _get_types(self):
00050     """
00051     internal API method
00052     """
00053     return self._slot_types
00054 
00055   def serialize(self, buff):
00056     """
00057     serialize message into buffer
00058     :param buff: buffer, ``StringIO``
00059     """
00060     try:
00061       _x = self.title
00062       length = len(_x)
00063       if python3 or type(_x) == unicode:
00064         _x = _x.encode('utf-8')
00065         length = len(_x)
00066       buff.write(struct.pack('<I%ss'%length, length, _x))
00067       length = len(self.image)
00068       buff.write(_struct_I.pack(length))
00069       pattern = '<%sb'%length
00070       buff.write(struct.pack(pattern, *self.image))
00071       _x = self.image_format
00072       length = len(_x)
00073       if python3 or type(_x) == unicode:
00074         _x = _x.encode('utf-8')
00075         length = len(_x)
00076       buff.write(struct.pack('<I%ss'%length, length, _x))
00077     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00078     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00079 
00080   def deserialize(self, str):
00081     """
00082     unpack serialized message in str into this message instance
00083     :param str: byte array of serialized message, ``str``
00084     """
00085     try:
00086       end = 0
00087       start = end
00088       end += 4
00089       (length,) = _struct_I.unpack(str[start:end])
00090       start = end
00091       end += length
00092       if python3:
00093         self.title = str[start:end].decode('utf-8')
00094       else:
00095         self.title = str[start:end]
00096       start = end
00097       end += 4
00098       (length,) = _struct_I.unpack(str[start:end])
00099       pattern = '<%sb'%length
00100       start = end
00101       end += struct.calcsize(pattern)
00102       self.image = struct.unpack(pattern, str[start:end])
00103       start = end
00104       end += 4
00105       (length,) = _struct_I.unpack(str[start:end])
00106       start = end
00107       end += length
00108       if python3:
00109         self.image_format = str[start:end].decode('utf-8')
00110       else:
00111         self.image_format = str[start:end]
00112       return self
00113     except struct.error as e:
00114       raise genpy.DeserializationError(e) #most likely buffer underfill
00115 
00116 
00117   def serialize_numpy(self, buff, numpy):
00118     """
00119     serialize message with numpy array types into buffer
00120     :param buff: buffer, ``StringIO``
00121     :param numpy: numpy python module
00122     """
00123     try:
00124       _x = self.title
00125       length = len(_x)
00126       if python3 or type(_x) == unicode:
00127         _x = _x.encode('utf-8')
00128         length = len(_x)
00129       buff.write(struct.pack('<I%ss'%length, length, _x))
00130       length = len(self.image)
00131       buff.write(_struct_I.pack(length))
00132       pattern = '<%sb'%length
00133       buff.write(self.image.tostring())
00134       _x = self.image_format
00135       length = len(_x)
00136       if python3 or type(_x) == unicode:
00137         _x = _x.encode('utf-8')
00138         length = len(_x)
00139       buff.write(struct.pack('<I%ss'%length, length, _x))
00140     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00141     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00142 
00143   def deserialize_numpy(self, str, numpy):
00144     """
00145     unpack serialized message in str into this message instance using numpy for array types
00146     :param str: byte array of serialized message, ``str``
00147     :param numpy: numpy python module
00148     """
00149     try:
00150       end = 0
00151       start = end
00152       end += 4
00153       (length,) = _struct_I.unpack(str[start:end])
00154       start = end
00155       end += length
00156       if python3:
00157         self.title = str[start:end].decode('utf-8')
00158       else:
00159         self.title = str[start:end]
00160       start = end
00161       end += 4
00162       (length,) = _struct_I.unpack(str[start:end])
00163       pattern = '<%sb'%length
00164       start = end
00165       end += struct.calcsize(pattern)
00166       self.image = numpy.frombuffer(str[start:end], dtype=numpy.int8, count=length)
00167       start = end
00168       end += 4
00169       (length,) = _struct_I.unpack(str[start:end])
00170       start = end
00171       end += length
00172       if python3:
00173         self.image_format = str[start:end].decode('utf-8')
00174       else:
00175         self.image_format = str[start:end]
00176       return self
00177     except struct.error as e:
00178       raise genpy.DeserializationError(e) #most likely buffer underfill
00179 
00180 _struct_I = genpy.struct_I


pr2_self_test_msgs
Author(s): Kevin Watts
autogenerated on Tue Apr 22 2014 19:38:25