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

import frame_msgs.msg
import geometry_msgs.msg
import genpy
import std_msgs.msg

class PersonTrajectories(genpy.Message):
  _md5sum = "ae6789945f2030885896ef815b8cdbee"
  _type = "frame_msgs/PersonTrajectories"
  _has_header = True #flag to mark the presence of a Header object
  _full_text = """# Message with all currently tracked person trajectories
#

Header              header          # Header containing timestamp etc. of this message
PersonTrajectory[]  trajectories    # All states of the last T frames of the most likely trajectory of that tracked person.

================================================================================
MSG: std_msgs/Header
# Standard metadata for higher-level stamped data types.
# This is generally used to communicate timestamped data 
# in a particular coordinate frame.
# 
# sequence ID: consecutively increasing ID 
uint32 seq
#Two-integer timestamp that is expressed as:
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
# time-handling sugar is provided by the client library
time stamp
#Frame this data is associated with
string frame_id

================================================================================
MSG: frame_msgs/PersonTrajectory
# Message defining the trajectory of a tracked person.
#
# The distinction between track and trajectory is that, depending on the
# implementation of the tracker, a single track (i.e. tracked person) might
# change the trajectory if at some point a new trajectory "fits" that track (person)
# better.
#

uint64                   track_id   # Unique identifier of the tracked person.
PersonTrajectoryEntry[]  trajectory # All states of the last T frames of the most likely trajectory of that tracked person.

================================================================================
MSG: frame_msgs/PersonTrajectoryEntry
# Message defining an entry of a person trajectory.
#

duration    age             # age of the track
bool        is_occluded     # if the track is currently not matched by a detection
uint64      detection_id    # id of the corresponding detection in the current cycle (undefined if occluded)

# The following fields are extracted from the Kalman state x and its covariance C

geometry_msgs/PoseWithCovariance    pose   # pose of the track (z value and orientation might not be set, check if corresponding variance on diagonal is > 99999)
geometry_msgs/TwistWithCovariance   twist  # velocity of the track (z value and rotational velocities might not be set, check if corresponding variance on diagonal is > 99999)

================================================================================
MSG: geometry_msgs/PoseWithCovariance
# This represents a pose in free space with uncertainty.

Pose pose

# Row-major representation of the 6x6 covariance matrix
# The orientation parameters use a fixed-axis representation.
# In order, the parameters are:
# (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
float64[36] covariance

================================================================================
MSG: geometry_msgs/Pose
# A representation of pose in free space, composed of position and orientation. 
Point position
Quaternion orientation

================================================================================
MSG: geometry_msgs/Point
# This contains the position of a point in free space
float64 x
float64 y
float64 z

================================================================================
MSG: geometry_msgs/Quaternion
# This represents an orientation in free space in quaternion form.

float64 x
float64 y
float64 z
float64 w

================================================================================
MSG: geometry_msgs/TwistWithCovariance
# This expresses velocity in free space with uncertainty.

Twist twist

# Row-major representation of the 6x6 covariance matrix
# The orientation parameters use a fixed-axis representation.
# In order, the parameters are:
# (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
float64[36] covariance

================================================================================
MSG: geometry_msgs/Twist
# This expresses velocity in free space broken into its linear and angular parts.
Vector3  linear
Vector3  angular

================================================================================
MSG: geometry_msgs/Vector3
# This represents a vector in free space. 
# It is only meant to represent a direction. Therefore, it does not
# make sense to apply a translation to it (e.g., when applying a 
# generic rigid transformation to a Vector3, tf2 will only apply the
# rotation). If you want your data to be translatable too, use the
# geometry_msgs/Point message instead.

float64 x
float64 y
float64 z"""
  __slots__ = ['header','trajectories']
  _slot_types = ['std_msgs/Header','frame_msgs/PersonTrajectory[]']

  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:
       header,trajectories

    :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(PersonTrajectories, self).__init__(*args, **kwds)
      #message fields cannot be None, assign default values for those that are
      if self.header is None:
        self.header = std_msgs.msg.Header()
      if self.trajectories is None:
        self.trajectories = []
    else:
      self.header = std_msgs.msg.Header()
      self.trajectories = []

  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_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
      _x = self.header.frame_id
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.trajectories)
      buff.write(_struct_I.pack(length))
      for val1 in self.trajectories:
        buff.write(_get_struct_Q().pack(val1.track_id))
        length = len(val1.trajectory)
        buff.write(_struct_I.pack(length))
        for val2 in val1.trajectory:
          _v1 = val2.age
          _x = _v1
          buff.write(_get_struct_2i().pack(_x.secs, _x.nsecs))
          _x = val2
          buff.write(_get_struct_BQ().pack(_x.is_occluded, _x.detection_id))
          _v2 = val2.pose
          _v3 = _v2.pose
          _v4 = _v3.position
          _x = _v4
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          _v5 = _v3.orientation
          _x = _v5
          buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w))
          buff.write(_get_struct_36d().pack(*_v2.covariance))
          _v6 = val2.twist
          _v7 = _v6.twist
          _v8 = _v7.linear
          _x = _v8
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          _v9 = _v7.angular
          _x = _v9
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          buff.write(_get_struct_36d().pack(*_v6.covariance))
    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``
    """
    try:
      if self.header is None:
        self.header = std_msgs.msg.Header()
      if self.trajectories is None:
        self.trajectories = None
      end = 0
      _x = self
      start = end
      end += 12
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.header.frame_id = str[start:end].decode('utf-8')
      else:
        self.header.frame_id = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.trajectories = []
      for i in range(0, length):
        val1 = frame_msgs.msg.PersonTrajectory()
        start = end
        end += 8
        (val1.track_id,) = _get_struct_Q().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.trajectory = []
        for i in range(0, length):
          val2 = frame_msgs.msg.PersonTrajectoryEntry()
          _v10 = val2.age
          _x = _v10
          start = end
          end += 8
          (_x.secs, _x.nsecs,) = _get_struct_2i().unpack(str[start:end])
          _x = val2
          start = end
          end += 9
          (_x.is_occluded, _x.detection_id,) = _get_struct_BQ().unpack(str[start:end])
          val2.is_occluded = bool(val2.is_occluded)
          _v11 = val2.pose
          _v12 = _v11.pose
          _v13 = _v12.position
          _x = _v13
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          _v14 = _v12.orientation
          _x = _v14
          start = end
          end += 32
          (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
          start = end
          end += 288
          _v11.covariance = _get_struct_36d().unpack(str[start:end])
          _v15 = val2.twist
          _v16 = _v15.twist
          _v17 = _v16.linear
          _x = _v17
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          _v18 = _v16.angular
          _x = _v18
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          start = end
          end += 288
          _v15.covariance = _get_struct_36d().unpack(str[start:end])
          val1.trajectory.append(val2)
        self.trajectories.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_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
      _x = self.header.frame_id
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.pack('<I%ss'%length, length, _x))
      length = len(self.trajectories)
      buff.write(_struct_I.pack(length))
      for val1 in self.trajectories:
        buff.write(_get_struct_Q().pack(val1.track_id))
        length = len(val1.trajectory)
        buff.write(_struct_I.pack(length))
        for val2 in val1.trajectory:
          _v19 = val2.age
          _x = _v19
          buff.write(_get_struct_2i().pack(_x.secs, _x.nsecs))
          _x = val2
          buff.write(_get_struct_BQ().pack(_x.is_occluded, _x.detection_id))
          _v20 = val2.pose
          _v21 = _v20.pose
          _v22 = _v21.position
          _x = _v22
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          _v23 = _v21.orientation
          _x = _v23
          buff.write(_get_struct_4d().pack(_x.x, _x.y, _x.z, _x.w))
          buff.write(_v20.covariance.tostring())
          _v24 = val2.twist
          _v25 = _v24.twist
          _v26 = _v25.linear
          _x = _v26
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          _v27 = _v25.angular
          _x = _v27
          buff.write(_get_struct_3d().pack(_x.x, _x.y, _x.z))
          buff.write(_v24.covariance.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
    """
    try:
      if self.header is None:
        self.header = std_msgs.msg.Header()
      if self.trajectories is None:
        self.trajectories = None
      end = 0
      _x = self
      start = end
      end += 12
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.header.frame_id = str[start:end].decode('utf-8')
      else:
        self.header.frame_id = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.trajectories = []
      for i in range(0, length):
        val1 = frame_msgs.msg.PersonTrajectory()
        start = end
        end += 8
        (val1.track_id,) = _get_struct_Q().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.trajectory = []
        for i in range(0, length):
          val2 = frame_msgs.msg.PersonTrajectoryEntry()
          _v28 = val2.age
          _x = _v28
          start = end
          end += 8
          (_x.secs, _x.nsecs,) = _get_struct_2i().unpack(str[start:end])
          _x = val2
          start = end
          end += 9
          (_x.is_occluded, _x.detection_id,) = _get_struct_BQ().unpack(str[start:end])
          val2.is_occluded = bool(val2.is_occluded)
          _v29 = val2.pose
          _v30 = _v29.pose
          _v31 = _v30.position
          _x = _v31
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          _v32 = _v30.orientation
          _x = _v32
          start = end
          end += 32
          (_x.x, _x.y, _x.z, _x.w,) = _get_struct_4d().unpack(str[start:end])
          start = end
          end += 288
          _v29.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=36)
          _v33 = val2.twist
          _v34 = _v33.twist
          _v35 = _v34.linear
          _x = _v35
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          _v36 = _v34.angular
          _x = _v36
          start = end
          end += 24
          (_x.x, _x.y, _x.z,) = _get_struct_3d().unpack(str[start:end])
          start = end
          end += 288
          _v33.covariance = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=36)
          val1.trajectory.append(val2)
        self.trajectories.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_36d = None
def _get_struct_36d():
    global _struct_36d
    if _struct_36d is None:
        _struct_36d = struct.Struct("<36d")
    return _struct_36d
_struct_Q = None
def _get_struct_Q():
    global _struct_Q
    if _struct_Q is None:
        _struct_Q = struct.Struct("<Q")
    return _struct_Q
_struct_3I = None
def _get_struct_3I():
    global _struct_3I
    if _struct_3I is None:
        _struct_3I = struct.Struct("<3I")
    return _struct_3I
_struct_BQ = None
def _get_struct_BQ():
    global _struct_BQ
    if _struct_BQ is None:
        _struct_BQ = struct.Struct("<BQ")
    return _struct_BQ
_struct_4d = None
def _get_struct_4d():
    global _struct_4d
    if _struct_4d is None:
        _struct_4d = struct.Struct("<4d")
    return _struct_4d
_struct_2i = None
def _get_struct_2i():
    global _struct_2i
    if _struct_2i is None:
        _struct_2i = struct.Struct("<2i")
    return _struct_2i
_struct_3d = None
def _get_struct_3d():
    global _struct_3d
    if _struct_3d is None:
        _struct_3d = struct.Struct("<3d")
    return _struct_3d
