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