qualify.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2008, 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 the Willow Garage 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 Kevin Watts
00036 ##\brief Loads qualification GUI for component qualification
00037 
00038 PKG = 'qualification'
00039 import roslib
00040 roslib.load_manifest(PKG)
00041 
00042 from roslaunch_caller import roslaunch_caller 
00043 
00044 import wx
00045 import sys, os
00046 import rospy
00047 import traceback
00048 
00049 ## Starts roscore, qualification app for components
00050 class QualificationApp(wx.App):
00051     def OnInit(self):
00052         try:
00053             self._core_launcher = roslaunch_caller.launch_core()
00054         except Exception, e:
00055             print >> sys.stderr, 'Failed to launch core. Another core may already be running.\n\n'
00056             wx.MessageBox('A ROS core is still running and preventing the qualification system from starting. Shut down ROS processes by using the "Kill ROS" icon.','ROS Already Running', wx.OK|wx.ICON_ERROR, None)
00057             traceback.print_exc()
00058             sys.exit(1)
00059 
00060         # Check that we can write our results into temporary, permenant files
00061         from qualification.result_dir import check_qual_result_dir, check_qual_temp_dir
00062         if not check_qual_temp_dir():
00063             wx.MessageBox("Unable to write to the temporary results directory. This will cause weird problems. Open a terminal and type, \"sudo rm /tmp/* -rf\" to remove the offending directory. You will have to restart the qualification system.", 
00064                           "Unable to Write Results", wx.OK|wx.ICON_ERROR, None)
00065             sys.exit(1)
00066 
00067         if not check_qual_result_dir():
00068             wx.MessageBox("Unable to write to the \"~/wg_hardware_test/qualification\" directory. Open a terminal and type, \"sudo chmod +rwx -R ~/wg_hardware_test/qualification\" to fix the offending directory. You will have to restart the qualification system.", 
00069                           "Unable to Write Results", wx.OK|wx.ICON_ERROR, None)
00070             sys.exit(1)
00071 
00072         
00073         rospy.init_node("qualification")
00074         
00075         img_path = os.path.join(roslib.packages.get_pkg_dir(PKG), 'xrc', 'splash.jpg')
00076         
00077         bitmap = wx.Bitmap(img_path, type=wx.BITMAP_TYPE_JPEG)
00078         self._splash = wx.SplashScreen(bitmap, wx.SPLASH_CENTRE_ON_SCREEN, 30000, None, -1)
00079         
00080         import qualification.component_qual
00081 
00082         qual_options = qualification.component_qual.ComponentQualOptions()
00083         if len(sys.argv) > 1 and sys.argv[1] == '--debug':
00084             qual_options.debug = True
00085 
00086         self._frame = qualification.component_qual.ComponentQualFrame(None, qual_options)
00087         self._frame.SetSize(wx.Size(700,1000))
00088         self._frame.Layout()
00089         self._frame.Centre()
00090         
00091         self._splash.Destroy()
00092         self._splash = None
00093         
00094         self._frame.Show(True)
00095         
00096         return True
00097 
00098     def OnExit(self):
00099         self._core_launcher.stop()
00100         
00101         if self._splash:
00102             self._splash.Destroy()
00103 
00104 if __name__ == '__main__':
00105     os.environ['ROSLAUNCH_SSH_UNKNOWN'] = '1'
00106     try:
00107         app = QualificationApp()
00108         app.MainLoop()
00109     except Exception, e:
00110         print >> sys.stderr, "Caught exception in Qualification App Main Loop"
00111         import traceback
00112         traceback.print_exc()


qualification
Author(s): Kevin Watts (watts@willowgarage.com), Josh Faust (jfaust@willowgarage.com)
autogenerated on Sat Dec 28 2013 17:57:34