3 Call snapshot service of rviz (provided by ScreenshotListener tool) 
    4 when a topic is published. 
    6 This script is useful to automatically record result of ros processing. 
    9   rviz should be in fron of other windows because  
   13 from jsk_rviz_plugins.srv 
import Screenshot
 
   17     rospy.loginfo(
'received a message, save a screenshot to {0}'.format(file_format.format(counter)))
 
   21     except rospy.ServiceException 
as e:
 
   22         rospy.logerr(
'Failed to call screenshot service call. Have you add ScreenshotListener to rviz and file_format is correct? file_format is "{0}"'.format(file_format))
 
   25 if __name__ == 
'__main__':
 
   27     rospy.init_node(
'relay_screenshot')
 
   28     screenshot_srv = rospy.ServiceProxy(
'/rviz/screenshot', Screenshot)
 
   29     file_format = rospy.get_param(
'~file_format', 
'rviz_screenshot_{0:0>5}.png')
 
   30     sub = rospy.Subscriber(
'~input', rospy.msg.AnyMsg, callback)