def main(argv): """ Main node """ node = cyber.Node("rtk_recorder") argv = FLAGS(argv) log_dir = "/apollo/data/log" if len(argv) > 1: log_dir = argv[1] if not os.path.exists(log_dir): os.makedirs(log_dir) Logger.config(log_file=log_dir + "rtk_recorder.log", use_stdout=True, log_level=logging.DEBUG) print("runtime log is in %s%s" % (log_dir, "rtk_recorder.log")) record_file = log_dir + "/garage.csv" recorder = RtkRecord(record_file) atexit.register(recorder.shutdown) node.create_reader('/apollo/canbus/chassis', chassis_pb2.Chassis, recorder.chassis_callback) node.create_reader('/apollo/localization/pose', localization_pb2.LocalizationEstimate, recorder.localization_callback) while not cyber.is_shutdown(): time.sleep(0.002)
def main(argv): """ Main rosnode """ rospy.init_node('rtk_recorder', anonymous=True) argv = FLAGS(argv) log_dir = os.path.dirname( os.path.abspath(__file__)) + "/../../../data/log/" if not os.path.exists(log_dir): os.makedirs(log_dir) Logger.config(log_file=log_dir + "rtk_recorder.log", use_stdout=True, log_level=logging.DEBUG) print("runtime log is in %s%s" % (log_dir, "rtk_recorder.log")) record_file = log_dir + "/garage.csv" recorder = RtkRecord(record_file) atexit.register(recorder.shutdown) rospy.Subscriber('/apollo/canbus/chassis', chassis_pb2.Chassis, recorder.chassis_callback) rospy.Subscriber('/apollo/localization/pose', localization_pb2.LocalizationEstimate, recorder.localization_callback) rospy.spin()
def main(argv): try: # parse flags argv = FLAGS(argv) except gflags.FlagsError as e: print('%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS)) sys.exit(1) if FLAGS.debug: print('non-flag arguments:', argv) # retrieve all the files to be processed all_files = find_files(FLAGS.inpath) # define pandas dataframe df = pd.DataFrame(columns=('patientID', 'xrayDateTime', 'gender', 'path')) pbar = progressbar.ProgressBar(maxval=len(all_files)) pbar.start() for i, name in enumerate(all_files): # run image processing new_image, all_images = cxv.run_system(name, FLAGS.clean) write_name = name.replace(FLAGS.inpath, FLAGS.outpath) split_name = write_name.rsplit('/', 1)[0] if not os.path.exists(split_name): os.makedirs(split_name) io.imsave(write_name, new_image) # run OCR for hash patient_id, xray_datetime, gender = get_patient_info(all_images) df.loc[i] = [patient_id, xray_datetime, gender, write_name] # update progress bar pbar.update(i) pbar.finish() df.to_csv(FLAGS.outpath + '/labelled_info.csv')
def get_flags_help(): """Generates a help string for all known flags.""" help_items = [] # We don't use gflags own str(FLAGS) because we need some more control: # - we don't want gflags own SPECIAL flags (e.g. --undefok) # - we don't want a breakdown per module # pylint: disable=W0212 FLAGS._FlagValues__RenderFlagList(FLAGS.FlagDict().values(), help_items) def cleanup(help): "Removes the confusing --no prefix from boolean flags" if help.startswith(' --[no]'): return ' --' + help[8:] else: return help return '\n'.join([cleanup(help) for help in help_items])
def main(argv): FLAGS(argv) print(["Not treating", "Treating"][FLAGS.separate_new_conn], "starting a connective as its own transition") print(["Not treating", "Treating"][FLAGS.separate_shift], "completing a connective as its own transition") files_dir = argv[-1] reader = DirectoryReader((CausalityStandoffReader.FILE_PATTERN, ), CausalityStandoffReader(), True) reader.open(files_dir) writer = CausalityOracleTransitionWriter() for document in reader: # don't read whole corpus before outputting writer.open(splitext(document.filename)[0] + '.trans') writer.write_all_instances(document)
def main(argv): try: argv = FLAGS(argv) # parse flags iaa_paths = argv[1:] except FlagsError as e: print('%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS)) sys.exit(1) if not (FLAGS.iaa_log_differences or FLAGS.iaa_log_stats or FLAGS.iaa_log_confusion): print('Nothing to log for comparison') sys.exit(0) logging.basicConfig( format='%(filename)s:%(lineno)s:%(levelname)s: %(message)s', level=logging.WARN) logging.captureWarnings(True) reader = DirectoryReader(FLAGS.iaa_file_regexes, CausalityStandoffReader(), FLAGS.iaa_recurse) instances_by_path = [] for path in iaa_paths: reader.open(path) path_docs = reader.get_all()[:FLAGS.iaa_max_sentence] path_instances = list( itertools.chain.from_iterable(doc.sentences for doc in path_docs)) instances_by_path.append(path_instances) reader.close() instances_path_pairs = zip(instances_by_path, iaa_paths) for ((gold, gold_path), (predicted, predicted_path)) in (itertools.combinations(instances_path_pairs, 2)): print('%s vs. %s:' % (gold_path, predicted_path)) compare_instance_lists(gold, predicted, 1) print()
brake_data = compensate(BRAKE_LINE_DATA) brake_line.set_ydata(brake_data) throttle_data = compensate(TROTTLE_LINE_DATA) throttle_line.set_ydata(throttle_data) steering_data = compensate(STEERING_LINE_DATA) steering_line.set_ydata(steering_data) brake_text.set_text('brake = %.1f' % brake_data[-1]) throttle_text.set_text('throttle = %.1f' % throttle_data[-1]) steering_text.set_text('steering = %.1f' % steering_data[-1]) if __name__ == '__main__': argv = FLAGS(sys.argv) listener() fig, ax = plt.subplots() X = range(FLAGS.data_length) Xs = [i * -1 for i in X] Xs.sort() steering_line, = ax.plot( Xs, [0] * FLAGS.data_length, 'b', lw=3, alpha=0.5, label='steering') throttle_line, = ax.plot( Xs, [0] * FLAGS.data_length, 'g', lw=3, alpha=0.5, label='throttle') brake_line, = ax.plot( Xs, [0] * FLAGS.data_length, 'r', lw=3, alpha=0.5, label='brake') brake_text = ax.text(0.75, 0.85, '', transform=ax.transAxes) throttle_text = ax.text(0.75, 0.90, '', transform=ax.transAxes) steering_text = ax.text(0.75, 0.95, '', transform=ax.transAxes)
now = datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S") log_file = open(log_path + now + ".txt", "w") rospy.init_node(FLAGS.navigation_planning_node_name, anonymous=True) rospy.Subscriber('/apollo/sensor/mobileye', mobileye_pb2.Mobileye, mobileye_callback) rospy.Subscriber('/apollo/localization/pose', localization_pb2.LocalizationEstimate, localization_callback) rospy.Subscriber('/apollo/canbus/chassis', chassis_pb2.Chassis, chassis_callback) rospy.Subscriber('/apollo/navigation', navigation_pb2.NavigationInfo, routing_callback) planning_pub = rospy.Publisher(FLAGS.navigation_planning_topic, planning_pb2.ADCTrajectory, queue_size=1) if __name__ == '__main__': try: argv = FLAGS(sys.argv) # parse flags except gflags.FlagsError as e: print('%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS)) sys.exit(1) try: init() rospy.spin() finally: log_file.close()
def main(argv): """ Main function """ argv = FLAGS(argv) print """ Keyboard Shortcut: [q]: Quit Tool [s]: Save Figure [a]: Auto-adjust x, y axis to display entire plot [x]: Update Figure to Display last few Planning Trajectory instead of all [h][r]: Go back Home, Display all Planning Trajectory [f]: Toggle Full Screen [n]: Reset all Plots [b]: Unsubscribe Topics Legend Description: Red Line: Current Planning Trajectory Blue Line: Past Car Status History Green Line: Past Planning Target History at every Car Status Frame Cyan Dashed Line: Past Planning Trajectory Frames """ rospy.init_node('realtime_plot', anonymous=True) fig = plt.figure() ax1 = plt.subplot(2, 2, 1) item1 = Xyitem(ax1, WindowSize, VehicleLength, "Trajectory", "X [m]", "Y [m]") ax2 = plt.subplot(2, 2, 2) item2 = Item(ax2, "Speed", "Time [sec]", "Speed [m/s]", 0, 30) if not FLAGS.show_st_graph: ax3 = plt.subplot(2, 2, 3, sharex=ax2) item3 = Item(ax3, "Curvature", "Time [sec]", "Curvature [m-1]", -0.2, 0.2) else: ax3 = plt.subplot(2, 2, 3) item3 = Stitem(ax3, "ST Graph", "Time [sec]", "S [m]") ax4 = plt.subplot(2, 2, 4, sharex=ax2) if not FLAGS.show_heading: item4 = Item(ax4, "Acceleration", "Time [sec]", "Acceleration [m/sec^2]", -5, 5) else: item4 = Item(ax4, "Heading", "Time [sec]", "Heading [radian]", -4, 4) plt.tight_layout(pad=0.20) plt.ion() plt.show() prevtime = 0 plotter = Plotter(item1, item2, item3, item4) fig.canvas.mpl_connect('key_press_event', plotter.press) planning_sub = rospy.Subscriber('/apollo/planning', planning_pb2.ADCTrajectory, plotter.callback_planning, queue_size=3) localization_sub = rospy.Subscriber('/apollo/localization/pose', localization_pb2.LocalizationEstimate, plotter.callback_localization, queue_size=3) chassis_sub = rospy.Subscriber('/apollo/canbus/chassis', chassis_pb2.Chassis, plotter.callback_chassis, queue_size=3) plotter.updatesub(planning_sub, localization_sub, chassis_sub) r = rospy.Rate(5) while not rospy.is_shutdown(): ax1.draw_artist(ax1.patch) ax2.draw_artist(ax2.patch) ax3.draw_artist(ax3.patch) ax4.draw_artist(ax4.patch) with plotter.lock: item1.draw_lines() item2.draw_lines() item3.draw_lines() item4.draw_lines() fig.canvas.blit(ax1.bbox) fig.canvas.blit(ax2.bbox) fig.canvas.blit(ax3.bbox) fig.canvas.blit(ax4.bbox) fig.canvas.flush_events() r.sleep()
'Filter smaller connectives', remove_smaller_matches, lambda: PairwiseAndNonIAAEvaluator( False, False, FLAGS.filter_print_test_instances, True)) stages.append(smaller_filter_stage) return stages # def main(argv): if __name__ == '__main__': logging.basicConfig( format='%(filename)s:%(lineno)s:%(levelname)s: %(message)s', level=logging.INFO) logging.captureWarnings(True) try: FLAGS.Reset() FLAGS(sys.argv) # parse flags if not FLAGS.models_dir: FLAGS.models_dir = os.path.join('..', 'models', FLAGS.pipeline_type) # Print command line in case we ever want to re-run from output file print "Flags:" print_indented(1, FLAGS.FlagsIntoString()) print "Git info:" print_indented(1, subprocess.check_output("git rev-parse HEAD".split()), "Modified:", sep='') print_indented(2, subprocess.check_output("git ls-files -m".split())) print "Available filter features:" print_indented( 1, '\n'.join(sorted(e.name for e in CausalClassifierModel.all_feature_extractors)))