_LabeledTrajectoryMonitorFactors.py
Go to the documentation of this file.
00001 """autogenerated by genpy from nasa_r2_common_msgs/LabeledTrajectoryMonitorFactors.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 LabeledTrajectoryMonitorFactors(genpy.Message):
00009   _md5sum = "a48b940794366a56997943ecd6977867"
00010   _type = "nasa_r2_common_msgs/LabeledTrajectoryMonitorFactors"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """string originator
00013 string[] joint_names
00014 float64[] torqueLimitFactors
00015 float64[] distanceFactors
00016 
00017 """
00018   __slots__ = ['originator','joint_names','torqueLimitFactors','distanceFactors']
00019   _slot_types = ['string','string[]','float64[]','float64[]']
00020 
00021   def __init__(self, *args, **kwds):
00022     """
00023     Constructor. Any message fields that are implicitly/explicitly
00024     set to None will be assigned a default value. The recommend
00025     use is keyword arguments as this is more robust to future message
00026     changes.  You cannot mix in-order arguments and keyword arguments.
00027 
00028     The available fields are:
00029        originator,joint_names,torqueLimitFactors,distanceFactors
00030 
00031     :param args: complete set of field values, in .msg order
00032     :param kwds: use keyword arguments corresponding to message field names
00033     to set specific fields.
00034     """
00035     if args or kwds:
00036       super(LabeledTrajectoryMonitorFactors, self).__init__(*args, **kwds)
00037       #message fields cannot be None, assign default values for those that are
00038       if self.originator is None:
00039         self.originator = ''
00040       if self.joint_names is None:
00041         self.joint_names = []
00042       if self.torqueLimitFactors is None:
00043         self.torqueLimitFactors = []
00044       if self.distanceFactors is None:
00045         self.distanceFactors = []
00046     else:
00047       self.originator = ''
00048       self.joint_names = []
00049       self.torqueLimitFactors = []
00050       self.distanceFactors = []
00051 
00052   def _get_types(self):
00053     """
00054     internal API method
00055     """
00056     return self._slot_types
00057 
00058   def serialize(self, buff):
00059     """
00060     serialize message into buffer
00061     :param buff: buffer, ``StringIO``
00062     """
00063     try:
00064       _x = self.originator
00065       length = len(_x)
00066       if python3 or type(_x) == unicode:
00067         _x = _x.encode('utf-8')
00068         length = len(_x)
00069       buff.write(struct.pack('<I%ss'%length, length, _x))
00070       length = len(self.joint_names)
00071       buff.write(_struct_I.pack(length))
00072       for val1 in self.joint_names:
00073         length = len(val1)
00074         if python3 or type(val1) == unicode:
00075           val1 = val1.encode('utf-8')
00076           length = len(val1)
00077         buff.write(struct.pack('<I%ss'%length, length, val1))
00078       length = len(self.torqueLimitFactors)
00079       buff.write(_struct_I.pack(length))
00080       pattern = '<%sd'%length
00081       buff.write(struct.pack(pattern, *self.torqueLimitFactors))
00082       length = len(self.distanceFactors)
00083       buff.write(_struct_I.pack(length))
00084       pattern = '<%sd'%length
00085       buff.write(struct.pack(pattern, *self.distanceFactors))
00086     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00087     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
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       end = 0
00096       start = end
00097       end += 4
00098       (length,) = _struct_I.unpack(str[start:end])
00099       start = end
00100       end += length
00101       if python3:
00102         self.originator = str[start:end].decode('utf-8')
00103       else:
00104         self.originator = str[start:end]
00105       start = end
00106       end += 4
00107       (length,) = _struct_I.unpack(str[start:end])
00108       self.joint_names = []
00109       for i in range(0, length):
00110         start = end
00111         end += 4
00112         (length,) = _struct_I.unpack(str[start:end])
00113         start = end
00114         end += length
00115         if python3:
00116           val1 = str[start:end].decode('utf-8')
00117         else:
00118           val1 = str[start:end]
00119         self.joint_names.append(val1)
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.torqueLimitFactors = struct.unpack(pattern, str[start:end])
00127       start = end
00128       end += 4
00129       (length,) = _struct_I.unpack(str[start:end])
00130       pattern = '<%sd'%length
00131       start = end
00132       end += struct.calcsize(pattern)
00133       self.distanceFactors = struct.unpack(pattern, str[start:end])
00134       return self
00135     except struct.error as e:
00136       raise genpy.DeserializationError(e) #most likely buffer underfill
00137 
00138 
00139   def serialize_numpy(self, buff, numpy):
00140     """
00141     serialize message with numpy array types into buffer
00142     :param buff: buffer, ``StringIO``
00143     :param numpy: numpy python module
00144     """
00145     try:
00146       _x = self.originator
00147       length = len(_x)
00148       if python3 or type(_x) == unicode:
00149         _x = _x.encode('utf-8')
00150         length = len(_x)
00151       buff.write(struct.pack('<I%ss'%length, length, _x))
00152       length = len(self.joint_names)
00153       buff.write(_struct_I.pack(length))
00154       for val1 in self.joint_names:
00155         length = len(val1)
00156         if python3 or type(val1) == unicode:
00157           val1 = val1.encode('utf-8')
00158           length = len(val1)
00159         buff.write(struct.pack('<I%ss'%length, length, val1))
00160       length = len(self.torqueLimitFactors)
00161       buff.write(_struct_I.pack(length))
00162       pattern = '<%sd'%length
00163       buff.write(self.torqueLimitFactors.tostring())
00164       length = len(self.distanceFactors)
00165       buff.write(_struct_I.pack(length))
00166       pattern = '<%sd'%length
00167       buff.write(self.distanceFactors.tostring())
00168     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00169     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00170 
00171   def deserialize_numpy(self, str, numpy):
00172     """
00173     unpack serialized message in str into this message instance using numpy for array types
00174     :param str: byte array of serialized message, ``str``
00175     :param numpy: numpy python module
00176     """
00177     try:
00178       end = 0
00179       start = end
00180       end += 4
00181       (length,) = _struct_I.unpack(str[start:end])
00182       start = end
00183       end += length
00184       if python3:
00185         self.originator = str[start:end].decode('utf-8')
00186       else:
00187         self.originator = str[start:end]
00188       start = end
00189       end += 4
00190       (length,) = _struct_I.unpack(str[start:end])
00191       self.joint_names = []
00192       for i in range(0, length):
00193         start = end
00194         end += 4
00195         (length,) = _struct_I.unpack(str[start:end])
00196         start = end
00197         end += length
00198         if python3:
00199           val1 = str[start:end].decode('utf-8')
00200         else:
00201           val1 = str[start:end]
00202         self.joint_names.append(val1)
00203       start = end
00204       end += 4
00205       (length,) = _struct_I.unpack(str[start:end])
00206       pattern = '<%sd'%length
00207       start = end
00208       end += struct.calcsize(pattern)
00209       self.torqueLimitFactors = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00210       start = end
00211       end += 4
00212       (length,) = _struct_I.unpack(str[start:end])
00213       pattern = '<%sd'%length
00214       start = end
00215       end += struct.calcsize(pattern)
00216       self.distanceFactors = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00217       return self
00218     except struct.error as e:
00219       raise genpy.DeserializationError(e) #most likely buffer underfill
00220 
00221 _struct_I = genpy.struct_I


nasa_r2_common_msgs
Author(s): Paul Dinh. Maintained by Jennifer Turner
autogenerated on Mon Oct 6 2014 02:42:34