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 The main entry-point to rxbag.
00036 """
00037
00038 PKG = 'rxbag'
00039 import roslib; roslib.load_manifest(PKG)
00040 import rospy
00041
00042 import optparse
00043 import sys
00044 import threading
00045 import time
00046
00047
00048 import wxversion
00049 WXVER = '2.8'
00050 if wxversion.checkInstalled(WXVER):
00051 wxversion.select(WXVER)
00052 else:
00053 print >> sys.stderr, 'This application requires wxPython version %s' % WXVER
00054 sys.exit(1)
00055 import wx
00056 import wx.lib.wxcairo
00057 if 'wxGTK' in wx.PlatformInfo:
00058
00059 import ctypes
00060 gdkLib = wx.lib.wxcairo._findGDKLib()
00061 gdkLib.gdk_cairo_create.restype = ctypes.c_void_p
00062
00063 import rxbag_app
00064
00065 def run(options, args):
00066 app = rxbag_app.RxBagApp(options, args)
00067 app.MainLoop()
00068 rospy.signal_shutdown('GUI shutdown')
00069
00070 def rxbag_main():
00071
00072 parser = optparse.OptionParser(usage='usage: %prog [options] BAG_FILE1 [BAG_FILE2 ...]')
00073 parser.add_option('-s', '--start', dest='start', default=0.0, action='store', type='float', help='start SEC seconds into the bag files', metavar='SEC')
00074 parser.add_option( '--record', dest='record', default=False, action='store_true', help='record to a bag file')
00075 parser.add_option('-a', '--all', dest='all', default=False, action='store_true', help='record all topics')
00076 parser.add_option('-e', '--regex', dest='regex', default=False, action="store_true", help='match topics using regular expressions')
00077 parser.add_option('-o', '--output-prefix', dest='prefix', default=None, action="store", help='prepend PREFIX to beginning of bag name (name will always end with date stamp)')
00078 parser.add_option('-O', '--output-name', dest='name', default=None, action="store", help='record to bag with name NAME.bag')
00079 parser.add_option('-l', '--limit', dest='limit', default=0, action="store", type='int', help='only record NUM messages on each topic', metavar='NUM')
00080 parser.add_option( '--profile', dest='profile', default=False, action='store_true', help='profile and write results to rxbag.prof [advanced]')
00081
00082 options, args = parser.parse_args(sys.argv[1:])
00083
00084 if len(args) == 0:
00085 if options.record:
00086 if not options.all:
00087 parser.error('You must specify topics to record when recording (or specify --all).')
00088 else:
00089 parser.error('You must specify at least one bag file to view.')
00090
00091 if options.prefix and options.name:
00092 parser.error('Can\'t set both prefix and name.')
00093
00094 if options.profile:
00095 import cProfile
00096 cProfile.runctx('run(options, args)', globals(), locals(), 'rxbag.prof')
00097 else:
00098 run(options, args)