# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from nhfc_ros/or_wrench_estimator_state.msg. Do not edit."""
import codecs
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct

import nhfc_ros.msg

class or_wrench_estimator_state(genpy.Message):
  _md5sum = "b4666805b9da7df2c042e9581e91d187"
  _type = "nhfc_ros/or_wrench_estimator_state"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# IDL struct ::or_wrench_estimator::state
or_time_ts ts
bool intrinsic
or_rb3d_force[] force
or_rb3d_force_cov[] force_cov
or_rb3d_torque[] torque
or_rb3d_torque_cov[] torque_cov

================================================================================
MSG: nhfc_ros/or_time_ts
# IDL struct ::or::time::ts
int32 sec
int32 nsec

================================================================================
MSG: nhfc_ros/or_rb3d_force
# IDL struct ::or::rb3d::force
float64 x
float64 y
float64 z

================================================================================
MSG: nhfc_ros/or_rb3d_force_cov
# IDL struct ::or::rb3d::force_cov
float64[6] cov

================================================================================
MSG: nhfc_ros/or_rb3d_torque
# IDL struct ::or::rb3d::torque
float64 x
float64 y
float64 z

================================================================================
MSG: nhfc_ros/or_rb3d_torque_cov
# IDL struct ::or::rb3d::torque_cov
float64[6] cov
"""
  __slots__ = ['ts','intrinsic','force','force_cov','torque','torque_cov']
  _slot_types = ['nhfc_ros/or_time_ts','bool','nhfc_ros/or_rb3d_force[]','nhfc_ros/or_rb3d_force_cov[]','nhfc_ros/or_rb3d_torque[]','nhfc_ros/or_rb3d_torque_cov[]']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.

    The available fields are:
       ts,intrinsic,force,force_cov,torque,torque_cov

    :param args: complete set of field values, in .msg order
    :param kwds: use keyword arguments corresponding to message field names
    to set specific fields.
    """
    if args or kwds:
      super(or_wrench_estimator_state, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.intrinsic is None:
        self.intrinsic = False
      if self.force is None:
        self.force = []
      if self.force_cov is None:
        self.force_cov = []
      if self.torque is None:
        self.torque = []
      if self.torque_cov is None:
        self.torque_cov = []
    else:
      self.ts = nhfc_ros.msg.or_time_ts()
      self.intrinsic = False
      self.force = []
      self.force_cov = []
      self.torque = []
      self.torque_cov = []

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      _x = self
      buff.write(_get_struct_2iB().pack(_x.ts.sec, _x.ts.nsec, _x.intrinsic))
      length = len(self.force)
      buff.write(_struct_I.pack(length))
      for val1 in self.force:
        _x = val1
        buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
      length = len(self.force_cov)
      buff.write(_struct_I.pack(length))
      for val1 in self.force_cov:
        buff.write(_get_struct_6d().pack(*val1.cov))
      length = len(self.torque)
      buff.write(_struct_I.pack(length))
      for val1 in self.torque:
        _x = val1
        buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
      length = len(self.torque_cov)
      buff.write(_struct_I.pack(length))
      for val1 in self.torque_cov:
        buff.write(_get_struct_6d().pack(*val1.cov))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    :param str: byte array of serialized message, ``str``
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.force is None:
        self.force = None
      if self.force_cov is None:
        self.force_cov = None
      if self.torque is None:
        self.torque = None
      if self.torque_cov is None:
        self.torque_cov = None
      end = 0
      _x = self
      start = end
      end += 9
      (_x.ts.sec, _x.ts.nsec, _x.intrinsic,) = _get_struct_2iB().unpack(str[start:end])
      self.intrinsic = bool(self.intrinsic)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.force = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_force()
        _x = val1
        start = end
        end += 24
        (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
        self.force.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.force_cov = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_force_cov()
        start = end
        end += 48
        val1.cov = _get_struct_6d().unpack(str[start:end])
        self.force_cov.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.torque = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_torque()
        _x = val1
        start = end
        end += 24
        (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
        self.torque.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.torque_cov = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_torque_cov()
        start = end
        end += 48
        val1.cov = _get_struct_6d().unpack(str[start:end])
        self.torque_cov.append(val1)
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    :param buff: buffer, ``StringIO``
    :param numpy: numpy python module
    """
    try:
      _x = self
      buff.write(_get_struct_2iB().pack(_x.ts.sec, _x.ts.nsec, _x.intrinsic))
      length = len(self.force)
      buff.write(_struct_I.pack(length))
      for val1 in self.force:
        _x = val1
        buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
      length = len(self.force_cov)
      buff.write(_struct_I.pack(length))
      for val1 in self.force_cov:
        buff.write(val1.cov.tostring())
      length = len(self.torque)
      buff.write(_struct_I.pack(length))
      for val1 in self.torque:
        _x = val1
        buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
      length = len(self.torque_cov)
      buff.write(_struct_I.pack(length))
      for val1 in self.torque_cov:
        buff.write(val1.cov.tostring())
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    :param str: byte array of serialized message, ``str``
    :param numpy: numpy python module
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.force is None:
        self.force = None
      if self.force_cov is None:
        self.force_cov = None
      if self.torque is None:
        self.torque = None
      if self.torque_cov is None:
        self.torque_cov = None
      end = 0
      _x = self
      start = end
      end += 9
      (_x.ts.sec, _x.ts.nsec, _x.intrinsic,) = _get_struct_2iB().unpack(str[start:end])
      self.intrinsic = bool(self.intrinsic)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.force = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_force()
        _x = val1
        start = end
        end += 24
        (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
        self.force.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.force_cov = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_force_cov()
        start = end
        end += 48
        val1.cov = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=6)
        self.force_cov.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.torque = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_torque()
        _x = val1
        start = end
        end += 24
        (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
        self.torque.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.torque_cov = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.or_rb3d_torque_cov()
        start = end
        end += 48
        val1.cov = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=6)
        self.torque_cov.append(val1)
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill

_struct_I = genpy.struct_I
def _get_struct_I():
    global _struct_I
    return _struct_I
_struct_2iB = None
def _get_struct_2iB():
    global _struct_2iB
    if _struct_2iB is None:
        _struct_2iB = struct.Struct("<2iB")
    return _struct_2iB
_struct_3d = None
def _get_struct_3d():
    global _struct_3d
    if _struct_3d is None:
        _struct_3d = struct.Struct("<3d")
    return _struct_3d
_struct_6d = None
def _get_struct_6d():
    global _struct_6d
    if _struct_6d is None:
        _struct_6d = struct.Struct("<6d")
    return _struct_6d
