_WordRecognized.py
Go to the documentation of this file.
00001 """autogenerated by genpy from nao_msgs/WordRecognized.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 WordRecognized(genpy.Message):
00009   _md5sum = "29134437cd61021f75f35f21b72b7eab"
00010   _type = "nao_msgs/WordRecognized"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# Message emitted by Nao speech recognition.
00013 # It contains the list of words recognized and confidence values
00014 # Both arrays are of the same length
00015 string[] words
00016 float32[] confidence_values
00017 
00018 """
00019   __slots__ = ['words','confidence_values']
00020   _slot_types = ['string[]','float32[]']
00021 
00022   def __init__(self, *args, **kwds):
00023     """
00024     Constructor. Any message fields that are implicitly/explicitly
00025     set to None will be assigned a default value. The recommend
00026     use is keyword arguments as this is more robust to future message
00027     changes.  You cannot mix in-order arguments and keyword arguments.
00028 
00029     The available fields are:
00030        words,confidence_values
00031 
00032     :param args: complete set of field values, in .msg order
00033     :param kwds: use keyword arguments corresponding to message field names
00034     to set specific fields.
00035     """
00036     if args or kwds:
00037       super(WordRecognized, self).__init__(*args, **kwds)
00038       #message fields cannot be None, assign default values for those that are
00039       if self.words is None:
00040         self.words = []
00041       if self.confidence_values is None:
00042         self.confidence_values = []
00043     else:
00044       self.words = []
00045       self.confidence_values = []
00046 
00047   def _get_types(self):
00048     """
00049     internal API method
00050     """
00051     return self._slot_types
00052 
00053   def serialize(self, buff):
00054     """
00055     serialize message into buffer
00056     :param buff: buffer, ``StringIO``
00057     """
00058     try:
00059       length = len(self.words)
00060       buff.write(_struct_I.pack(length))
00061       for val1 in self.words:
00062         length = len(val1)
00063         if python3 or type(val1) == unicode:
00064           val1 = val1.encode('utf-8')
00065           length = len(val1)
00066         buff.write(struct.pack('<I%ss'%length, length, val1))
00067       length = len(self.confidence_values)
00068       buff.write(_struct_I.pack(length))
00069       pattern = '<%sf'%length
00070       buff.write(struct.pack(pattern, *self.confidence_values))
00071     except struct.error as se: self._check_types(se)
00072     except TypeError as te: self._check_types(te)
00073 
00074   def deserialize(self, str):
00075     """
00076     unpack serialized message in str into this message instance
00077     :param str: byte array of serialized message, ``str``
00078     """
00079     try:
00080       end = 0
00081       start = end
00082       end += 4
00083       (length,) = _struct_I.unpack(str[start:end])
00084       self.words = []
00085       for i in range(0, length):
00086         start = end
00087         end += 4
00088         (length,) = _struct_I.unpack(str[start:end])
00089         start = end
00090         end += length
00091         if python3:
00092           val1 = str[start:end].decode('utf-8')
00093         else:
00094           val1 = str[start:end]
00095         self.words.append(val1)
00096       start = end
00097       end += 4
00098       (length,) = _struct_I.unpack(str[start:end])
00099       pattern = '<%sf'%length
00100       start = end
00101       end += struct.calcsize(pattern)
00102       self.confidence_values = struct.unpack(pattern, str[start:end])
00103       return self
00104     except struct.error as e:
00105       raise genpy.DeserializationError(e) #most likely buffer underfill
00106 
00107 
00108   def serialize_numpy(self, buff, numpy):
00109     """
00110     serialize message with numpy array types into buffer
00111     :param buff: buffer, ``StringIO``
00112     :param numpy: numpy python module
00113     """
00114     try:
00115       length = len(self.words)
00116       buff.write(_struct_I.pack(length))
00117       for val1 in self.words:
00118         length = len(val1)
00119         if python3 or type(val1) == unicode:
00120           val1 = val1.encode('utf-8')
00121           length = len(val1)
00122         buff.write(struct.pack('<I%ss'%length, length, val1))
00123       length = len(self.confidence_values)
00124       buff.write(_struct_I.pack(length))
00125       pattern = '<%sf'%length
00126       buff.write(self.confidence_values.tostring())
00127     except struct.error as se: self._check_types(se)
00128     except TypeError as te: self._check_types(te)
00129 
00130   def deserialize_numpy(self, str, numpy):
00131     """
00132     unpack serialized message in str into this message instance using numpy for array types
00133     :param str: byte array of serialized message, ``str``
00134     :param numpy: numpy python module
00135     """
00136     try:
00137       end = 0
00138       start = end
00139       end += 4
00140       (length,) = _struct_I.unpack(str[start:end])
00141       self.words = []
00142       for i in range(0, length):
00143         start = end
00144         end += 4
00145         (length,) = _struct_I.unpack(str[start:end])
00146         start = end
00147         end += length
00148         if python3:
00149           val1 = str[start:end].decode('utf-8')
00150         else:
00151           val1 = str[start:end]
00152         self.words.append(val1)
00153       start = end
00154       end += 4
00155       (length,) = _struct_I.unpack(str[start:end])
00156       pattern = '<%sf'%length
00157       start = end
00158       end += struct.calcsize(pattern)
00159       self.confidence_values = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00160       return self
00161     except struct.error as e:
00162       raise genpy.DeserializationError(e) #most likely buffer underfill
00163 
00164 _struct_I = genpy.struct_I
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


nao_msgs
Author(s): Armin Hornung, Stefan Osswald, Daniel Maier
autogenerated on Tue Oct 15 2013 10:05:22