_Shape.py
Go to the documentation of this file.
00001 """autogenerated by genpy from arm_navigation_msgs/Shape.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 geometry_msgs.msg
00008 
00009 class Shape(genpy.Message):
00010   _md5sum = "59935940044147de75e7523b5d37c4d7"
00011   _type = "arm_navigation_msgs/Shape"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """byte SPHERE=0
00014 byte BOX=1
00015 byte CYLINDER=2
00016 byte MESH=3
00017 
00018 byte type
00019 
00020 
00021 #### define sphere, box, cylinder ####
00022 # the origin of each shape is considered at the shape's center
00023 
00024 # for sphere
00025 # radius := dimensions[0]
00026 
00027 # for cylinder
00028 # radius := dimensions[0]
00029 # length := dimensions[1]
00030 # the length is along the Z axis
00031 
00032 # for box
00033 # size_x := dimensions[0]
00034 # size_y := dimensions[1]
00035 # size_z := dimensions[2]
00036 float64[] dimensions
00037 
00038 
00039 #### define mesh ####
00040 
00041 # list of triangles; triangle k is defined by tre vertices located
00042 # at indices triangles[3k], triangles[3k+1], triangles[3k+2]
00043 int32[] triangles
00044 geometry_msgs/Point[] vertices
00045 
00046 ================================================================================
00047 MSG: geometry_msgs/Point
00048 # This contains the position of a point in free space
00049 float64 x
00050 float64 y
00051 float64 z
00052 
00053 """
00054   # Pseudo-constants
00055   SPHERE = 0
00056   BOX = 1
00057   CYLINDER = 2
00058   MESH = 3
00059 
00060   __slots__ = ['type','dimensions','triangles','vertices']
00061   _slot_types = ['byte','float64[]','int32[]','geometry_msgs/Point[]']
00062 
00063   def __init__(self, *args, **kwds):
00064     """
00065     Constructor. Any message fields that are implicitly/explicitly
00066     set to None will be assigned a default value. The recommend
00067     use is keyword arguments as this is more robust to future message
00068     changes.  You cannot mix in-order arguments and keyword arguments.
00069 
00070     The available fields are:
00071        type,dimensions,triangles,vertices
00072 
00073     :param args: complete set of field values, in .msg order
00074     :param kwds: use keyword arguments corresponding to message field names
00075     to set specific fields.
00076     """
00077     if args or kwds:
00078       super(Shape, self).__init__(*args, **kwds)
00079       #message fields cannot be None, assign default values for those that are
00080       if self.type is None:
00081         self.type = 0
00082       if self.dimensions is None:
00083         self.dimensions = []
00084       if self.triangles is None:
00085         self.triangles = []
00086       if self.vertices is None:
00087         self.vertices = []
00088     else:
00089       self.type = 0
00090       self.dimensions = []
00091       self.triangles = []
00092       self.vertices = []
00093 
00094   def _get_types(self):
00095     """
00096     internal API method
00097     """
00098     return self._slot_types
00099 
00100   def serialize(self, buff):
00101     """
00102     serialize message into buffer
00103     :param buff: buffer, ``StringIO``
00104     """
00105     try:
00106       buff.write(_struct_b.pack(self.type))
00107       length = len(self.dimensions)
00108       buff.write(_struct_I.pack(length))
00109       pattern = '<%sd'%length
00110       buff.write(struct.pack(pattern, *self.dimensions))
00111       length = len(self.triangles)
00112       buff.write(_struct_I.pack(length))
00113       pattern = '<%si'%length
00114       buff.write(struct.pack(pattern, *self.triangles))
00115       length = len(self.vertices)
00116       buff.write(_struct_I.pack(length))
00117       for val1 in self.vertices:
00118         _x = val1
00119         buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00120     except struct.error as se: self._check_types(se)
00121     except TypeError as te: self._check_types(te)
00122 
00123   def deserialize(self, str):
00124     """
00125     unpack serialized message in str into this message instance
00126     :param str: byte array of serialized message, ``str``
00127     """
00128     try:
00129       if self.vertices is None:
00130         self.vertices = None
00131       end = 0
00132       start = end
00133       end += 1
00134       (self.type,) = _struct_b.unpack(str[start:end])
00135       start = end
00136       end += 4
00137       (length,) = _struct_I.unpack(str[start:end])
00138       pattern = '<%sd'%length
00139       start = end
00140       end += struct.calcsize(pattern)
00141       self.dimensions = struct.unpack(pattern, str[start:end])
00142       start = end
00143       end += 4
00144       (length,) = _struct_I.unpack(str[start:end])
00145       pattern = '<%si'%length
00146       start = end
00147       end += struct.calcsize(pattern)
00148       self.triangles = struct.unpack(pattern, str[start:end])
00149       start = end
00150       end += 4
00151       (length,) = _struct_I.unpack(str[start:end])
00152       self.vertices = []
00153       for i in range(0, length):
00154         val1 = geometry_msgs.msg.Point()
00155         _x = val1
00156         start = end
00157         end += 24
00158         (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00159         self.vertices.append(val1)
00160       return self
00161     except struct.error as e:
00162       raise genpy.DeserializationError(e) #most likely buffer underfill
00163 
00164 
00165   def serialize_numpy(self, buff, numpy):
00166     """
00167     serialize message with numpy array types into buffer
00168     :param buff: buffer, ``StringIO``
00169     :param numpy: numpy python module
00170     """
00171     try:
00172       buff.write(_struct_b.pack(self.type))
00173       length = len(self.dimensions)
00174       buff.write(_struct_I.pack(length))
00175       pattern = '<%sd'%length
00176       buff.write(self.dimensions.tostring())
00177       length = len(self.triangles)
00178       buff.write(_struct_I.pack(length))
00179       pattern = '<%si'%length
00180       buff.write(self.triangles.tostring())
00181       length = len(self.vertices)
00182       buff.write(_struct_I.pack(length))
00183       for val1 in self.vertices:
00184         _x = val1
00185         buff.write(_struct_3d.pack(_x.x, _x.y, _x.z))
00186     except struct.error as se: self._check_types(se)
00187     except TypeError as te: self._check_types(te)
00188 
00189   def deserialize_numpy(self, str, numpy):
00190     """
00191     unpack serialized message in str into this message instance using numpy for array types
00192     :param str: byte array of serialized message, ``str``
00193     :param numpy: numpy python module
00194     """
00195     try:
00196       if self.vertices is None:
00197         self.vertices = None
00198       end = 0
00199       start = end
00200       end += 1
00201       (self.type,) = _struct_b.unpack(str[start:end])
00202       start = end
00203       end += 4
00204       (length,) = _struct_I.unpack(str[start:end])
00205       pattern = '<%sd'%length
00206       start = end
00207       end += struct.calcsize(pattern)
00208       self.dimensions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00209       start = end
00210       end += 4
00211       (length,) = _struct_I.unpack(str[start:end])
00212       pattern = '<%si'%length
00213       start = end
00214       end += struct.calcsize(pattern)
00215       self.triangles = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00216       start = end
00217       end += 4
00218       (length,) = _struct_I.unpack(str[start:end])
00219       self.vertices = []
00220       for i in range(0, length):
00221         val1 = geometry_msgs.msg.Point()
00222         _x = val1
00223         start = end
00224         end += 24
00225         (_x.x, _x.y, _x.z,) = _struct_3d.unpack(str[start:end])
00226         self.vertices.append(val1)
00227       return self
00228     except struct.error as e:
00229       raise genpy.DeserializationError(e) #most likely buffer underfill
00230 
00231 _struct_I = genpy.struct_I
00232 _struct_b = struct.Struct("<b")
00233 _struct_3d = struct.Struct("<3d")


arm_navigation_msgs
Author(s): Gil Jones
autogenerated on Mon Dec 2 2013 12:31:50