<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:macro name="imu" params="name parent xyz rpy frequency topic">

        <link name="${name}_link">
            <inertial>
                <mass value="0.01"/>
                <inertia 
                    ixx="0.001828"
                    ixy="0.0"
                    ixz="0.0"
                    iyy="0.001828"
                    iyz="0.0"
                    izz="0.003528"
                />
            </inertial>
        </link>
        <joint name="${name}_joint" type="fixed">
            <parent link="${parent}_link"/>
            <child link="${name}_link"/>
            <origin xyz="${xyz}" rpy="${rpy}"/>
        </joint>
        <gazebo reference="${name}_link">
            <sensor name="${name}" type="imu">
                <always_on>1</always_on>
                <update_rate>${frequency}</update_rate>
                <gz_frame_id>${name}_link</gz_frame_id>
                <visualize>true</visualize>
                <topic>${topic}</topic>
            </sensor>
        </gazebo>
    </xacro:macro>
</robot>