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