Go to the documentation of this file.00001 """autogenerated by genpy from ethercat_hardware/RawFTData.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 ethercat_hardware.msg
00008
00009 class RawFTData(genpy.Message):
00010 _md5sum = "85f5ed45095367bfb8fb2e57954c0b89"
00011 _type = "ethercat_hardware/RawFTData"
00012 _has_header = False
00013 _full_text = """# Raw Data from WG035 F/T input via WG006 (gripper MCB).
00014 RawFTDataSample[] samples # The realtime loop receives upto 4 new samples each 1hKhz cycle
00015 int64 sample_count # Counts number of samples
00016 int64 missed_samples # Counts number of samples that were missed
00017 ================================================================================
00018 MSG: ethercat_hardware/RawFTDataSample
00019 # One raw Data sample from WG035 F/T input via WG006 (gripper MCB).
00020 uint64 sample_count
00021 int16[] data
00022 uint16 vhalf
00023 """
00024 __slots__ = ['samples','sample_count','missed_samples']
00025 _slot_types = ['ethercat_hardware/RawFTDataSample[]','int64','int64']
00026
00027 def __init__(self, *args, **kwds):
00028 """
00029 Constructor. Any message fields that are implicitly/explicitly
00030 set to None will be assigned a default value. The recommend
00031 use is keyword arguments as this is more robust to future message
00032 changes. You cannot mix in-order arguments and keyword arguments.
00033
00034 The available fields are:
00035 samples,sample_count,missed_samples
00036
00037 :param args: complete set of field values, in .msg order
00038 :param kwds: use keyword arguments corresponding to message field names
00039 to set specific fields.
00040 """
00041 if args or kwds:
00042 super(RawFTData, self).__init__(*args, **kwds)
00043
00044 if self.samples is None:
00045 self.samples = []
00046 if self.sample_count is None:
00047 self.sample_count = 0
00048 if self.missed_samples is None:
00049 self.missed_samples = 0
00050 else:
00051 self.samples = []
00052 self.sample_count = 0
00053 self.missed_samples = 0
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 length = len(self.samples)
00068 buff.write(_struct_I.pack(length))
00069 for val1 in self.samples:
00070 buff.write(_struct_Q.pack(val1.sample_count))
00071 length = len(val1.data)
00072 buff.write(_struct_I.pack(length))
00073 pattern = '<%sh'%length
00074 buff.write(struct.pack(pattern, *val1.data))
00075 buff.write(_struct_H.pack(val1.vhalf))
00076 _x = self
00077 buff.write(_struct_2q.pack(_x.sample_count, _x.missed_samples))
00078 except struct.error as se: self._check_types(se)
00079 except TypeError as te: self._check_types(te)
00080
00081 def deserialize(self, str):
00082 """
00083 unpack serialized message in str into this message instance
00084 :param str: byte array of serialized message, ``str``
00085 """
00086 try:
00087 if self.samples is None:
00088 self.samples = None
00089 end = 0
00090 start = end
00091 end += 4
00092 (length,) = _struct_I.unpack(str[start:end])
00093 self.samples = []
00094 for i in range(0, length):
00095 val1 = ethercat_hardware.msg.RawFTDataSample()
00096 start = end
00097 end += 8
00098 (val1.sample_count,) = _struct_Q.unpack(str[start:end])
00099 start = end
00100 end += 4
00101 (length,) = _struct_I.unpack(str[start:end])
00102 pattern = '<%sh'%length
00103 start = end
00104 end += struct.calcsize(pattern)
00105 val1.data = struct.unpack(pattern, str[start:end])
00106 start = end
00107 end += 2
00108 (val1.vhalf,) = _struct_H.unpack(str[start:end])
00109 self.samples.append(val1)
00110 _x = self
00111 start = end
00112 end += 16
00113 (_x.sample_count, _x.missed_samples,) = _struct_2q.unpack(str[start:end])
00114 return self
00115 except struct.error as e:
00116 raise genpy.DeserializationError(e)
00117
00118
00119 def serialize_numpy(self, buff, numpy):
00120 """
00121 serialize message with numpy array types into buffer
00122 :param buff: buffer, ``StringIO``
00123 :param numpy: numpy python module
00124 """
00125 try:
00126 length = len(self.samples)
00127 buff.write(_struct_I.pack(length))
00128 for val1 in self.samples:
00129 buff.write(_struct_Q.pack(val1.sample_count))
00130 length = len(val1.data)
00131 buff.write(_struct_I.pack(length))
00132 pattern = '<%sh'%length
00133 buff.write(val1.data.tostring())
00134 buff.write(_struct_H.pack(val1.vhalf))
00135 _x = self
00136 buff.write(_struct_2q.pack(_x.sample_count, _x.missed_samples))
00137 except struct.error as se: self._check_types(se)
00138 except TypeError as te: self._check_types(te)
00139
00140 def deserialize_numpy(self, str, numpy):
00141 """
00142 unpack serialized message in str into this message instance using numpy for array types
00143 :param str: byte array of serialized message, ``str``
00144 :param numpy: numpy python module
00145 """
00146 try:
00147 if self.samples is None:
00148 self.samples = None
00149 end = 0
00150 start = end
00151 end += 4
00152 (length,) = _struct_I.unpack(str[start:end])
00153 self.samples = []
00154 for i in range(0, length):
00155 val1 = ethercat_hardware.msg.RawFTDataSample()
00156 start = end
00157 end += 8
00158 (val1.sample_count,) = _struct_Q.unpack(str[start:end])
00159 start = end
00160 end += 4
00161 (length,) = _struct_I.unpack(str[start:end])
00162 pattern = '<%sh'%length
00163 start = end
00164 end += struct.calcsize(pattern)
00165 val1.data = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=length)
00166 start = end
00167 end += 2
00168 (val1.vhalf,) = _struct_H.unpack(str[start:end])
00169 self.samples.append(val1)
00170 _x = self
00171 start = end
00172 end += 16
00173 (_x.sample_count, _x.missed_samples,) = _struct_2q.unpack(str[start:end])
00174 return self
00175 except struct.error as e:
00176 raise genpy.DeserializationError(e)
00177
00178 _struct_I = genpy.struct_I
00179 _struct_Q = struct.Struct("<Q")
00180 _struct_H = struct.Struct("<H")
00181 _struct_2q = struct.Struct("<2q")