frame_viewer.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 #***********************************************************
00003 #* Software License Agreement (BSD License)
00004 #*
00005 #*  Copyright (c) 2009, Willow Garage, Inc.
00006 #*  All rights reserved.
00007 #*
00008 #*  Redistribution and use in source and binary forms, with or without
00009 #*  modification, are permitted provided that the following conditions
00010 #*  are met:
00011 #*
00012 #*   * Redistributions of source code must retain the above copyright
00013 #*     notice, this list of conditions and the following disclaimer.
00014 #*   * Redistributions in binary form must reproduce the above
00015 #*     copyright notice, this list of conditions and the following
00016 #*     disclaimer in the documentation and/or other materials provided
00017 #*     with the distribution.
00018 #*   * Neither the name of Willow Garage, Inc. nor the names of its
00019 #*     contributors may be used to endorse or promote products derived
00020 #*     from this software without specific prior written permission.
00021 #*
00022 #*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 #*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 #*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 #*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 #*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 #*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 #*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 #*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 #*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 #*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 #*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 #*  POSSIBILITY OF SUCH DAMAGE.
00034 #* 
00035 #* Author: Eitan Marder-Eppstein
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         # Create menu
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')
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


tf2_visualization
Author(s): Wim Meeussen
autogenerated on Mon Aug 19 2013 11:37:23