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
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
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(se)
00115 except TypeError as te: self._check_types(te)
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)
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(se)
00208 except TypeError as te: self._check_types(te)
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)
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 = "e778e277023cbea0ad639b06f5e88977"
00281 _type = "dmp/LearnDMPFromDemoResponse"
00282 _has_header = False
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
00297 """
00298 __slots__ = ['dmp_list','tau']
00299 _slot_types = ['dmp/DMPData[]','float64']
00300
00301 def __init__(self, *args, **kwds):
00302 """
00303 Constructor. Any message fields that are implicitly/explicitly
00304 set to None will be assigned a default value. The recommend
00305 use is keyword arguments as this is more robust to future message
00306 changes. You cannot mix in-order arguments and keyword arguments.
00307
00308 The available fields are:
00309 dmp_list,tau
00310
00311 :param args: complete set of field values, in .msg order
00312 :param kwds: use keyword arguments corresponding to message field names
00313 to set specific fields.
00314 """
00315 if args or kwds:
00316 super(LearnDMPFromDemoResponse, self).__init__(*args, **kwds)
00317
00318 if self.dmp_list is None:
00319 self.dmp_list = []
00320 if self.tau is None:
00321 self.tau = 0.
00322 else:
00323 self.dmp_list = []
00324 self.tau = 0.
00325
00326 def _get_types(self):
00327 """
00328 internal API method
00329 """
00330 return self._slot_types
00331
00332 def serialize(self, buff):
00333 """
00334 serialize message into buffer
00335 :param buff: buffer, ``StringIO``
00336 """
00337 try:
00338 length = len(self.dmp_list)
00339 buff.write(_struct_I.pack(length))
00340 for val1 in self.dmp_list:
00341 _x = val1
00342 buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00343 length = len(val1.weights)
00344 buff.write(_struct_I.pack(length))
00345 pattern = '<%sd'%length
00346 buff.write(struct.pack(pattern, *val1.weights))
00347 buff.write(_struct_d.pack(self.tau))
00348 except struct.error as se: self._check_types(se)
00349 except TypeError as te: self._check_types(te)
00350
00351 def deserialize(self, str):
00352 """
00353 unpack serialized message in str into this message instance
00354 :param str: byte array of serialized message, ``str``
00355 """
00356 try:
00357 if self.dmp_list is None:
00358 self.dmp_list = None
00359 end = 0
00360 start = end
00361 end += 4
00362 (length,) = _struct_I.unpack(str[start:end])
00363 self.dmp_list = []
00364 for i in range(0, length):
00365 val1 = dmp.msg.DMPData()
00366 _x = val1
00367 start = end
00368 end += 16
00369 (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00370 start = end
00371 end += 4
00372 (length,) = _struct_I.unpack(str[start:end])
00373 pattern = '<%sd'%length
00374 start = end
00375 end += struct.calcsize(pattern)
00376 val1.weights = struct.unpack(pattern, str[start:end])
00377 self.dmp_list.append(val1)
00378 start = end
00379 end += 8
00380 (self.tau,) = _struct_d.unpack(str[start:end])
00381 return self
00382 except struct.error as e:
00383 raise genpy.DeserializationError(e)
00384
00385
00386 def serialize_numpy(self, buff, numpy):
00387 """
00388 serialize message with numpy array types into buffer
00389 :param buff: buffer, ``StringIO``
00390 :param numpy: numpy python module
00391 """
00392 try:
00393 length = len(self.dmp_list)
00394 buff.write(_struct_I.pack(length))
00395 for val1 in self.dmp_list:
00396 _x = val1
00397 buff.write(_struct_2d.pack(_x.k_gain, _x.d_gain))
00398 length = len(val1.weights)
00399 buff.write(_struct_I.pack(length))
00400 pattern = '<%sd'%length
00401 buff.write(val1.weights.tostring())
00402 buff.write(_struct_d.pack(self.tau))
00403 except struct.error as se: self._check_types(se)
00404 except TypeError as te: self._check_types(te)
00405
00406 def deserialize_numpy(self, str, numpy):
00407 """
00408 unpack serialized message in str into this message instance using numpy for array types
00409 :param str: byte array of serialized message, ``str``
00410 :param numpy: numpy python module
00411 """
00412 try:
00413 if self.dmp_list is None:
00414 self.dmp_list = None
00415 end = 0
00416 start = end
00417 end += 4
00418 (length,) = _struct_I.unpack(str[start:end])
00419 self.dmp_list = []
00420 for i in range(0, length):
00421 val1 = dmp.msg.DMPData()
00422 _x = val1
00423 start = end
00424 end += 16
00425 (_x.k_gain, _x.d_gain,) = _struct_2d.unpack(str[start:end])
00426 start = end
00427 end += 4
00428 (length,) = _struct_I.unpack(str[start:end])
00429 pattern = '<%sd'%length
00430 start = end
00431 end += struct.calcsize(pattern)
00432 val1.weights = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00433 self.dmp_list.append(val1)
00434 start = end
00435 end += 8
00436 (self.tau,) = _struct_d.unpack(str[start:end])
00437 return self
00438 except struct.error as e:
00439 raise genpy.DeserializationError(e)
00440
00441 _struct_I = genpy.struct_I
00442 _struct_2d = struct.Struct("<2d")
00443 _struct_d = struct.Struct("<d")
00444 class LearnDMPFromDemo(object):
00445 _type = 'dmp/LearnDMPFromDemo'
00446 _md5sum = 'c86b9c6d2dad44f8f9b1c5a75e26b660'
00447 _request_class = LearnDMPFromDemoRequest
00448 _response_class = LearnDMPFromDemoResponse