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


brics_actuator
Author(s): Alexander Bubeck
autogenerated on Sun Oct 5 2014 22:58:19