_DMPTraj.py
Go to the documentation of this file.
00001 """autogenerated by genpy from dmp/DMPTraj.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 DMPTraj(genpy.Message):
00010   _md5sum = "1d088d86ab60cf6a2671bc3c0e99932b"
00011   _type = "dmp/DMPTraj"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """# points and times should be the same length
00014 DMPPoint[] points
00015 
00016 # Times of observations, in seconds, starting at zero
00017 float64[] times
00018 
00019 
00020 
00021 ================================================================================
00022 MSG: dmp/DMPPoint
00023 # Positions and velocities of DOFs
00024 #Velocity is only used for movement plans, not for giving demonstrations.
00025 float64[] positions
00026 float64[] velocities
00027 
00028 
00029 
00030 """
00031   __slots__ = ['points','times']
00032   _slot_types = ['dmp/DMPPoint[]','float64[]']
00033 
00034   def __init__(self, *args, **kwds):
00035     """
00036     Constructor. Any message fields that are implicitly/explicitly
00037     set to None will be assigned a default value. The recommend
00038     use is keyword arguments as this is more robust to future message
00039     changes.  You cannot mix in-order arguments and keyword arguments.
00040 
00041     The available fields are:
00042        points,times
00043 
00044     :param args: complete set of field values, in .msg order
00045     :param kwds: use keyword arguments corresponding to message field names
00046     to set specific fields.
00047     """
00048     if args or kwds:
00049       super(DMPTraj, self).__init__(*args, **kwds)
00050       #message fields cannot be None, assign default values for those that are
00051       if self.points is None:
00052         self.points = []
00053       if self.times is None:
00054         self.times = []
00055     else:
00056       self.points = []
00057       self.times = []
00058 
00059   def _get_types(self):
00060     """
00061     internal API method
00062     """
00063     return self._slot_types
00064 
00065   def serialize(self, buff):
00066     """
00067     serialize message into buffer
00068     :param buff: buffer, ``StringIO``
00069     """
00070     try:
00071       length = len(self.points)
00072       buff.write(_struct_I.pack(length))
00073       for val1 in self.points:
00074         length = len(val1.positions)
00075         buff.write(_struct_I.pack(length))
00076         pattern = '<%sd'%length
00077         buff.write(struct.pack(pattern, *val1.positions))
00078         length = len(val1.velocities)
00079         buff.write(_struct_I.pack(length))
00080         pattern = '<%sd'%length
00081         buff.write(struct.pack(pattern, *val1.velocities))
00082       length = len(self.times)
00083       buff.write(_struct_I.pack(length))
00084       pattern = '<%sd'%length
00085       buff.write(struct.pack(pattern, *self.times))
00086     except struct.error as se: self._check_types(se)
00087     except TypeError as te: self._check_types(te)
00088 
00089   def deserialize(self, str):
00090     """
00091     unpack serialized message in str into this message instance
00092     :param str: byte array of serialized message, ``str``
00093     """
00094     try:
00095       if self.points is None:
00096         self.points = None
00097       end = 0
00098       start = end
00099       end += 4
00100       (length,) = _struct_I.unpack(str[start:end])
00101       self.points = []
00102       for i in range(0, length):
00103         val1 = dmp.msg.DMPPoint()
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         val1.positions = 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         val1.velocities = struct.unpack(pattern, str[start:end])
00118         self.points.append(val1)
00119       start = end
00120       end += 4
00121       (length,) = _struct_I.unpack(str[start:end])
00122       pattern = '<%sd'%length
00123       start = end
00124       end += struct.calcsize(pattern)
00125       self.times = struct.unpack(pattern, str[start:end])
00126       return self
00127     except struct.error as e:
00128       raise genpy.DeserializationError(e) #most likely buffer underfill
00129 
00130 
00131   def serialize_numpy(self, buff, numpy):
00132     """
00133     serialize message with numpy array types into buffer
00134     :param buff: buffer, ``StringIO``
00135     :param numpy: numpy python module
00136     """
00137     try:
00138       length = len(self.points)
00139       buff.write(_struct_I.pack(length))
00140       for val1 in self.points:
00141         length = len(val1.positions)
00142         buff.write(_struct_I.pack(length))
00143         pattern = '<%sd'%length
00144         buff.write(val1.positions.tostring())
00145         length = len(val1.velocities)
00146         buff.write(_struct_I.pack(length))
00147         pattern = '<%sd'%length
00148         buff.write(val1.velocities.tostring())
00149       length = len(self.times)
00150       buff.write(_struct_I.pack(length))
00151       pattern = '<%sd'%length
00152       buff.write(self.times.tostring())
00153     except struct.error as se: self._check_types(se)
00154     except TypeError as te: self._check_types(te)
00155 
00156   def deserialize_numpy(self, str, numpy):
00157     """
00158     unpack serialized message in str into this message instance using numpy for array types
00159     :param str: byte array of serialized message, ``str``
00160     :param numpy: numpy python module
00161     """
00162     try:
00163       if self.points is None:
00164         self.points = None
00165       end = 0
00166       start = end
00167       end += 4
00168       (length,) = _struct_I.unpack(str[start:end])
00169       self.points = []
00170       for i in range(0, length):
00171         val1 = dmp.msg.DMPPoint()
00172         start = end
00173         end += 4
00174         (length,) = _struct_I.unpack(str[start:end])
00175         pattern = '<%sd'%length
00176         start = end
00177         end += struct.calcsize(pattern)
00178         val1.positions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00179         start = end
00180         end += 4
00181         (length,) = _struct_I.unpack(str[start:end])
00182         pattern = '<%sd'%length
00183         start = end
00184         end += struct.calcsize(pattern)
00185         val1.velocities = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00186         self.points.append(val1)
00187       start = end
00188       end += 4
00189       (length,) = _struct_I.unpack(str[start:end])
00190       pattern = '<%sd'%length
00191       start = end
00192       end += struct.calcsize(pattern)
00193       self.times = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00194       return self
00195     except struct.error as e:
00196       raise genpy.DeserializationError(e) #most likely buffer underfill
00197 
00198 _struct_I = genpy.struct_I


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