def quat_to_list(quat):
    """
    convert a geometry_msgs/Quaternion or numpy.ndarray in list [x, y, z, w]
    :param quat:  a geometry_msgs/Quaternion or numpy.ndarray
    :return: the corresponding quaternion [x, y, z, w]
    """
    if isinstance(quat, Quaternion):
        return [quat.x, quat.y, quat.z, quat.w]
    elif isinstance(quat, ndarray):
        return [quat[0], quat[1], quat[2], quat[3]]
    else:
        raise Exception("quat_to_list expects Quaternion only but received {}".
                        format(str(type(quat))))
convert a geometry_msgs/Quaternion or numpy.ndarray in list [x, y, z, w]
    :param quat:  a geometry_msgs/Quaternion or numpy.ndarray
    :return: the corresponding quaternion [x, y, z, w]