00001 """autogenerated by genpy from iri_leaf_segmentation/ClusterSet.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 std_msgs.msg
00008
00009 class ClusterSet(genpy.Message):
00010 _md5sum = "473c59501c5a8d02d0d0a1bc6ce725b3"
00011 _type = "iri_leaf_segmentation/ClusterSet"
00012 _has_header = False
00013 _full_text = """std_msgs/UInt32 num_clusters
00014 std_msgs/UInt32MultiArray cluster_labels
00015
00016 ================================================================================
00017 MSG: std_msgs/UInt32
00018 uint32 data
00019 ================================================================================
00020 MSG: std_msgs/UInt32MultiArray
00021 # Please look at the MultiArrayLayout message definition for
00022 # documentation on all multiarrays.
00023
00024 MultiArrayLayout layout # specification of data layout
00025 uint32[] data # array of data
00026
00027
00028 ================================================================================
00029 MSG: std_msgs/MultiArrayLayout
00030 # The multiarray declares a generic multi-dimensional array of a
00031 # particular data type. Dimensions are ordered from outer most
00032 # to inner most.
00033
00034 MultiArrayDimension[] dim # Array of dimension properties
00035 uint32 data_offset # padding bytes at front of data
00036
00037 # Accessors should ALWAYS be written in terms of dimension stride
00038 # and specified outer-most dimension first.
00039 #
00040 # multiarray(i,j,k) = data[data_offset + dim_stride[1]*i + dim_stride[2]*j + k]
00041 #
00042 # A standard, 3-channel 640x480 image with interleaved color channels
00043 # would be specified as:
00044 #
00045 # dim[0].label = "height"
00046 # dim[0].size = 480
00047 # dim[0].stride = 3*640*480 = 921600 (note dim[0] stride is just size of image)
00048 # dim[1].label = "width"
00049 # dim[1].size = 640
00050 # dim[1].stride = 3*640 = 1920
00051 # dim[2].label = "channel"
00052 # dim[2].size = 3
00053 # dim[2].stride = 3
00054 #
00055 # multiarray(i,j,k) refers to the ith row, jth column, and kth channel.
00056 ================================================================================
00057 MSG: std_msgs/MultiArrayDimension
00058 string label # label of given dimension
00059 uint32 size # size of given dimension (in type units)
00060 uint32 stride # stride of given dimension
00061 """
00062 __slots__ = ['num_clusters','cluster_labels']
00063 _slot_types = ['std_msgs/UInt32','std_msgs/UInt32MultiArray']
00064
00065 def __init__(self, *args, **kwds):
00066 """
00067 Constructor. Any message fields that are implicitly/explicitly
00068 set to None will be assigned a default value. The recommend
00069 use is keyword arguments as this is more robust to future message
00070 changes. You cannot mix in-order arguments and keyword arguments.
00071
00072 The available fields are:
00073 num_clusters,cluster_labels
00074
00075 :param args: complete set of field values, in .msg order
00076 :param kwds: use keyword arguments corresponding to message field names
00077 to set specific fields.
00078 """
00079 if args or kwds:
00080 super(ClusterSet, self).__init__(*args, **kwds)
00081
00082 if self.num_clusters is None:
00083 self.num_clusters = std_msgs.msg.UInt32()
00084 if self.cluster_labels is None:
00085 self.cluster_labels = std_msgs.msg.UInt32MultiArray()
00086 else:
00087 self.num_clusters = std_msgs.msg.UInt32()
00088 self.cluster_labels = std_msgs.msg.UInt32MultiArray()
00089
00090 def _get_types(self):
00091 """
00092 internal API method
00093 """
00094 return self._slot_types
00095
00096 def serialize(self, buff):
00097 """
00098 serialize message into buffer
00099 :param buff: buffer, ``StringIO``
00100 """
00101 try:
00102 buff.write(_struct_I.pack(self.num_clusters.data))
00103 length = len(self.cluster_labels.layout.dim)
00104 buff.write(_struct_I.pack(length))
00105 for val1 in self.cluster_labels.layout.dim:
00106 _x = val1.label
00107 length = len(_x)
00108 if python3 or type(_x) == unicode:
00109 _x = _x.encode('utf-8')
00110 length = len(_x)
00111 buff.write(struct.pack('<I%ss'%length, length, _x))
00112 _x = val1
00113 buff.write(_struct_2I.pack(_x.size, _x.stride))
00114 buff.write(_struct_I.pack(self.cluster_labels.layout.data_offset))
00115 length = len(self.cluster_labels.data)
00116 buff.write(_struct_I.pack(length))
00117 pattern = '<%sI'%length
00118 buff.write(struct.pack(pattern, *self.cluster_labels.data))
00119 except struct.error as se: self._check_types(se)
00120 except TypeError as te: self._check_types(te)
00121
00122 def deserialize(self, str):
00123 """
00124 unpack serialized message in str into this message instance
00125 :param str: byte array of serialized message, ``str``
00126 """
00127 try:
00128 if self.num_clusters is None:
00129 self.num_clusters = std_msgs.msg.UInt32()
00130 if self.cluster_labels is None:
00131 self.cluster_labels = std_msgs.msg.UInt32MultiArray()
00132 end = 0
00133 start = end
00134 end += 4
00135 (self.num_clusters.data,) = _struct_I.unpack(str[start:end])
00136 start = end
00137 end += 4
00138 (length,) = _struct_I.unpack(str[start:end])
00139 self.cluster_labels.layout.dim = []
00140 for i in range(0, length):
00141 val1 = std_msgs.msg.MultiArrayDimension()
00142 start = end
00143 end += 4
00144 (length,) = _struct_I.unpack(str[start:end])
00145 start = end
00146 end += length
00147 if python3:
00148 val1.label = str[start:end].decode('utf-8')
00149 else:
00150 val1.label = str[start:end]
00151 _x = val1
00152 start = end
00153 end += 8
00154 (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
00155 self.cluster_labels.layout.dim.append(val1)
00156 start = end
00157 end += 4
00158 (self.cluster_labels.layout.data_offset,) = _struct_I.unpack(str[start:end])
00159 start = end
00160 end += 4
00161 (length,) = _struct_I.unpack(str[start:end])
00162 pattern = '<%sI'%length
00163 start = end
00164 end += struct.calcsize(pattern)
00165 self.cluster_labels.data = struct.unpack(pattern, str[start:end])
00166 return self
00167 except struct.error as e:
00168 raise genpy.DeserializationError(e)
00169
00170
00171 def serialize_numpy(self, buff, numpy):
00172 """
00173 serialize message with numpy array types into buffer
00174 :param buff: buffer, ``StringIO``
00175 :param numpy: numpy python module
00176 """
00177 try:
00178 buff.write(_struct_I.pack(self.num_clusters.data))
00179 length = len(self.cluster_labels.layout.dim)
00180 buff.write(_struct_I.pack(length))
00181 for val1 in self.cluster_labels.layout.dim:
00182 _x = val1.label
00183 length = len(_x)
00184 if python3 or type(_x) == unicode:
00185 _x = _x.encode('utf-8')
00186 length = len(_x)
00187 buff.write(struct.pack('<I%ss'%length, length, _x))
00188 _x = val1
00189 buff.write(_struct_2I.pack(_x.size, _x.stride))
00190 buff.write(_struct_I.pack(self.cluster_labels.layout.data_offset))
00191 length = len(self.cluster_labels.data)
00192 buff.write(_struct_I.pack(length))
00193 pattern = '<%sI'%length
00194 buff.write(self.cluster_labels.data.tostring())
00195 except struct.error as se: self._check_types(se)
00196 except TypeError as te: self._check_types(te)
00197
00198 def deserialize_numpy(self, str, numpy):
00199 """
00200 unpack serialized message in str into this message instance using numpy for array types
00201 :param str: byte array of serialized message, ``str``
00202 :param numpy: numpy python module
00203 """
00204 try:
00205 if self.num_clusters is None:
00206 self.num_clusters = std_msgs.msg.UInt32()
00207 if self.cluster_labels is None:
00208 self.cluster_labels = std_msgs.msg.UInt32MultiArray()
00209 end = 0
00210 start = end
00211 end += 4
00212 (self.num_clusters.data,) = _struct_I.unpack(str[start:end])
00213 start = end
00214 end += 4
00215 (length,) = _struct_I.unpack(str[start:end])
00216 self.cluster_labels.layout.dim = []
00217 for i in range(0, length):
00218 val1 = std_msgs.msg.MultiArrayDimension()
00219 start = end
00220 end += 4
00221 (length,) = _struct_I.unpack(str[start:end])
00222 start = end
00223 end += length
00224 if python3:
00225 val1.label = str[start:end].decode('utf-8')
00226 else:
00227 val1.label = str[start:end]
00228 _x = val1
00229 start = end
00230 end += 8
00231 (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
00232 self.cluster_labels.layout.dim.append(val1)
00233 start = end
00234 end += 4
00235 (self.cluster_labels.layout.data_offset,) = _struct_I.unpack(str[start:end])
00236 start = end
00237 end += 4
00238 (length,) = _struct_I.unpack(str[start:end])
00239 pattern = '<%sI'%length
00240 start = end
00241 end += struct.calcsize(pattern)
00242 self.cluster_labels.data = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00243 return self
00244 except struct.error as e:
00245 raise genpy.DeserializationError(e)
00246
00247 _struct_I = genpy.struct_I
00248 _struct_2I = struct.Struct("<2I")