_NumpyArray.py
Go to the documentation of this file.
00001 """autogenerated by genpy from hrl_lib/NumpyArray.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 std_msgs.msg
00008 
00009 class NumpyArray(genpy.Message):
00010   _md5sum = "18efe15e5e1ff3c15a2573bddc555f1b"
00011   _type = "hrl_lib/NumpyArray"
00012   _has_header = True #flag to mark the presence of a Header object
00013   _full_text = """Header header
00014 string data
00015 int32[] shape
00016 string dtype
00017 
00018 ================================================================================
00019 MSG: std_msgs/Header
00020 # Standard metadata for higher-level stamped data types.
00021 # This is generally used to communicate timestamped data 
00022 # in a particular coordinate frame.
00023 # 
00024 # sequence ID: consecutively increasing ID 
00025 uint32 seq
00026 #Two-integer timestamp that is expressed as:
00027 # * stamp.secs: seconds (stamp_secs) since epoch
00028 # * stamp.nsecs: nanoseconds since stamp_secs
00029 # time-handling sugar is provided by the client library
00030 time stamp
00031 #Frame this data is associated with
00032 # 0: no frame
00033 # 1: global frame
00034 string frame_id
00035 
00036 """
00037   __slots__ = ['header','data','shape','dtype']
00038   _slot_types = ['std_msgs/Header','string','int32[]','string']
00039 
00040   def __init__(self, *args, **kwds):
00041     """
00042     Constructor. Any message fields that are implicitly/explicitly
00043     set to None will be assigned a default value. The recommend
00044     use is keyword arguments as this is more robust to future message
00045     changes.  You cannot mix in-order arguments and keyword arguments.
00046 
00047     The available fields are:
00048        header,data,shape,dtype
00049 
00050     :param args: complete set of field values, in .msg order
00051     :param kwds: use keyword arguments corresponding to message field names
00052     to set specific fields.
00053     """
00054     if args or kwds:
00055       super(NumpyArray, self).__init__(*args, **kwds)
00056       #message fields cannot be None, assign default values for those that are
00057       if self.header is None:
00058         self.header = std_msgs.msg.Header()
00059       if self.data is None:
00060         self.data = ''
00061       if self.shape is None:
00062         self.shape = []
00063       if self.dtype is None:
00064         self.dtype = ''
00065     else:
00066       self.header = std_msgs.msg.Header()
00067       self.data = ''
00068       self.shape = []
00069       self.dtype = ''
00070 
00071   def _get_types(self):
00072     """
00073     internal API method
00074     """
00075     return self._slot_types
00076 
00077   def serialize(self, buff):
00078     """
00079     serialize message into buffer
00080     :param buff: buffer, ``StringIO``
00081     """
00082     try:
00083       _x = self
00084       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00085       _x = self.header.frame_id
00086       length = len(_x)
00087       if python3 or type(_x) == unicode:
00088         _x = _x.encode('utf-8')
00089         length = len(_x)
00090       buff.write(struct.pack('<I%ss'%length, length, _x))
00091       _x = self.data
00092       length = len(_x)
00093       if python3 or type(_x) == unicode:
00094         _x = _x.encode('utf-8')
00095         length = len(_x)
00096       buff.write(struct.pack('<I%ss'%length, length, _x))
00097       length = len(self.shape)
00098       buff.write(_struct_I.pack(length))
00099       pattern = '<%si'%length
00100       buff.write(struct.pack(pattern, *self.shape))
00101       _x = self.dtype
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     except struct.error as se: self._check_types(se)
00108     except TypeError as te: self._check_types(te)
00109 
00110   def deserialize(self, str):
00111     """
00112     unpack serialized message in str into this message instance
00113     :param str: byte array of serialized message, ``str``
00114     """
00115     try:
00116       if self.header is None:
00117         self.header = std_msgs.msg.Header()
00118       end = 0
00119       _x = self
00120       start = end
00121       end += 12
00122       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00123       start = end
00124       end += 4
00125       (length,) = _struct_I.unpack(str[start:end])
00126       start = end
00127       end += length
00128       if python3:
00129         self.header.frame_id = str[start:end].decode('utf-8')
00130       else:
00131         self.header.frame_id = str[start:end]
00132       start = end
00133       end += 4
00134       (length,) = _struct_I.unpack(str[start:end])
00135       start = end
00136       end += length
00137       if python3:
00138         self.data = str[start:end].decode('utf-8')
00139       else:
00140         self.data = str[start:end]
00141       start = end
00142       end += 4
00143       (length,) = _struct_I.unpack(str[start:end])
00144       pattern = '<%si'%length
00145       start = end
00146       end += struct.calcsize(pattern)
00147       self.shape = struct.unpack(pattern, str[start:end])
00148       start = end
00149       end += 4
00150       (length,) = _struct_I.unpack(str[start:end])
00151       start = end
00152       end += length
00153       if python3:
00154         self.dtype = str[start:end].decode('utf-8')
00155       else:
00156         self.dtype = str[start:end]
00157       return self
00158     except struct.error as e:
00159       raise genpy.DeserializationError(e) #most likely buffer underfill
00160 
00161 
00162   def serialize_numpy(self, buff, numpy):
00163     """
00164     serialize message with numpy array types into buffer
00165     :param buff: buffer, ``StringIO``
00166     :param numpy: numpy python module
00167     """
00168     try:
00169       _x = self
00170       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00171       _x = self.header.frame_id
00172       length = len(_x)
00173       if python3 or type(_x) == unicode:
00174         _x = _x.encode('utf-8')
00175         length = len(_x)
00176       buff.write(struct.pack('<I%ss'%length, length, _x))
00177       _x = self.data
00178       length = len(_x)
00179       if python3 or type(_x) == unicode:
00180         _x = _x.encode('utf-8')
00181         length = len(_x)
00182       buff.write(struct.pack('<I%ss'%length, length, _x))
00183       length = len(self.shape)
00184       buff.write(_struct_I.pack(length))
00185       pattern = '<%si'%length
00186       buff.write(self.shape.tostring())
00187       _x = self.dtype
00188       length = len(_x)
00189       if python3 or type(_x) == unicode:
00190         _x = _x.encode('utf-8')
00191         length = len(_x)
00192       buff.write(struct.pack('<I%ss'%length, length, _x))
00193     except struct.error as se: self._check_types(se)
00194     except TypeError as te: self._check_types(te)
00195 
00196   def deserialize_numpy(self, str, numpy):
00197     """
00198     unpack serialized message in str into this message instance using numpy for array types
00199     :param str: byte array of serialized message, ``str``
00200     :param numpy: numpy python module
00201     """
00202     try:
00203       if self.header is None:
00204         self.header = std_msgs.msg.Header()
00205       end = 0
00206       _x = self
00207       start = end
00208       end += 12
00209       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00210       start = end
00211       end += 4
00212       (length,) = _struct_I.unpack(str[start:end])
00213       start = end
00214       end += length
00215       if python3:
00216         self.header.frame_id = str[start:end].decode('utf-8')
00217       else:
00218         self.header.frame_id = str[start:end]
00219       start = end
00220       end += 4
00221       (length,) = _struct_I.unpack(str[start:end])
00222       start = end
00223       end += length
00224       if python3:
00225         self.data = str[start:end].decode('utf-8')
00226       else:
00227         self.data = str[start:end]
00228       start = end
00229       end += 4
00230       (length,) = _struct_I.unpack(str[start:end])
00231       pattern = '<%si'%length
00232       start = end
00233       end += struct.calcsize(pattern)
00234       self.shape = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00235       start = end
00236       end += 4
00237       (length,) = _struct_I.unpack(str[start:end])
00238       start = end
00239       end += length
00240       if python3:
00241         self.dtype = str[start:end].decode('utf-8')
00242       else:
00243         self.dtype = str[start:end]
00244       return self
00245     except struct.error as e:
00246       raise genpy.DeserializationError(e) #most likely buffer underfill
00247 
00248 _struct_I = genpy.struct_I
00249 _struct_3I = struct.Struct("<3I")


hrl_lib
Author(s): Cressel Anderson, Travis Deyle, Advait Jain, Hai Nguyen, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:34:06