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