Ask Your Question

Revision history [back]

I think, what coul happen is: Once you terminate, rospy.is_shutdown() is False. And the currently waiting rate.sleep() is also terminated. But your for-loop still runs into the next rate.sleep(). You could do something like:

while not rospy.is_shutdown():
    for i, filename in enumerate(sort_images, 0):
        print("Publish Image with Name: %s" %os.path.basename(filename))
        rate.sleep()
        if rospy.is_shutdown():
            break

Let me know if it worked