def save_imu_tum_files(
    output_folder,
    objects: list[bpy.types.Object],
    start=bpy.context.scene.frame_start,
    end=bpy.context.scene.frame_end,
):
    """
    Write imu and tum data to output files for each object.
    """

    output_folder = Path(output_folder)
    output_folder.mkdir(exist_ok=True, parents=True)

    anim_objects = [x for x in objects if x.animation_data is not None]
    if len(anim_objects) == 0:
        logger.warning("save_imu_tum_files: No animation data in given objects")
        return

    for i in range(len(objects)):
        try:
            imu_text, tum_text = get_imu_tum_data(anim_objects[i], start, end)
            name = anim_objects[i].name.replace("/", "_")
        except Exception as e:
            logger.warning(
                f"Error when saving imu/tum data for {anim_objects[i].name}: {e}"
            )
            continue
        imu_file_name = output_folder / f"{name}_imu.txt"
        tum_file_name = output_folder / f"{name}_tum.txt"

        with open(imu_file_name, "w") as imu_file:
            imu_file.write(
                "#Format: timestamp angular velocity(x y z) linear acceleration(x y z)\n"
            )
            imu_file.write(imu_text)
            print(f"saved {imu_file_name}")
            logger.info(f"Saved IMU data for {anim_objects[i].name}")

        with open(tum_file_name, "w") as tum_file:
            tum_file.write("#Format: timestamp position(x y z) rotation(x y z w)\n")
            tum_file.write(tum_text)
            logger.info(f"Saved TUM data for {anim_objects[i].name}")

    Write imu and tum data to output files for each object.
    
infinigen/core/util/imu.py