Ejemplo n.º 1
0
def main():
    # Parse all command line arguments.
    arg_parser = argparse.ArgumentParser(description='Log Plotter')
    arg_parser.add_argument('log_file', metavar='LOG_FILE', type=str, \
        help='The file from which to read logs and plot.')
    arg_parser.add_argument('--plot-defs', '-p', action='store', type=str, \
        help='Read the items to plot from this file.')
    arg_parser.add_argument('--no-binary', '-n', action='store_true', \
        help='Don\'t print the binary name in the legend.')

    args = arg_parser.parse_args(sys.argv[1:])

    p = Plotter()

    # If the user defines the list of data to plot in a file, read it from there.
    if args.plot_defs:
        defs = ReadPlotDefinitions(args.plot_defs)
        for definition in defs:
            p.Add(definition[0], definition[1], *definition[2:])

    # Otherwise use a pre-defined set of data to plot.
    else:
        p.Add('fridge', 'goal', 'height')
        p.Add('fridge', 'goal', 'angle')
        p.Add('fridge', 'goal', 'velocity')
        p.Add('fridge', 'goal', 'angular_velocity')

        p.Add('fridge', 'output', 'left_arm')
        p.Add('fridge', 'output', 'right_arm')
        p.Add('fridge', 'output', 'left_elevator')
        p.Add('fridge', 'output', 'right_elevator')

    p.PlotFile(args.log_file, args.no_binary)