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