Go to the documentation of this file.00001 """autogenerated by genpy from lwr_fri/JointPosCommand.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 JointPosCommand(genpy.Message):
00009 _md5sum = "4c13323622b71d0b598abb8052aea6aa"
00010 _type = "lwr_fri/JointPosCommand"
00011 _has_header = False
00012 _full_text = """string[] names
00013 float64[] positions
00014 """
00015 __slots__ = ['names','positions']
00016 _slot_types = ['string[]','float64[]']
00017
00018 def __init__(self, *args, **kwds):
00019 """
00020 Constructor. Any message fields that are implicitly/explicitly
00021 set to None will be assigned a default value. The recommend
00022 use is keyword arguments as this is more robust to future message
00023 changes. You cannot mix in-order arguments and keyword arguments.
00024
00025 The available fields are:
00026 names,positions
00027
00028 :param args: complete set of field values, in .msg order
00029 :param kwds: use keyword arguments corresponding to message field names
00030 to set specific fields.
00031 """
00032 if args or kwds:
00033 super(JointPosCommand, self).__init__(*args, **kwds)
00034
00035 if self.names is None:
00036 self.names = []
00037 if self.positions is None:
00038 self.positions = []
00039 else:
00040 self.names = []
00041 self.positions = []
00042
00043 def _get_types(self):
00044 """
00045 internal API method
00046 """
00047 return self._slot_types
00048
00049 def serialize(self, buff):
00050 """
00051 serialize message into buffer
00052 :param buff: buffer, ``StringIO``
00053 """
00054 try:
00055 length = len(self.names)
00056 buff.write(_struct_I.pack(length))
00057 for val1 in self.names:
00058 length = len(val1)
00059 if python3 or type(val1) == unicode:
00060 val1 = val1.encode('utf-8')
00061 length = len(val1)
00062 buff.write(struct.pack('<I%ss'%length, length, val1))
00063 length = len(self.positions)
00064 buff.write(_struct_I.pack(length))
00065 pattern = '<%sd'%length
00066 buff.write(struct.pack(pattern, *self.positions))
00067 except struct.error as se: self._check_types(se)
00068 except TypeError as te: self._check_types(te)
00069
00070 def deserialize(self, str):
00071 """
00072 unpack serialized message in str into this message instance
00073 :param str: byte array of serialized message, ``str``
00074 """
00075 try:
00076 end = 0
00077 start = end
00078 end += 4
00079 (length,) = _struct_I.unpack(str[start:end])
00080 self.names = []
00081 for i in range(0, length):
00082 start = end
00083 end += 4
00084 (length,) = _struct_I.unpack(str[start:end])
00085 start = end
00086 end += length
00087 if python3:
00088 val1 = str[start:end].decode('utf-8')
00089 else:
00090 val1 = str[start:end]
00091 self.names.append(val1)
00092 start = end
00093 end += 4
00094 (length,) = _struct_I.unpack(str[start:end])
00095 pattern = '<%sd'%length
00096 start = end
00097 end += struct.calcsize(pattern)
00098 self.positions = struct.unpack(pattern, str[start:end])
00099 return self
00100 except struct.error as e:
00101 raise genpy.DeserializationError(e)
00102
00103
00104 def serialize_numpy(self, buff, numpy):
00105 """
00106 serialize message with numpy array types into buffer
00107 :param buff: buffer, ``StringIO``
00108 :param numpy: numpy python module
00109 """
00110 try:
00111 length = len(self.names)
00112 buff.write(_struct_I.pack(length))
00113 for val1 in self.names:
00114 length = len(val1)
00115 if python3 or type(val1) == unicode:
00116 val1 = val1.encode('utf-8')
00117 length = len(val1)
00118 buff.write(struct.pack('<I%ss'%length, length, val1))
00119 length = len(self.positions)
00120 buff.write(_struct_I.pack(length))
00121 pattern = '<%sd'%length
00122 buff.write(self.positions.tostring())
00123 except struct.error as se: self._check_types(se)
00124 except TypeError as te: self._check_types(te)
00125
00126 def deserialize_numpy(self, str, numpy):
00127 """
00128 unpack serialized message in str into this message instance using numpy for array types
00129 :param str: byte array of serialized message, ``str``
00130 :param numpy: numpy python module
00131 """
00132 try:
00133 end = 0
00134 start = end
00135 end += 4
00136 (length,) = _struct_I.unpack(str[start:end])
00137 self.names = []
00138 for i in range(0, length):
00139 start = end
00140 end += 4
00141 (length,) = _struct_I.unpack(str[start:end])
00142 start = end
00143 end += length
00144 if python3:
00145 val1 = str[start:end].decode('utf-8')
00146 else:
00147 val1 = str[start:end]
00148 self.names.append(val1)
00149 start = end
00150 end += 4
00151 (length,) = _struct_I.unpack(str[start:end])
00152 pattern = '<%sd'%length
00153 start = end
00154 end += struct.calcsize(pattern)
00155 self.positions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00156 return self
00157 except struct.error as e:
00158 raise genpy.DeserializationError(e)
00159
00160 _struct_I = genpy.struct_I