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