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


dmp
Author(s): Scott Niekum
autogenerated on Fri Jan 3 2014 11:19:23