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 = "dd2a2dd30705ac6b894c0c83b8081221"
00010 _type = "dmp/DMPData"
00011 _has_header = False
00012 _full_text = """float64 k_gain
00013 float64 d_gain
00014 float64[] weights
00015 float64[] f_domain
00016 float64[] f_targets
00017
00018
00019 """
00020 __slots__ = ['k_gain','d_gain','weights','f_domain','f_targets']
00021 _slot_types = ['float64','float64','float64[]','float64[]','float64[]']
00022
00023 def __init__(self, *args, **kwds):
00024 """
00025 Constructor. Any message fields that are implicitly/explicitly
00026 set to None will be assigned a default value. The recommend
00027 use is keyword arguments as this is more robust to future message
00028 changes. You cannot mix in-order arguments and keyword arguments.
00029
00030 The available fields are:
00031 k_gain,d_gain,weights,f_domain,f_targets
00032
00033 :param args: complete set of field values, in .msg order
00034 :param kwds: use keyword arguments corresponding to message field names
00035 to set specific fields.
00036 """
00037 if args or kwds:
00038 super(DMPData, self).__init__(*args, **kwds)
00039
00040 if self.k_gain is None:
00041 self.k_gain = 0.
00042 if self.d_gain is None:
00043 self.d_gain = 0.
00044 if self.weights is None:
00045 self.weights = []
00046 if self.f_domain is None:
00047 self.f_domain = []
00048 if self.f_targets is None:
00049 self.f_targets = []
00050 else:
00051 self.k_gain = 0.
00052 self.d_gain = 0.
00053 self.weights = []
00054 self.f_domain = []
00055 self.f_targets = []
00056
00057 def _get_types(self):
00058 """
00059 internal API method
00060 """
00061 return self._slot_types
00062
00063 def serialize(self, buff):
00064 """
00065 serialize message into buffer
00066 :param buff: buffer, ``StringIO``
00067 """
00068 try:
00069 _x = self
00070 buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00071 length = len(self.weights)
00072 buff.write(_struct_I.pack(length))
00073 pattern = '<%sd'%length
00074 buff.write(struct.pack(pattern, *self.weights))
00075 length = len(self.f_domain)
00076 buff.write(_struct_I.pack(length))
00077 pattern = '<%sd'%length
00078 buff.write(struct.pack(pattern, *self.f_domain))
00079 length = len(self.f_targets)
00080 buff.write(_struct_I.pack(length))
00081 pattern = '<%sd'%length
00082 buff.write(struct.pack(pattern, *self.f_targets))
00083 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00084 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00085
00086 def deserialize(self, str):
00087 """
00088 unpack serialized message in str into this message instance
00089 :param str: byte array of serialized message, ``str``
00090 """
00091 try:
00092 end = 0
00093 _x = self
00094 start = end
00095 end += 16
00096 (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00097 start = end
00098 end += 4
00099 (length,) = _struct_I.unpack(str[start:end])
00100 pattern = '<%sd'%length
00101 start = end
00102 end += struct.calcsize(pattern)
00103 self.weights = struct.unpack(pattern, str[start:end])
00104 start = end
00105 end += 4
00106 (length,) = _struct_I.unpack(str[start:end])
00107 pattern = '<%sd'%length
00108 start = end
00109 end += struct.calcsize(pattern)
00110 self.f_domain = struct.unpack(pattern, str[start:end])
00111 start = end
00112 end += 4
00113 (length,) = _struct_I.unpack(str[start:end])
00114 pattern = '<%sd'%length
00115 start = end
00116 end += struct.calcsize(pattern)
00117 self.f_targets = struct.unpack(pattern, str[start:end])
00118 return self
00119 except struct.error as e:
00120 raise genpy.DeserializationError(e)
00121
00122
00123 def serialize_numpy(self, buff, numpy):
00124 """
00125 serialize message with numpy array types into buffer
00126 :param buff: buffer, ``StringIO``
00127 :param numpy: numpy python module
00128 """
00129 try:
00130 _x = self
00131 buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00132 length = len(self.weights)
00133 buff.write(_struct_I.pack(length))
00134 pattern = '<%sd'%length
00135 buff.write(self.weights.tostring())
00136 length = len(self.f_domain)
00137 buff.write(_struct_I.pack(length))
00138 pattern = '<%sd'%length
00139 buff.write(self.f_domain.tostring())
00140 length = len(self.f_targets)
00141 buff.write(_struct_I.pack(length))
00142 pattern = '<%sd'%length
00143 buff.write(self.f_targets.tostring())
00144 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00145 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00146
00147 def deserialize_numpy(self, str, numpy):
00148 """
00149 unpack serialized message in str into this message instance using numpy for array types
00150 :param str: byte array of serialized message, ``str``
00151 :param numpy: numpy python module
00152 """
00153 try:
00154 end = 0
00155 _x = self
00156 start = end
00157 end += 16
00158 (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00159 start = end
00160 end += 4
00161 (length,) = _struct_I.unpack(str[start:end])
00162 pattern = '<%sd'%length
00163 start = end
00164 end += struct.calcsize(pattern)
00165 self.weights = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00166 start = end
00167 end += 4
00168 (length,) = _struct_I.unpack(str[start:end])
00169 pattern = '<%sd'%length
00170 start = end
00171 end += struct.calcsize(pattern)
00172 self.f_domain = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00173 start = end
00174 end += 4
00175 (length,) = _struct_I.unpack(str[start:end])
00176 pattern = '<%sd'%length
00177 start = end
00178 end += struct.calcsize(pattern)
00179 self.f_targets = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00180 return self
00181 except struct.error as e:
00182 raise genpy.DeserializationError(e)
00183
00184 _struct_I = genpy.struct_I
00185 _struct_2d = struct.Struct("<2d")