_Gains.py
Go to the documentation of this file.
00001 """autogenerated by genpy from nasa_r2_common_msgs/Gains.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 Gains(genpy.Message):
00009   _md5sum = "f78899cbb8067fadfd895405ba5d6742"
00010   _type = "nasa_r2_common_msgs/Gains"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """string[] joint_names
00013 float64[] naturalFreq
00014 float64[] dampingRatio
00015 float64[] K
00016 float64[] D
00017 float64[] I
00018 float64[] windupLimit
00019 
00020 """
00021   __slots__ = ['joint_names','naturalFreq','dampingRatio','K','D','I','windupLimit']
00022   _slot_types = ['string[]','float64[]','float64[]','float64[]','float64[]','float64[]','float64[]']
00023 
00024   def __init__(self, *args, **kwds):
00025     """
00026     Constructor. Any message fields that are implicitly/explicitly
00027     set to None will be assigned a default value. The recommend
00028     use is keyword arguments as this is more robust to future message
00029     changes.  You cannot mix in-order arguments and keyword arguments.
00030 
00031     The available fields are:
00032        joint_names,naturalFreq,dampingRatio,K,D,I,windupLimit
00033 
00034     :param args: complete set of field values, in .msg order
00035     :param kwds: use keyword arguments corresponding to message field names
00036     to set specific fields.
00037     """
00038     if args or kwds:
00039       super(Gains, self).__init__(*args, **kwds)
00040       #message fields cannot be None, assign default values for those that are
00041       if self.joint_names is None:
00042         self.joint_names = []
00043       if self.naturalFreq is None:
00044         self.naturalFreq = []
00045       if self.dampingRatio is None:
00046         self.dampingRatio = []
00047       if self.K is None:
00048         self.K = []
00049       if self.D is None:
00050         self.D = []
00051       if self.I is None:
00052         self.I = []
00053       if self.windupLimit is None:
00054         self.windupLimit = []
00055     else:
00056       self.joint_names = []
00057       self.naturalFreq = []
00058       self.dampingRatio = []
00059       self.K = []
00060       self.D = []
00061       self.I = []
00062       self.windupLimit = []
00063 
00064   def _get_types(self):
00065     """
00066     internal API method
00067     """
00068     return self._slot_types
00069 
00070   def serialize(self, buff):
00071     """
00072     serialize message into buffer
00073     :param buff: buffer, ``StringIO``
00074     """
00075     try:
00076       length = len(self.joint_names)
00077       buff.write(_struct_I.pack(length))
00078       for val1 in self.joint_names:
00079         length = len(val1)
00080         if python3 or type(val1) == unicode:
00081           val1 = val1.encode('utf-8')
00082           length = len(val1)
00083         buff.write(struct.pack('<I%ss'%length, length, val1))
00084       length = len(self.naturalFreq)
00085       buff.write(_struct_I.pack(length))
00086       pattern = '<%sd'%length
00087       buff.write(struct.pack(pattern, *self.naturalFreq))
00088       length = len(self.dampingRatio)
00089       buff.write(_struct_I.pack(length))
00090       pattern = '<%sd'%length
00091       buff.write(struct.pack(pattern, *self.dampingRatio))
00092       length = len(self.K)
00093       buff.write(_struct_I.pack(length))
00094       pattern = '<%sd'%length
00095       buff.write(struct.pack(pattern, *self.K))
00096       length = len(self.D)
00097       buff.write(_struct_I.pack(length))
00098       pattern = '<%sd'%length
00099       buff.write(struct.pack(pattern, *self.D))
00100       length = len(self.I)
00101       buff.write(_struct_I.pack(length))
00102       pattern = '<%sd'%length
00103       buff.write(struct.pack(pattern, *self.I))
00104       length = len(self.windupLimit)
00105       buff.write(_struct_I.pack(length))
00106       pattern = '<%sd'%length
00107       buff.write(struct.pack(pattern, *self.windupLimit))
00108     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00109     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00110 
00111   def deserialize(self, str):
00112     """
00113     unpack serialized message in str into this message instance
00114     :param str: byte array of serialized message, ``str``
00115     """
00116     try:
00117       end = 0
00118       start = end
00119       end += 4
00120       (length,) = _struct_I.unpack(str[start:end])
00121       self.joint_names = []
00122       for i in range(0, length):
00123         start = end
00124         end += 4
00125         (length,) = _struct_I.unpack(str[start:end])
00126         start = end
00127         end += length
00128         if python3:
00129           val1 = str[start:end].decode('utf-8')
00130         else:
00131           val1 = str[start:end]
00132         self.joint_names.append(val1)
00133       start = end
00134       end += 4
00135       (length,) = _struct_I.unpack(str[start:end])
00136       pattern = '<%sd'%length
00137       start = end
00138       end += struct.calcsize(pattern)
00139       self.naturalFreq = struct.unpack(pattern, str[start:end])
00140       start = end
00141       end += 4
00142       (length,) = _struct_I.unpack(str[start:end])
00143       pattern = '<%sd'%length
00144       start = end
00145       end += struct.calcsize(pattern)
00146       self.dampingRatio = struct.unpack(pattern, str[start:end])
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.K = 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.D = 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.I = struct.unpack(pattern, str[start:end])
00168       start = end
00169       end += 4
00170       (length,) = _struct_I.unpack(str[start:end])
00171       pattern = '<%sd'%length
00172       start = end
00173       end += struct.calcsize(pattern)
00174       self.windupLimit = struct.unpack(pattern, str[start:end])
00175       return self
00176     except struct.error as e:
00177       raise genpy.DeserializationError(e) #most likely buffer underfill
00178 
00179 
00180   def serialize_numpy(self, buff, numpy):
00181     """
00182     serialize message with numpy array types into buffer
00183     :param buff: buffer, ``StringIO``
00184     :param numpy: numpy python module
00185     """
00186     try:
00187       length = len(self.joint_names)
00188       buff.write(_struct_I.pack(length))
00189       for val1 in self.joint_names:
00190         length = len(val1)
00191         if python3 or type(val1) == unicode:
00192           val1 = val1.encode('utf-8')
00193           length = len(val1)
00194         buff.write(struct.pack('<I%ss'%length, length, val1))
00195       length = len(self.naturalFreq)
00196       buff.write(_struct_I.pack(length))
00197       pattern = '<%sd'%length
00198       buff.write(self.naturalFreq.tostring())
00199       length = len(self.dampingRatio)
00200       buff.write(_struct_I.pack(length))
00201       pattern = '<%sd'%length
00202       buff.write(self.dampingRatio.tostring())
00203       length = len(self.K)
00204       buff.write(_struct_I.pack(length))
00205       pattern = '<%sd'%length
00206       buff.write(self.K.tostring())
00207       length = len(self.D)
00208       buff.write(_struct_I.pack(length))
00209       pattern = '<%sd'%length
00210       buff.write(self.D.tostring())
00211       length = len(self.I)
00212       buff.write(_struct_I.pack(length))
00213       pattern = '<%sd'%length
00214       buff.write(self.I.tostring())
00215       length = len(self.windupLimit)
00216       buff.write(_struct_I.pack(length))
00217       pattern = '<%sd'%length
00218       buff.write(self.windupLimit.tostring())
00219     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00220     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00221 
00222   def deserialize_numpy(self, str, numpy):
00223     """
00224     unpack serialized message in str into this message instance using numpy for array types
00225     :param str: byte array of serialized message, ``str``
00226     :param numpy: numpy python module
00227     """
00228     try:
00229       end = 0
00230       start = end
00231       end += 4
00232       (length,) = _struct_I.unpack(str[start:end])
00233       self.joint_names = []
00234       for i in range(0, length):
00235         start = end
00236         end += 4
00237         (length,) = _struct_I.unpack(str[start:end])
00238         start = end
00239         end += length
00240         if python3:
00241           val1 = str[start:end].decode('utf-8')
00242         else:
00243           val1 = str[start:end]
00244         self.joint_names.append(val1)
00245       start = end
00246       end += 4
00247       (length,) = _struct_I.unpack(str[start:end])
00248       pattern = '<%sd'%length
00249       start = end
00250       end += struct.calcsize(pattern)
00251       self.naturalFreq = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00252       start = end
00253       end += 4
00254       (length,) = _struct_I.unpack(str[start:end])
00255       pattern = '<%sd'%length
00256       start = end
00257       end += struct.calcsize(pattern)
00258       self.dampingRatio = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00259       start = end
00260       end += 4
00261       (length,) = _struct_I.unpack(str[start:end])
00262       pattern = '<%sd'%length
00263       start = end
00264       end += struct.calcsize(pattern)
00265       self.K = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00266       start = end
00267       end += 4
00268       (length,) = _struct_I.unpack(str[start:end])
00269       pattern = '<%sd'%length
00270       start = end
00271       end += struct.calcsize(pattern)
00272       self.D = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00273       start = end
00274       end += 4
00275       (length,) = _struct_I.unpack(str[start:end])
00276       pattern = '<%sd'%length
00277       start = end
00278       end += struct.calcsize(pattern)
00279       self.I = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00280       start = end
00281       end += 4
00282       (length,) = _struct_I.unpack(str[start:end])
00283       pattern = '<%sd'%length
00284       start = end
00285       end += struct.calcsize(pattern)
00286       self.windupLimit = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00287       return self
00288     except struct.error as e:
00289       raise genpy.DeserializationError(e) #most likely buffer underfill
00290 
00291 _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