import dds
import ddsutil
import geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_
import geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_
import std_msgs/msg/Header_.std_msgs.msg.dds_
import struct

class Odometry___TypeSupport(dds.TypeSupport):

    _typename = 'nav_msgs::msg::dds_::Odometry_'
    _keylist = ''
    _metadescriptor = '<MetaData version="1.0.0"><Module name="geometry_msgs"><Module name="msg"><Module name="dds_"><Struct name="Point_"><Member name="x_"><Double/></Member><Member name="y_"><Double/></Member><Member name="z_"><Double/></Member></Struct><Struct name="Quaternion_"><Member name="x_"><Double/></Member><Member name="y_"><Double/></Member><Member name="z_"><Double/></Member><Member name="w_"><Double/></Member></Struct><Struct name="Vector3_"><Member name="x_"><Double/></Member><Member name="y_"><Double/></Member><Member name="z_"><Double/></Member></Struct><Struct name="Pose_"><Member name="position_"><Type name="Point_"/></Member><Member name="orientation_"><Type name="Quaternion_"/></Member></Struct><Struct name="Twist_"><Member name="linear_"><Type name="Vector3_"/></Member><Member name="angular_"><Type name="Vector3_"/></Member></Struct><Struct name="PoseWithCovariance_"><Member name="pose_"><Type name="Pose_"/></Member><Member name="covariance_"><Array size="36"><Double/></Array></Member></Struct><Struct name="TwistWithCovariance_"><Member name="twist_"><Type name="Twist_"/></Member><Member name="covariance_"><Array size="36"><Double/></Array></Member></Struct></Module></Module></Module><Module name="builtin_interfaces"><Module name="msg"><Module name="dds_"><Struct name="Time_"><Member name="sec_"><Long/></Member><Member name="nanosec_"><ULong/></Member></Struct></Module></Module></Module><Module name="std_msgs"><Module name="msg"><Module name="dds_"><Struct name="Header_"><Member name="stamp_"><Type name="::builtin_interfaces::msg::dds_::Time_"/></Member><Member name="frame_id_"><String/></Member></Struct></Module></Module></Module><Module name="nav_msgs"><Module name="msg"><Module name="dds_"><Struct name="Odometry_"><Member name="header_"><Type name="::std_msgs::msg::dds_::Header_"/></Member><Member name="child_frame_id_"><String/></Member><Member name="pose_"><Type name="::geometry_msgs::msg::dds_::PoseWithCovariance_"/></Member><Member name="twist_"><Type name="::geometry_msgs::msg::dds_::TwistWithCovariance_"/></Member></Struct></Module></Module></Module></MetaData>'

    def __init__(self):
        super(Odometry___TypeSupport, self).__init__(self._typename,
              self._keylist,
              self._metadescriptor,
              struct.calcsize(Odometry_()._get_packing_fmt()))

    def _serialize(self, o):
        if not isinstance(o, Odometry_):
            raise TypeError('Incorrect data type')
        result = o._serialize()
        return result

    def _deserialize(self, buf):
        result = Odometry_()
        data = struct.unpack(result._get_packing_fmt(), buf)
        result._deserialize(list(data))
        return result

class Odometry_(ddsutil.TopicDataClass):

    @staticmethod
    def get_type_support():
        ''' Return type support information required for dds.Topic constructor '''
        return Odometry___TypeSupport()

    @property
    def header_(self):
        '''
        a DDS std_msgs::msg::dds_::Header_ value
        @rtype: std_msgs/msg/Header_.std_msgs.msg.dds_.Header_
        '''
        return self._header__

    _header__checker = ddsutil._class_checker(std_msgs/msg/Header_.std_msgs.msg.dds_.Header_)
    @header_.setter
    def header_(self, value):
        self._header__checker(value)
        self._header__ = value

    @property
    def child_frame_id_(self):
        '''
        a DDS string value
        @rtype: str
        '''
        return self._child_frame_id__

    _child_frame_id__checker = ddsutil._str_checker
    @child_frame_id_.setter
    def child_frame_id_(self, value):
        self._child_frame_id__checker(value)
        self._child_frame_id__ = value

    @property
    def pose_(self):
        '''
        a DDS geometry_msgs::msg::dds_::PoseWithCovariance_ value
        @rtype: geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_.PoseWithCovariance_
        '''
        return self._pose__

    _pose__checker = ddsutil._class_checker(geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_.PoseWithCovariance_)
    @pose_.setter
    def pose_(self, value):
        self._pose__checker(value)
        self._pose__ = value

    @property
    def twist_(self):
        '''
        a DDS geometry_msgs::msg::dds_::TwistWithCovariance_ value
        @rtype: geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_.TwistWithCovariance_
        '''
        return self._twist__

    _twist__checker = ddsutil._class_checker(geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_.TwistWithCovariance_)
    @twist_.setter
    def twist_(self, value):
        self._twist__checker(value)
        self._twist__ = value

    _member_attributes = ('header_', 'child_frame_id_', 'pose_', 'twist_')

    def __init__(self, **kwargs):
        ''' Create a Odometry_ instance, optionally initializing fields by name '''
        # init attributes to default value
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()
        self.child_frame_id_ = ''
        self.pose_ = geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_.PoseWithCovariance_()
        self.twist_ = geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_.TwistWithCovariance_()
        # set values for attributes passed in
        for key, value in kwargs.items():
            if key not in self._member_attributes:
                raise TypeError('Invalid argument name : %s' %(key))
            setattr(self, key, value)

    _packing_fmt = None

    @staticmethod
    def _get_packing_fmt():
        ''' Returns packing format of this class data '''
        if Odometry_._packing_fmt is not None:
            return Odometry_._packing_fmt
        fmt = ''
        fmt += ddsutil._align(fmt, std_msgs/msg/Header_.std_msgs.msg.dds_.Header_._get_packing_fmt())
        fmt += 'P'
        fmt += ddsutil._align(fmt, geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_.PoseWithCovariance_._get_packing_fmt())
        fmt += ddsutil._align(fmt, geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_.TwistWithCovariance_._get_packing_fmt())

        Odometry_._packing_fmt = ddsutil._pad_fmt(fmt)
        return Odometry_._packing_fmt

    def _serialize(self):
        ''' Serialize data for writing '''
        fmt = self._get_packing_fmt()
        args = self._get_packing_args()
        result = struct.pack(fmt, *args)
        return result

    def _deserialize(self, data):
        ''' Initialize values from data returned by struct.unpack()'''
        self.header_ = std_msgs/msg/Header_.std_msgs.msg.dds_.Header_()._deserialize(data)
        self.child_frame_id_ = ddsutil._ptr_to_bytes(data.pop(0)).decode('ISO-8859-1')
        self.pose_ = geometry_msgs/msg/PoseWithCovariance_.geometry_msgs.msg.dds_.PoseWithCovariance_()._deserialize(data)
        self.twist_ = geometry_msgs/msg/TwistWithCovariance_.geometry_msgs.msg.dds_.TwistWithCovariance_()._deserialize(data)
        return self;

    def _get_packing_args(self):
        ''' Return an list of data suitable for struct.pack '''
        args = []
        args.extend(self.header_._get_packing_args())
        args.append(ddsutil._bytes_to_ptr(self.child_frame_id_.encode('ISO-8859-1')))
        args.extend(self.pose_._get_packing_args())
        args.extend(self.twist_._get_packing_args())
        return args

