Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 import roslib; roslib.load_manifest('tf2_visualization')
00038 import rospy
00039 
00040 import wxversion
00041 import sys
00042 WXVER = '2.8'
00043 if wxversion.checkInstalled(WXVER):
00044     wxversion.select(WXVER)
00045 else:
00046     print >> sys.stderr, 'This application requires wxPython version %s' % WXVER
00047     sys.exit(1)
00048 
00049 import wx
00050 import wx.richtext
00051 import xdot
00052 import threading
00053 import yaml
00054 from tf2_msgs.srv import FrameGraph, FrameGraphResponse
00055 import tf2_ros
00056 import os
00057 
00058 import rosgraph.masterapi
00059 
00060 from tf2_visualization.frame_viewer_panel import FrameViewerPanel
00061 from tf2_visualization.tf_interface import TFInterface
00062 
00063 class FrameViewerFrame(wx.Frame):
00064     def __init__(self, tf_interface):
00065         wx.Frame.__init__(self, None, -1, "Frame Viewer", size=(1024,768))
00066 
00067         self.viewer = FrameViewerPanel(self, tf_interface)
00068 
00069         
00070         menubar = wx.MenuBar()
00071         file = wx.Menu()
00072         file.Append(101, '&Load', 'Load a frame_viewer snapshot')
00073         file.Append(102, '&Save', 'Save a frame_viewer snapshot')
00074         file.Append(103, '&Export PDF', 'Export To PDF')
00075         menubar.Append(file, '&File')
00076         self.SetMenuBar(menubar)
00077        
00078         wx.EVT_MENU(self, 101, self.onLoad)
00079         wx.EVT_MENU(self, 102, self.onSave)
00080         wx.EVT_MENU(self, 103, self.onPDF)
00081 
00082     def onLoad(self, event): self.viewer.update_file_list(wx.LoadFileSelector("TF Snapshot", ".tf"))
00083     def onSave(self, event): self.viewer.tf_interface.save_yaml(wx.SaveFileSelector("TF Snapshot", ".tf"))
00084     def onPDF(self, event): self.viewer.tf_interface.save_pdf(wx.SaveFileSelector("PDF Export", ".pdf"))
00085 
00086 class FrameViewerApp(wx.App):
00087     def __init__(self):
00088         wx.App.__init__(self)
00089 
00090     def OnInit(self):
00091         self.tf_interface = TFInterface()
00092         self.frame = FrameViewerFrame(self.tf_interface)
00093         self.frame.Show()
00094         return True
00095 
00096 def main():
00097     app = FrameViewerApp()
00098     app.MainLoop()
00099 
00100 if __name__ == '__main__':
00101     rospy.init_node('frame_viewer', anonymous=False, disable_signals=True, log_level=rospy.DEBUG)
00102     main()
00103     rospy.signal_shutdown('GUI shutdown')