def animate_wiggle_bones(
    arma, bones, mag_deg, freq, off=0, wavelength=1, remove_iks=True
):
    """
    mag_deg = sum of magnitudes across al bones
    freq = flaps per second
    off = global time offset
    wavelength = how many flaps fit into one creature

    """

    logger.debug(f"animate_wiggle_bones on {len(bones)=} {mag_deg=}")

    # remove any iks, we will be overriding them
    if remove_iks:
        remove_ik_constraints(bones)

    mag = np.deg2rad(mag_deg) / len(bones)
    frame_period = int(bpy.context.scene.render.fps / freq)

    for i, b in enumerate(bones):
        b_off = -(off + i / len(bones)) * frame_period / wavelength
        b.rotation_mode = "XYZ"
        sinusoid_driver(b.driver_add("rotation_euler")[0].driver, mag, freq, b_off)

    mag_deg = sum of magnitudes across al bones
    freq = flaps per second
    off = global time offset
    wavelength = how many flaps fit into one creature

    
infinigen/assets/objects/creatures/util/animation/driver_wiggle.py