Go to the documentation of this file.00001
00002 """
00003 bags_to_database.py
00004 Mac Mason <mmason@willowgarage.com>
00005
00006 We collect bag files; we want to process them into a database. So, this does
00007 that.
00008 """
00009
00010 import os
00011 import sys
00012 import signal
00013 import time
00014 import subprocess
00015
00016 def handler(signum, frame):
00017 global RL
00018 global RB
00019
00020 if RL:
00021 RL.kill()
00022 if RB:
00023 RB.kill()
00024
00025 signal.signal(signal.SIGTERM, handler)
00026
00027 M = "** We assume that playbag.launch will run, and record to the database\n"\
00028 "** you want it to. Starting the roscore, etc. that you need for that\n"\
00029 "** to work is your problem. Enjoy!\n"
00030
00031 print M
00032
00033 if len(sys.argv) < 2:
00034 print "Usage: bags_to_database.py <one or more bagfiles>"
00035 sys.exit(1)
00036
00037
00038 for filename in sys.argv[1:]:
00039 try:
00040 os.stat(filename)
00041 except OSError:
00042 print "File '" + filename + "' does not exist!"
00043
00044
00045
00046
00047
00048
00049 for bagfile in sys.argv[1:]:
00050 global RL
00051 global RB
00052
00053 RL = subprocess.Popen(['roslaunch',
00054 'semanticmodel',
00055 'go.launch',
00056 'gui:=false',
00057 'playbag:=true',
00058 'run_local_db:=true',
00059 'overwrite_local_db:=false'],
00060 stdin=None, stdout=None, stderr=None,
00061 env=os.environ)
00062
00063 print "launched for", bagfile
00064
00065
00066 time.sleep(15.0)
00067
00068
00069 RB = subprocess.check_call(['rosrun',
00070 'semanticmodel',
00071 'playbag.sh',
00072 bagfile],
00073 stdin=None, stdout=None, stderr=None,
00074 env=os.environ)
00075
00076 print "played for", bagfile
00077
00078
00079 time.sleep(60)
00080
00081
00082 RL.terminate()
00083
00084
00085 time.sleep(15.0)
00086
00087
00088