$search
00001 """autogenerated by genmsg_py from TactileSensor.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 import schunk_sdh.msg 00006 import std_msgs.msg 00007 00008 class TactileSensor(roslib.message.Message): 00009 _md5sum = "c6176a03c00cccf1b8efd3037de0d45d" 00010 _type = "schunk_sdh/TactileSensor" 00011 _has_header = True #flag to mark the presence of a Header object 00012 _full_text = """#tactile sensor data in 2D grid 00013 Header header 00014 schunk_sdh/TactileMatrix[] tactile_matrix 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 MSG: schunk_sdh/TactileMatrix 00036 uint32 matrix_id 00037 int16 cells_x 00038 int16 cells_y 00039 int16[] tactile_array 00040 00041 """ 00042 __slots__ = ['header','tactile_matrix'] 00043 _slot_types = ['Header','schunk_sdh/TactileMatrix[]'] 00044 00045 def __init__(self, *args, **kwds): 00046 """ 00047 Constructor. Any message fields that are implicitly/explicitly 00048 set to None will be assigned a default value. The recommend 00049 use is keyword arguments as this is more robust to future message 00050 changes. You cannot mix in-order arguments and keyword arguments. 00051 00052 The available fields are: 00053 header,tactile_matrix 00054 00055 @param args: complete set of field values, in .msg order 00056 @param kwds: use keyword arguments corresponding to message field names 00057 to set specific fields. 00058 """ 00059 if args or kwds: 00060 super(TactileSensor, self).__init__(*args, **kwds) 00061 #message fields cannot be None, assign default values for those that are 00062 if self.header is None: 00063 self.header = std_msgs.msg._Header.Header() 00064 if self.tactile_matrix is None: 00065 self.tactile_matrix = [] 00066 else: 00067 self.header = std_msgs.msg._Header.Header() 00068 self.tactile_matrix = [] 00069 00070 def _get_types(self): 00071 """ 00072 internal API method 00073 """ 00074 return self._slot_types 00075 00076 def serialize(self, buff): 00077 """ 00078 serialize message into buffer 00079 @param buff: buffer 00080 @type buff: 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 buff.write(struct.pack('<I%ss'%length, length, _x)) 00088 length = len(self.tactile_matrix) 00089 buff.write(_struct_I.pack(length)) 00090 for val1 in self.tactile_matrix: 00091 _x = val1 00092 buff.write(_struct_I2h.pack(_x.matrix_id, _x.cells_x, _x.cells_y)) 00093 length = len(val1.tactile_array) 00094 buff.write(_struct_I.pack(length)) 00095 pattern = '<%sh'%length 00096 buff.write(struct.pack(pattern, *val1.tactile_array)) 00097 except struct.error as se: self._check_types(se) 00098 except TypeError as te: self._check_types(te) 00099 00100 def deserialize(self, str): 00101 """ 00102 unpack serialized message in str into this message instance 00103 @param str: byte array of serialized message 00104 @type str: str 00105 """ 00106 try: 00107 if self.header is None: 00108 self.header = std_msgs.msg._Header.Header() 00109 end = 0 00110 _x = self 00111 start = end 00112 end += 12 00113 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00114 start = end 00115 end += 4 00116 (length,) = _struct_I.unpack(str[start:end]) 00117 start = end 00118 end += length 00119 self.header.frame_id = str[start:end] 00120 start = end 00121 end += 4 00122 (length,) = _struct_I.unpack(str[start:end]) 00123 self.tactile_matrix = [] 00124 for i in range(0, length): 00125 val1 = schunk_sdh.msg.TactileMatrix() 00126 _x = val1 00127 start = end 00128 end += 8 00129 (_x.matrix_id, _x.cells_x, _x.cells_y,) = _struct_I2h.unpack(str[start:end]) 00130 start = end 00131 end += 4 00132 (length,) = _struct_I.unpack(str[start:end]) 00133 pattern = '<%sh'%length 00134 start = end 00135 end += struct.calcsize(pattern) 00136 val1.tactile_array = struct.unpack(pattern, str[start:end]) 00137 self.tactile_matrix.append(val1) 00138 return self 00139 except struct.error as e: 00140 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00141 00142 00143 def serialize_numpy(self, buff, numpy): 00144 """ 00145 serialize message with numpy array types into buffer 00146 @param buff: buffer 00147 @type buff: StringIO 00148 @param numpy: numpy python module 00149 @type numpy module 00150 """ 00151 try: 00152 _x = self 00153 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 00154 _x = self.header.frame_id 00155 length = len(_x) 00156 buff.write(struct.pack('<I%ss'%length, length, _x)) 00157 length = len(self.tactile_matrix) 00158 buff.write(_struct_I.pack(length)) 00159 for val1 in self.tactile_matrix: 00160 _x = val1 00161 buff.write(_struct_I2h.pack(_x.matrix_id, _x.cells_x, _x.cells_y)) 00162 length = len(val1.tactile_array) 00163 buff.write(_struct_I.pack(length)) 00164 pattern = '<%sh'%length 00165 buff.write(val1.tactile_array.tostring()) 00166 except struct.error as se: self._check_types(se) 00167 except TypeError as te: self._check_types(te) 00168 00169 def deserialize_numpy(self, str, numpy): 00170 """ 00171 unpack serialized message in str into this message instance using numpy for array types 00172 @param str: byte array of serialized message 00173 @type str: str 00174 @param numpy: numpy python module 00175 @type numpy: module 00176 """ 00177 try: 00178 if self.header is None: 00179 self.header = std_msgs.msg._Header.Header() 00180 end = 0 00181 _x = self 00182 start = end 00183 end += 12 00184 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end]) 00185 start = end 00186 end += 4 00187 (length,) = _struct_I.unpack(str[start:end]) 00188 start = end 00189 end += length 00190 self.header.frame_id = str[start:end] 00191 start = end 00192 end += 4 00193 (length,) = _struct_I.unpack(str[start:end]) 00194 self.tactile_matrix = [] 00195 for i in range(0, length): 00196 val1 = schunk_sdh.msg.TactileMatrix() 00197 _x = val1 00198 start = end 00199 end += 8 00200 (_x.matrix_id, _x.cells_x, _x.cells_y,) = _struct_I2h.unpack(str[start:end]) 00201 start = end 00202 end += 4 00203 (length,) = _struct_I.unpack(str[start:end]) 00204 pattern = '<%sh'%length 00205 start = end 00206 end += struct.calcsize(pattern) 00207 val1.tactile_array = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=length) 00208 self.tactile_matrix.append(val1) 00209 return self 00210 except struct.error as e: 00211 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00212 00213 _struct_I = roslib.message.struct_I 00214 _struct_I2h = struct.Struct("<I2h") 00215 _struct_3I = struct.Struct("<3I")