_SensorState.py
Go to the documentation of this file.
00001 """autogenerated by genpy from ros_arduino_msgs/SensorState.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 SensorState(genpy.Message):
00010   _md5sum = "c775d5ae64f1f355fcb3c88b89468dd0"
00011   _type = "ros_arduino_msgs/SensorState"
00012   _has_header = True #flag to mark the presence of a Header object
00013   _full_text = """Header header
00014 
00015 string[] name
00016 float32[] value
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','name','value']
00038   _slot_types = ['std_msgs/Header','string[]','float32[]']
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,name,value
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(SensorState, 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.name is None:
00060         self.name = []
00061       if self.value is None:
00062         self.value = []
00063     else:
00064       self.header = std_msgs.msg.Header()
00065       self.name = []
00066       self.value = []
00067 
00068   def _get_types(self):
00069     """
00070     internal API method
00071     """
00072     return self._slot_types
00073 
00074   def serialize(self, buff):
00075     """
00076     serialize message into buffer
00077     :param buff: buffer, ``StringIO``
00078     """
00079     try:
00080       _x = self
00081       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00082       _x = self.header.frame_id
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       length = len(self.name)
00089       buff.write(_struct_I.pack(length))
00090       for val1 in self.name:
00091         length = len(val1)
00092         if python3 or type(val1) == unicode:
00093           val1 = val1.encode('utf-8')
00094           length = len(val1)
00095         buff.write(struct.pack('<I%ss'%length, length, val1))
00096       length = len(self.value)
00097       buff.write(_struct_I.pack(length))
00098       pattern = '<%sf'%length
00099       buff.write(struct.pack(pattern, *self.value))
00100     except struct.error as se: self._check_types(se)
00101     except TypeError as te: self._check_types(te)
00102 
00103   def deserialize(self, str):
00104     """
00105     unpack serialized message in str into this message instance
00106     :param str: byte array of serialized message, ``str``
00107     """
00108     try:
00109       if self.header is None:
00110         self.header = std_msgs.msg.Header()
00111       end = 0
00112       _x = self
00113       start = end
00114       end += 12
00115       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00116       start = end
00117       end += 4
00118       (length,) = _struct_I.unpack(str[start:end])
00119       start = end
00120       end += length
00121       if python3:
00122         self.header.frame_id = str[start:end].decode('utf-8')
00123       else:
00124         self.header.frame_id = str[start:end]
00125       start = end
00126       end += 4
00127       (length,) = _struct_I.unpack(str[start:end])
00128       self.name = []
00129       for i in range(0, length):
00130         start = end
00131         end += 4
00132         (length,) = _struct_I.unpack(str[start:end])
00133         start = end
00134         end += length
00135         if python3:
00136           val1 = str[start:end].decode('utf-8')
00137         else:
00138           val1 = str[start:end]
00139         self.name.append(val1)
00140       start = end
00141       end += 4
00142       (length,) = _struct_I.unpack(str[start:end])
00143       pattern = '<%sf'%length
00144       start = end
00145       end += struct.calcsize(pattern)
00146       self.value = struct.unpack(pattern, str[start:end])
00147       return self
00148     except struct.error as e:
00149       raise genpy.DeserializationError(e) #most likely buffer underfill
00150 
00151 
00152   def serialize_numpy(self, buff, numpy):
00153     """
00154     serialize message with numpy array types into buffer
00155     :param buff: buffer, ``StringIO``
00156     :param numpy: numpy python module
00157     """
00158     try:
00159       _x = self
00160       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00161       _x = self.header.frame_id
00162       length = len(_x)
00163       if python3 or type(_x) == unicode:
00164         _x = _x.encode('utf-8')
00165         length = len(_x)
00166       buff.write(struct.pack('<I%ss'%length, length, _x))
00167       length = len(self.name)
00168       buff.write(_struct_I.pack(length))
00169       for val1 in self.name:
00170         length = len(val1)
00171         if python3 or type(val1) == unicode:
00172           val1 = val1.encode('utf-8')
00173           length = len(val1)
00174         buff.write(struct.pack('<I%ss'%length, length, val1))
00175       length = len(self.value)
00176       buff.write(_struct_I.pack(length))
00177       pattern = '<%sf'%length
00178       buff.write(self.value.tostring())
00179     except struct.error as se: self._check_types(se)
00180     except TypeError as te: self._check_types(te)
00181 
00182   def deserialize_numpy(self, str, numpy):
00183     """
00184     unpack serialized message in str into this message instance using numpy for array types
00185     :param str: byte array of serialized message, ``str``
00186     :param numpy: numpy python module
00187     """
00188     try:
00189       if self.header is None:
00190         self.header = std_msgs.msg.Header()
00191       end = 0
00192       _x = self
00193       start = end
00194       end += 12
00195       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00196       start = end
00197       end += 4
00198       (length,) = _struct_I.unpack(str[start:end])
00199       start = end
00200       end += length
00201       if python3:
00202         self.header.frame_id = str[start:end].decode('utf-8')
00203       else:
00204         self.header.frame_id = str[start:end]
00205       start = end
00206       end += 4
00207       (length,) = _struct_I.unpack(str[start:end])
00208       self.name = []
00209       for i in range(0, length):
00210         start = end
00211         end += 4
00212         (length,) = _struct_I.unpack(str[start:end])
00213         start = end
00214         end += length
00215         if python3:
00216           val1 = str[start:end].decode('utf-8')
00217         else:
00218           val1 = str[start:end]
00219         self.name.append(val1)
00220       start = end
00221       end += 4
00222       (length,) = _struct_I.unpack(str[start:end])
00223       pattern = '<%sf'%length
00224       start = end
00225       end += struct.calcsize(pattern)
00226       self.value = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00227       return self
00228     except struct.error as e:
00229       raise genpy.DeserializationError(e) #most likely buffer underfill
00230 
00231 _struct_I = genpy.struct_I
00232 _struct_3I = struct.Struct("<3I")


ros_arduino_msgs
Author(s): Patrick Goebel
autogenerated on Thu Nov 21 2013 12:10:01