relay_screenshot.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 Call snapshot service of rviz (provided by ScreenshotListener tool)
00004 when a topic is published.
00005 
00006 This script is useful to automatically record result of ros processing.
00007 
00008 NOTE:
00009   rviz should be in fron of other windows because 
00010 """
00011 
00012 import rospy
00013 from jsk_rviz_plugins.srv import Screenshot
00014 
00015 def callback(msg):
00016     global counter
00017     rospy.loginfo('received a message, save a screenshot to {0}'.format(file_format.format(counter)))
00018     try:
00019         screenshot_srv(file_format.format(counter))
00020         counter = counter + 1
00021     except rospy.ServiceException, e:
00022         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))
00023         
00024     
00025 if __name__ == '__main__':
00026     counter = 0
00027     rospy.init_node('relay_screenshot')
00028     screenshot_srv = rospy.ServiceProxy('/rviz/screenshot', Screenshot)
00029     file_format = rospy.get_param('~file_format', 'rviz_screenshot_{0:0>5}.png')
00030     sub = rospy.Subscriber('~input', rospy.msg.AnyMsg, callback)
00031     rospy.spin()


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Wed May 1 2019 02:40:22