def get_imu_tum_data(object, start, end):
    """
    Returns imu and tum data of camera in file formatted strings
    """

    if object.animation_data is None:
        raise Exception(f"{object.name} has no animation data")

    if object.animation_data.action is None:
        raise Exception(f"{object.name} has no action")

    start = ceil(start)
    end = floor(end)
    length = end - start + 1

    if length <= 1:
        raise Exception(f"trajectory duration is too short: {length} frames")

    old_rotation = object.rotation_mode
    object.rotation_mode = "XYZ"

    ax, ay, az, rvx, rvy, rvz = (
        np.zeros(length),
        np.zeros(length),
        np.zeros(length),
        np.zeros(length),
        np.zeros(length),
        np.zeros(length),
    )
    x, y, z, rx, ry, rz = None, None, None, None, None, None

    # find data
    for curve in object.animation_data.action.fcurves:
        if curve.data_path == "location":
            if curve.array_index == 0:
                ax, x = data_from_keyframes(curve.keyframe_points, start, end, True)
            elif curve.array_index == 1:
                ay, y = data_from_keyframes(curve.keyframe_points, start, end, True)
            elif curve.array_index == 2:
                az, z = data_from_keyframes(curve.keyframe_points, start, end, True)

        elif curve.data_path == "rotation_euler":
            if curve.array_index == 0:
                rvx, rx = data_from_keyframes(curve.keyframe_points, start, end, False)
            elif curve.array_index == 1:
                rvy, ry = data_from_keyframes(curve.keyframe_points, start, end, False)
            elif curve.array_index == 2:
                rvz, rz = data_from_keyframes(curve.keyframe_points, start, end, False)

        else:
            raise Exception("Unsupported action fcurve: {}".format(curve.data_path))

    SMALL = float(1e-4)

    # check data accuracy
    for i in range(length):
        bpy.context.scene.frame_set(i + start)
        if x is not None:
            if abs(x[i] - object.location[0]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for x translation {} vs {}".format(
                        i, x[i], object.location[0]
                    )
                )
        if y is not None:
            if abs(y[i] - object.location[1]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for y translation {} vs {}".format(
                        i, y[i], object.location[1]
                    )
                )
        if z is not None:
            if abs(z[i] - object.location[2]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for z translation {} vs {}".format(
                        i, z[i], object.location[2]
                    )
                )
        if rx is not None:
            if abs(rx[i] - object.rotation_euler[0]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for x Euler rotation {} vs {}".format(
                        i, rx[i], object.rotation_euler[0]
                    )
                )
        if ry is not None:
            if abs(ry[i] - object.rotation_euler[1]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for y Euler rotation {} vs {}".format(
                        i, ry[i], object.rotation_euler[1]
                    )
                )
        if rz is not None:
            if abs(rz[i] - object.rotation_euler[2]) > SMALL:
                raise Exception(
                    "Bezier interpolation innacurate at frame {} for z Euler rotation {} vs {}".format(
                        i, rz[i], object.rotation_euler[2]
                    )
                )

    imu_text = []
    tum_text = []
    object.rotation_mode = "QUATERNION"

    # format data
    for i in range(length):
        bpy.context.scene.frame_set(i + start)
        imu_text.append(
            " ".join(
                [
                    str(i + start),
                    str(rvx[i]),
                    str(rvy[i]),
                    str(rvz[i]),
                    str(ax[i]),
                    str(ay[i]),
                    str(az[i]),
                ]
            )
        )
        tum_text.append(
            " ".join(
                [
                    str(i + start),
                    str(object.location[0]),
                    str(object.location[1]),
                    str(object.location[2]),
                    str(object.rotation_quaternion[1]),
                    str(object.rotation_quaternion[2]),
                    str(object.rotation_quaternion[3]),
                    str(object.rotation_quaternion[0]),
                ]
            )
        )

    object.rotation_mode = old_rotation
    return "\n".join(imu_text), "\n".join(tum_text)

    Returns imu and tum data of camera in file formatted strings
    
infinigen/core/util/imu.py