def resample(motion, fps):
    """
    Upsample/downsample frame rate of motion object to `fps` Hz. For
    upsampling, poses are interpolated using `Pose.interpolate` method to
    fill in the gaps.

    Args:
        motion: Motion sequence to be resampled
        fps: Frequency of motion desired
    """
    poses_new = []

    dt = 1.0 / fps
    t = 0
    while t < motion.fps * len(motion.poses):
        pose = motion.get_pose_by_time(t)
        pose.skel = motion.skel
        poses_new.append(pose)
        t += dt

    motion.poses = poses_new
    motion.fps = fps
    return motion