00001 """autogenerated by genmsg_py from MultiArrayLayout.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import std_msgs.msg
00006
00007 class MultiArrayLayout(roslib.message.Message):
00008 _md5sum = "0fed2a11c13e11c5571b4e2a995a91a3"
00009 _type = "std_msgs/MultiArrayLayout"
00010 _has_header = False
00011 _full_text = """# The multiarray declares a generic multi-dimensional array of a
00012 # particular data type. Dimensions are ordered from outer most
00013 # to inner most.
00014
00015 MultiArrayDimension[] dim # Array of dimension properties
00016 uint32 data_offset # padding bytes at front of data
00017
00018 # Accessors should ALWAYS be written in terms of dimension stride
00019 # and specified outer-most dimension first.
00020 #
00021 # multiarray(i,j,k) = data[data_offset + dim_stride[1]*i + dim_stride[2]*j + k]
00022 #
00023 # A standard, 3-channel 640x480 image with interleaved color channels
00024 # would be specified as:
00025 #
00026 # dim[0].label = "height"
00027 # dim[0].size = 480
00028 # dim[0].stride = 3*640*480 = 921600 (note dim[0] stride is just size of image)
00029 # dim[1].label = "width"
00030 # dim[1].size = 640
00031 # dim[1].stride = 3*640 = 1920
00032 # dim[2].label = "channel"
00033 # dim[2].size = 3
00034 # dim[2].stride = 3
00035 #
00036 # multiarray(i,j,k) refers to the ith row, jth column, and kth channel.
00037 ================================================================================
00038 MSG: std_msgs/MultiArrayDimension
00039 string label # label of given dimension
00040 uint32 size # size of given dimension (in type units)
00041 uint32 stride # stride of given dimension
00042 """
00043 __slots__ = ['dim','data_offset']
00044 _slot_types = ['std_msgs/MultiArrayDimension[]','uint32']
00045
00046 def __init__(self, *args, **kwds):
00047 """
00048 Constructor. Any message fields that are implicitly/explicitly
00049 set to None will be assigned a default value. The recommend
00050 use is keyword arguments as this is more robust to future message
00051 changes. You cannot mix in-order arguments and keyword arguments.
00052
00053 The available fields are:
00054 dim,data_offset
00055
00056 @param args: complete set of field values, in .msg order
00057 @param kwds: use keyword arguments corresponding to message field names
00058 to set specific fields.
00059 """
00060 if args or kwds:
00061 super(MultiArrayLayout, self).__init__(*args, **kwds)
00062
00063 if self.dim is None:
00064 self.dim = []
00065 if self.data_offset is None:
00066 self.data_offset = 0
00067 else:
00068 self.dim = []
00069 self.data_offset = 0
00070
00071 def _get_types(self):
00072 """
00073 internal API method
00074 """
00075 return self._slot_types
00076
00077 def serialize(self, buff):
00078 """
00079 serialize message into buffer
00080 @param buff: buffer
00081 @type buff: StringIO
00082 """
00083 try:
00084 length = len(self.dim)
00085 buff.write(_struct_I.pack(length))
00086 for val1 in self.dim:
00087 _x = val1.label
00088 length = len(_x)
00089 buff.write(struct.pack('<I%ss'%length, length, _x))
00090 _x = val1
00091 buff.write(_struct_2I.pack(_x.size, _x.stride))
00092 buff.write(_struct_I.pack(self.data_offset))
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 end = 0
00104 start = end
00105 end += 4
00106 (length,) = _struct_I.unpack(str[start:end])
00107 self.dim = []
00108 for i in range(0, length):
00109 val1 = std_msgs.msg.MultiArrayDimension()
00110 start = end
00111 end += 4
00112 (length,) = _struct_I.unpack(str[start:end])
00113 start = end
00114 end += length
00115 val1.label = str[start:end]
00116 _x = val1
00117 start = end
00118 end += 8
00119 (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
00120 self.dim.append(val1)
00121 start = end
00122 end += 4
00123 (self.data_offset,) = _struct_I.unpack(str[start:end])
00124 return self
00125 except struct.error as e:
00126 raise roslib.message.DeserializationError(e)
00127
00128
00129 def serialize_numpy(self, buff, numpy):
00130 """
00131 serialize message with numpy array types into buffer
00132 @param buff: buffer
00133 @type buff: StringIO
00134 @param numpy: numpy python module
00135 @type numpy module
00136 """
00137 try:
00138 length = len(self.dim)
00139 buff.write(_struct_I.pack(length))
00140 for val1 in self.dim:
00141 _x = val1.label
00142 length = len(_x)
00143 buff.write(struct.pack('<I%ss'%length, length, _x))
00144 _x = val1
00145 buff.write(_struct_2I.pack(_x.size, _x.stride))
00146 buff.write(_struct_I.pack(self.data_offset))
00147 except struct.error as se: self._check_types(se)
00148 except TypeError as te: self._check_types(te)
00149
00150 def deserialize_numpy(self, str, numpy):
00151 """
00152 unpack serialized message in str into this message instance using numpy for array types
00153 @param str: byte array of serialized message
00154 @type str: str
00155 @param numpy: numpy python module
00156 @type numpy: module
00157 """
00158 try:
00159 end = 0
00160 start = end
00161 end += 4
00162 (length,) = _struct_I.unpack(str[start:end])
00163 self.dim = []
00164 for i in range(0, length):
00165 val1 = std_msgs.msg.MultiArrayDimension()
00166 start = end
00167 end += 4
00168 (length,) = _struct_I.unpack(str[start:end])
00169 start = end
00170 end += length
00171 val1.label = str[start:end]
00172 _x = val1
00173 start = end
00174 end += 8
00175 (_x.size, _x.stride,) = _struct_2I.unpack(str[start:end])
00176 self.dim.append(val1)
00177 start = end
00178 end += 4
00179 (self.data_offset,) = _struct_I.unpack(str[start:end])
00180 return self
00181 except struct.error as e:
00182 raise roslib.message.DeserializationError(e)
00183
00184 _struct_I = roslib.message.struct_I
00185 _struct_2I = struct.Struct("<2I")