_LearnDMPFromDemo.py
Go to the documentation of this file.
00001 """autogenerated by genpy from dmp/LearnDMPFromDemoRequest.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 dmp.msg
00008 
00009 class LearnDMPFromDemoRequest(genpy.Message):
00010   _md5sum = "d7c68a7f789c246aea188ade43175b30"
00011   _type = "dmp/LearnDMPFromDemoRequest"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """
00014 DMPTraj demo
00015 
00016 
00017 float64[] k_gains
00018 float64[] d_gains
00019 
00020 
00021 int32 num_bases
00022 
00023 
00024 ================================================================================
00025 MSG: dmp/DMPTraj
00026 # points and times should be the same length
00027 DMPPoint[] points
00028 
00029 # Times of observations, in seconds, starting at zero
00030 float64[] times
00031 
00032 
00033 
00034 ================================================================================
00035 MSG: dmp/DMPPoint
00036 # Positions and velocities of DOFs
00037 #Velocity is only used for movement plans, not for giving demonstrations.
00038 float64[] positions
00039 float64[] velocities
00040 
00041 
00042 
00043 """
00044   __slots__ = ['demo','k_gains','d_gains','num_bases']
00045   _slot_types = ['dmp/DMPTraj','float64[]','float64[]','int32']
00046 
00047   def __init__(self, *args, **kwds):
00048     """
00049     Constructor. Any message fields that are implicitly/explicitly
00050     set to None will be assigned a default value. The recommend
00051     use is keyword arguments as this is more robust to future message
00052     changes.  You cannot mix in-order arguments and keyword arguments.
00053 
00054     The available fields are:
00055        demo,k_gains,d_gains,num_bases
00056 
00057     :param args: complete set of field values, in .msg order
00058     :param kwds: use keyword arguments corresponding to message field names
00059     to set specific fields.
00060     """
00061     if args or kwds:
00062       super(LearnDMPFromDemoRequest, self).__init__(*args, **kwds)
00063       #message fields cannot be None, assign default values for those that are
00064       if self.demo is None:
00065         self.demo = dmp.msg.DMPTraj()
00066       if self.k_gains is None:
00067         self.k_gains = []
00068       if self.d_gains is None:
00069         self.d_gains = []
00070       if self.num_bases is None:
00071         self.num_bases = 0
00072     else:
00073       self.demo = dmp.msg.DMPTraj()
00074       self.k_gains = []
00075       self.d_gains = []
00076       self.num_bases = 0
00077 
00078   def _get_types(self):
00079     """
00080     internal API method
00081     """
00082     return self._slot_types
00083 
00084   def serialize(self, buff):
00085     """
00086     serialize message into buffer
00087     :param buff: buffer, ``StringIO``
00088     """
00089     try:
00090       length = len(self.demo.points)
00091       buff.write(_struct_I.pack(length))
00092       for val1 in self.demo.points:
00093         length = len(val1.positions)
00094         buff.write(_struct_I.pack(length))
00095         pattern = '<%sd'%length
00096         buff.write(struct.pack(pattern, *val1.positions))
00097         length = len(val1.velocities)
00098         buff.write(_struct_I.pack(length))
00099         pattern = '<%sd'%length
00100         buff.write(struct.pack(pattern, *val1.velocities))
00101       length = len(self.demo.times)
00102       buff.write(_struct_I.pack(length))
00103       pattern = '<%sd'%length
00104       buff.write(struct.pack(pattern, *self.demo.times))
00105       length = len(self.k_gains)
00106       buff.write(_struct_I.pack(length))
00107       pattern = '<%sd'%length
00108       buff.write(struct.pack(pattern, *self.k_gains))
00109       length = len(self.d_gains)
00110       buff.write(_struct_I.pack(length))
00111       pattern = '<%sd'%length
00112       buff.write(struct.pack(pattern, *self.d_gains))
00113       buff.write(_struct_i.pack(self.num_bases))
00114     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00115     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00116 
00117   def deserialize(self, str):
00118     """
00119     unpack serialized message in str into this message instance
00120     :param str: byte array of serialized message, ``str``
00121     """
00122     try:
00123       if self.demo is None:
00124         self.demo = dmp.msg.DMPTraj()
00125       end = 0
00126       start = end
00127       end += 4
00128       (length,) = _struct_I.unpack(str[start:end])
00129       self.demo.points = []
00130       for i in range(0, length):
00131         val1 = dmp.msg.DMPPoint()
00132         start = end
00133         end += 4
00134         (length,) = _struct_I.unpack(str[start:end])
00135         pattern = '<%sd'%length
00136         start = end
00137         end += struct.calcsize(pattern)
00138         val1.positions = struct.unpack(pattern, str[start:end])
00139         start = end
00140         end += 4
00141         (length,) = _struct_I.unpack(str[start:end])
00142         pattern = '<%sd'%length
00143         start = end
00144         end += struct.calcsize(pattern)
00145         val1.velocities = struct.unpack(pattern, str[start:end])
00146         self.demo.points.append(val1)
00147       start = end
00148       end += 4
00149       (length,) = _struct_I.unpack(str[start:end])
00150       pattern = '<%sd'%length
00151       start = end
00152       end += struct.calcsize(pattern)
00153       self.demo.times = struct.unpack(pattern, str[start:end])
00154       start = end
00155       end += 4
00156       (length,) = _struct_I.unpack(str[start:end])
00157       pattern = '<%sd'%length
00158       start = end
00159       end += struct.calcsize(pattern)
00160       self.k_gains = struct.unpack(pattern, str[start:end])
00161       start = end
00162       end += 4
00163       (length,) = _struct_I.unpack(str[start:end])
00164       pattern = '<%sd'%length
00165       start = end
00166       end += struct.calcsize(pattern)
00167       self.d_gains = struct.unpack(pattern, str[start:end])
00168       start = end
00169       end += 4
00170       (self.num_bases,) = _struct_i.unpack(str[start:end])
00171       return self
00172     except struct.error as e:
00173       raise genpy.DeserializationError(e) #most likely buffer underfill
00174 
00175 
00176   def serialize_numpy(self, buff, numpy):
00177     """
00178     serialize message with numpy array types into buffer
00179     :param buff: buffer, ``StringIO``
00180     :param numpy: numpy python module
00181     """
00182     try:
00183       length = len(self.demo.points)
00184       buff.write(_struct_I.pack(length))
00185       for val1 in self.demo.points:
00186         length = len(val1.positions)
00187         buff.write(_struct_I.pack(length))
00188         pattern = '<%sd'%length
00189         buff.write(val1.positions.tostring())
00190         length = len(val1.velocities)
00191         buff.write(_struct_I.pack(length))
00192         pattern = '<%sd'%length
00193         buff.write(val1.velocities.tostring())
00194       length = len(self.demo.times)
00195       buff.write(_struct_I.pack(length))
00196       pattern = '<%sd'%length
00197       buff.write(self.demo.times.tostring())
00198       length = len(self.k_gains)
00199       buff.write(_struct_I.pack(length))
00200       pattern = '<%sd'%length
00201       buff.write(self.k_gains.tostring())
00202       length = len(self.d_gains)
00203       buff.write(_struct_I.pack(length))
00204       pattern = '<%sd'%length
00205       buff.write(self.d_gains.tostring())
00206       buff.write(_struct_i.pack(self.num_bases))
00207     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00208     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00209 
00210   def deserialize_numpy(self, str, numpy):
00211     """
00212     unpack serialized message in str into this message instance using numpy for array types
00213     :param str: byte array of serialized message, ``str``
00214     :param numpy: numpy python module
00215     """
00216     try:
00217       if self.demo is None:
00218         self.demo = dmp.msg.DMPTraj()
00219       end = 0
00220       start = end
00221       end += 4
00222       (length,) = _struct_I.unpack(str[start:end])
00223       self.demo.points = []
00224       for i in range(0, length):
00225         val1 = dmp.msg.DMPPoint()
00226         start = end
00227         end += 4
00228         (length,) = _struct_I.unpack(str[start:end])
00229         pattern = '<%sd'%length
00230         start = end
00231         end += struct.calcsize(pattern)
00232         val1.positions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00233         start = end
00234         end += 4
00235         (length,) = _struct_I.unpack(str[start:end])
00236         pattern = '<%sd'%length
00237         start = end
00238         end += struct.calcsize(pattern)
00239         val1.velocities = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00240         self.demo.points.append(val1)
00241       start = end
00242       end += 4
00243       (length,) = _struct_I.unpack(str[start:end])
00244       pattern = '<%sd'%length
00245       start = end
00246       end += struct.calcsize(pattern)
00247       self.demo.times = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00248       start = end
00249       end += 4
00250       (length,) = _struct_I.unpack(str[start:end])
00251       pattern = '<%sd'%length
00252       start = end
00253       end += struct.calcsize(pattern)
00254       self.k_gains = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00255       start = end
00256       end += 4
00257       (length,) = _struct_I.unpack(str[start:end])
00258       pattern = '<%sd'%length
00259       start = end
00260       end += struct.calcsize(pattern)
00261       self.d_gains = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00262       start = end
00263       end += 4
00264       (self.num_bases,) = _struct_i.unpack(str[start:end])
00265       return self
00266     except struct.error as e:
00267       raise genpy.DeserializationError(e) #most likely buffer underfill
00268 
00269 _struct_I = genpy.struct_I
00270 _struct_i = struct.Struct("<i")
00271 """autogenerated by genpy from dmp/LearnDMPFromDemoResponse.msg. Do not edit."""
00272 import sys
00273 python3 = True if sys.hexversion > 0x03000000 else False
00274 import genpy
00275 import struct
00276 
00277 import dmp.msg
00278 
00279 class LearnDMPFromDemoResponse(genpy.Message):
00280   _md5sum = "d2dccae00aae58574694dfa33e62fac1"
00281   _type = "dmp/LearnDMPFromDemoResponse"
00282   _has_header = False #flag to mark the presence of a Header object
00283   _full_text = """
00284 
00285 DMPData[] dmp_list
00286 
00287 
00288 float64 tau
00289 
00290 
00291 ================================================================================
00292 MSG: dmp/DMPData
00293 float64 k_gain
00294 float64 d_gain
00295 float64[] weights
00296 float64[] f_domain
00297 float64[] f_targets
00298 
00299 
00300 """
00301   __slots__ = ['dmp_list','tau']
00302   _slot_types = ['dmp/DMPData[]','float64']
00303 
00304   def __init__(self, *args, **kwds):
00305     """
00306     Constructor. Any message fields that are implicitly/explicitly
00307     set to None will be assigned a default value. The recommend
00308     use is keyword arguments as this is more robust to future message
00309     changes.  You cannot mix in-order arguments and keyword arguments.
00310 
00311     The available fields are:
00312        dmp_list,tau
00313 
00314     :param args: complete set of field values, in .msg order
00315     :param kwds: use keyword arguments corresponding to message field names
00316     to set specific fields.
00317     """
00318     if args or kwds:
00319       super(LearnDMPFromDemoResponse, self).__init__(*args, **kwds)
00320       #message fields cannot be None, assign default values for those that are
00321       if self.dmp_list is None:
00322         self.dmp_list = []
00323       if self.tau is None:
00324         self.tau = 0.
00325     else:
00326       self.dmp_list = []
00327       self.tau = 0.
00328 
00329   def _get_types(self):
00330     """
00331     internal API method
00332     """
00333     return self._slot_types
00334 
00335   def serialize(self, buff):
00336     """
00337     serialize message into buffer
00338     :param buff: buffer, ``StringIO``
00339     """
00340     try:
00341       length = len(self.dmp_list)
00342       buff.write(_struct_I.pack(length))
00343       for val1 in self.dmp_list:
00344         _x = val1
00345         buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00346         length = len(val1.weights)
00347         buff.write(_struct_I.pack(length))
00348         pattern = '<%sd'%length
00349         buff.write(struct.pack(pattern, *val1.weights))
00350         length = len(val1.f_domain)
00351         buff.write(_struct_I.pack(length))
00352         pattern = '<%sd'%length
00353         buff.write(struct.pack(pattern, *val1.f_domain))
00354         length = len(val1.f_targets)
00355         buff.write(_struct_I.pack(length))
00356         pattern = '<%sd'%length
00357         buff.write(struct.pack(pattern, *val1.f_targets))
00358       buff.write(_struct_d.pack(self.tau))
00359     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00360     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00361 
00362   def deserialize(self, str):
00363     """
00364     unpack serialized message in str into this message instance
00365     :param str: byte array of serialized message, ``str``
00366     """
00367     try:
00368       if self.dmp_list is None:
00369         self.dmp_list = None
00370       end = 0
00371       start = end
00372       end += 4
00373       (length,) = _struct_I.unpack(str[start:end])
00374       self.dmp_list = []
00375       for i in range(0, length):
00376         val1 = dmp.msg.DMPData()
00377         _x = val1
00378         start = end
00379         end += 16
00380         (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00381         start = end
00382         end += 4
00383         (length,) = _struct_I.unpack(str[start:end])
00384         pattern = '<%sd'%length
00385         start = end
00386         end += struct.calcsize(pattern)
00387         val1.weights = struct.unpack(pattern, str[start:end])
00388         start = end
00389         end += 4
00390         (length,) = _struct_I.unpack(str[start:end])
00391         pattern = '<%sd'%length
00392         start = end
00393         end += struct.calcsize(pattern)
00394         val1.f_domain = struct.unpack(pattern, str[start:end])
00395         start = end
00396         end += 4
00397         (length,) = _struct_I.unpack(str[start:end])
00398         pattern = '<%sd'%length
00399         start = end
00400         end += struct.calcsize(pattern)
00401         val1.f_targets = struct.unpack(pattern, str[start:end])
00402         self.dmp_list.append(val1)
00403       start = end
00404       end += 8
00405       (self.tau,) = _struct_d.unpack(str[start:end])
00406       return self
00407     except struct.error as e:
00408       raise genpy.DeserializationError(e) #most likely buffer underfill
00409 
00410 
00411   def serialize_numpy(self, buff, numpy):
00412     """
00413     serialize message with numpy array types into buffer
00414     :param buff: buffer, ``StringIO``
00415     :param numpy: numpy python module
00416     """
00417     try:
00418       length = len(self.dmp_list)
00419       buff.write(_struct_I.pack(length))
00420       for val1 in self.dmp_list:
00421         _x = val1
00422         buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00423         length = len(val1.weights)
00424         buff.write(_struct_I.pack(length))
00425         pattern = '<%sd'%length
00426         buff.write(val1.weights.tostring())
00427         length = len(val1.f_domain)
00428         buff.write(_struct_I.pack(length))
00429         pattern = '<%sd'%length
00430         buff.write(val1.f_domain.tostring())
00431         length = len(val1.f_targets)
00432         buff.write(_struct_I.pack(length))
00433         pattern = '<%sd'%length
00434         buff.write(val1.f_targets.tostring())
00435       buff.write(_struct_d.pack(self.tau))
00436     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00437     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00438 
00439   def deserialize_numpy(self, str, numpy):
00440     """
00441     unpack serialized message in str into this message instance using numpy for array types
00442     :param str: byte array of serialized message, ``str``
00443     :param numpy: numpy python module
00444     """
00445     try:
00446       if self.dmp_list is None:
00447         self.dmp_list = None
00448       end = 0
00449       start = end
00450       end += 4
00451       (length,) = _struct_I.unpack(str[start:end])
00452       self.dmp_list = []
00453       for i in range(0, length):
00454         val1 = dmp.msg.DMPData()
00455         _x = val1
00456         start = end
00457         end += 16
00458         (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00459         start = end
00460         end += 4
00461         (length,) = _struct_I.unpack(str[start:end])
00462         pattern = '<%sd'%length
00463         start = end
00464         end += struct.calcsize(pattern)
00465         val1.weights = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00466         start = end
00467         end += 4
00468         (length,) = _struct_I.unpack(str[start:end])
00469         pattern = '<%sd'%length
00470         start = end
00471         end += struct.calcsize(pattern)
00472         val1.f_domain = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00473         start = end
00474         end += 4
00475         (length,) = _struct_I.unpack(str[start:end])
00476         pattern = '<%sd'%length
00477         start = end
00478         end += struct.calcsize(pattern)
00479         val1.f_targets = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00480         self.dmp_list.append(val1)
00481       start = end
00482       end += 8
00483       (self.tau,) = _struct_d.unpack(str[start:end])
00484       return self
00485     except struct.error as e:
00486       raise genpy.DeserializationError(e) #most likely buffer underfill
00487 
00488 _struct_I = genpy.struct_I
00489 _struct_2d = struct.Struct("<2d")
00490 _struct_d = struct.Struct("<d")
00491 class LearnDMPFromDemo(object):
00492   _type          = 'dmp/LearnDMPFromDemo'
00493   _md5sum = '3ba13cfa47585560a2fd9cc202efdbff'
00494   _request_class  = LearnDMPFromDemoRequest
00495   _response_class = LearnDMPFromDemoResponse


dmp
Author(s): Scott Niekum
autogenerated on Sun Oct 5 2014 23:29:12