예제 #1
0
def main(args):
    ttc_logfile = load_log_csv(args.ttc_log_path)
    freefall_logfile = load_log_csv(args.freefall_log_path)

    ttc_logfile['legend'] = 'TTC'
    freefall_logfile['legend'] = 'Freefall'

    ax = plot_distance(pd.concat([ttc_logfile, freefall_logfile]),
                       hue='legend')
    plt.show()
예제 #2
0
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Oracle"]
    labels = ["Estimated TTC Control", "Oracle TTC Control"]

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, axes = plt.subplots(1, 2, figsize=(11, 4.8))
    for logfile, label in zip(logfiles, labels):
        for i, ax in enumerate(axes):
            ax.set_xlabel("Timestep", fontsize=16)
            if i == 0:
                sns.lineplot(x='Timestep', y='distance', data=logfile, ax=ax, label=label)
                ax.set_ylabel("Distance", fontsize=16)
                ax.yaxis.set_label_coords(-0.08, 0.5)
            else:
                logfile['actual_velocity_y'] *= -1
                sns.lineplot(x='Timestep', y='actual_velocity_y', data=logfile, ax=ax, label=label)
                ax.set_ylabel("Vertical Velocity", fontsize=16)
                ax.set_ylim(0, 2)
                ax.yaxis.set_label_coords(-0.12, 0.5)
            ax.xaxis.set_label_coords(0.5, -0.12)
            ax.legend(prop={"size": 14})
            ax.tick_params(axis='both', which='major', labelsize=12)
    plt.tight_layout()
    fig.subplots_adjust(left=0.057, wspace=0.193)
    plt.show(block=False)
    fig.savefig(os.path.join(root_dir, "compare_oracle.png"))
예제 #3
0
def main(args):
    Exs = load_pickle(os.path.join(args.logdir, 'Exs.npy'))
    Eys = load_pickle(os.path.join(args.logdir, 'Eys.npy'))
    Ets = load_pickle(os.path.join(args.logdir, 'Ets.npy'))
    logfile = load_log_csv(os.path.join(args.logdir, 'log.csv'))

    # Plot distance
    fig_distance, ax_distance = plt.subplots()
    plot_distance(logfile, ax=ax_distance)
    fig_distance.savefig(os.path.join(args.logdir, 'distance.jpg'))

    # Plot velocity
    fig_vel, ax_vel = plt.subplots()
    plot_vel(logfile, ax=ax_vel)
    fig_vel.savefig(os.path.join(args.logdir, 'actual_vel.jpg'))

    # Plot desired velocity
    fig_desired_vel, ax_desired_vel = plt.subplots()
    plot_desired_vel(logfile, ax=ax_desired_vel)
    fig_desired_vel.savefig(os.path.join(args.logdir,
                                         'actual_desired_vel.jpg'))

    # Plot ttc
    fig_ttc, ax_ttc = plt.subplots()
    plot_ttc(logfile, ax=ax_ttc, ylim=(0, 1000))
    fig_ttc.savefig(os.path.join(args.logdir, 'ttc.jpg'))

    # Plot derivatives
    if args.derivative_gif:
        plot_derivative_animation(Exs,
                                  Eys,
                                  Ets,
                                  output_path=os.path.join(
                                      args.logdir, 'derivatives.gif'))
예제 #4
0
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Dust", "Cloudy", "Windy", "RotationalLight"]
    labels = ["Basic", "Duststorm", "Cloudy", "Windy", "Rotational Light"]

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, ax = plt.subplots()
    for i, (logfile, label) in enumerate(zip(logfiles, labels)):
        logfile['actual_velocity_y'] *= -1
        sns.lineplot(x='Timestep', y='actual_velocity_y', data=logfile, ax=ax, label=label, zorder=len(labels)-i)
    ax.set_yscale("log")
    #ax.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
    ax.set_xlabel("Timestep", fontsize=16)
    ax.set_ylabel("Vertical Velocity (log-scale)", fontsize=16)
    ax.xaxis.set_label_coords(0.5, -0.12)
    ax.yaxis.set_label_coords(-0.08, 0.5)
    ax.legend(prop={"size": 14})
    ax.tick_params(axis='both', which='major', labelsize=12)
    plt.tight_layout()
    plt.show(block=False)
    fig.savefig(os.path.join(root_dir, "compare_velocity.pdf"))
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Dust", "Cloudy", "Windy", "RotationalLight"]
    labels = ["Basic", "Duststorm", "Cloudy", "Windy", "Rotational Light"]

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, axes = plt.subplots(1, 2, figsize=(11, 4.8))
    for i, (logfile, label) in enumerate(zip(logfiles, labels)):
        for j, ax in enumerate(axes):
            if j == 0:
                sns.lineplot(x='Timestep',
                             y='distance',
                             data=logfile,
                             ax=ax,
                             label=label)
            else:
                logfile['actual_velocity_y'] *= -1
                sns.lineplot(x='Timestep',
                             y='actual_velocity_y',
                             data=logfile,
                             ax=ax,
                             label=label,
                             zorder=len(labels) - i)
    for i, ax in enumerate(axes):
        if i == 0:
            ax.set_ylabel("Distance", fontsize=16)
            ax.set_xlabel("Timestep", fontsize=16)
            ax.legend(prop={"size": 14})
            ax.yaxis.set_label_coords(-0.08, 0.5)
        else:
            ax.set_yscale("log")
            ax.set_xlabel("Timestep", fontsize=16)
            ax.set_ylabel("Vertical Velocity (log-scale)", fontsize=16)
            ax.yaxis.set_label_coords(-0.12, 0.5)
            ax.get_legend().remove()
        ax.tick_params(axis='both', which='major', labelsize=12)
        ax.xaxis.set_label_coords(0.5, -0.12)
    plt.tight_layout()
    plt.show(block=False)
    fig.savefig(os.path.join(root_dir, "compare_distance_and_velocity.pdf"))
예제 #6
0
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Dust", "Cloudy", "Windy", "RotationalLight"]
    labels = ["Basic", "Duststorm", "Cloudy", "Windy", "Rotational Light"]
    running_window_size = 50
    time_interval = 50

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, axes = plt.subplots(1, 5, figsize=(20,4), sharey=True)
    running_window_low = running_window_size // 2
    running_window_high = running_window_size - running_window_low
    for i, (logfile, label, ax) in enumerate(zip(logfiles, labels, axes)):
        ttc = logfile['TTC'].to_numpy() / time_interval
        N = len(logfile['Timestep'])
        running_mean, running_std = [], []
        for n in range(N):
            low = max(0, n-running_window_low)
            high = min(N, n+running_window_high)
            running_mean.append(np.mean(ttc[low:high]))
            running_std.append(np.std(ttc[low:high]))
        running_mean, running_std = np.array(running_mean), np.array(running_std)
        gt_ttc = logfile['distance'].to_numpy() / -logfile['actual_velocity_y'].to_numpy()
        ax.plot(logfile['Timestep'], gt_ttc, color='gray', label='Ground Truth')
        ax.plot(logfile['Timestep'], running_mean, color=sns.color_palette()[i])
        ax.fill_between(logfile['Timestep'], running_mean - running_std, running_mean + running_std, 
                        alpha=.3, color=sns.color_palette()[i])
        
        ax.set_title(label, fontsize=16)
        ax.set_xlabel("Timestep", fontsize=16)
        if i == 0:
            ax.set_ylabel("TTC", fontsize=16)
            ax.yaxis.set_label_coords(-0.12, 0.5)
            ax.legend(prop={"size": 12})
        ax.xaxis.set_label_coords(0.5, -0.12)
        ax.tick_params(axis='both', which='major', labelsize=12)
        ax.set_ylim(0, 30)
    plt.tight_layout()
    fig.subplots_adjust(left=0.043)
    plt.show(block=False)
    fig.savefig(os.path.join(root_dir, "compare_ttc.pdf"))
예제 #7
0
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Dust", "Cloudy", "Windy", "RotationalLight"]
    labels = ["Basic", "Duststorm", "Cloudy", "Windy", "Rotational Light"]

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, ax = plt.subplots()
    for logfile, label in zip(logfiles, labels):
        sns.lineplot(x='Timestep', y='distance', data=logfile, ax=ax, label=label)
    ax.set_xlabel("Timestep", fontsize=16)
    ax.set_ylabel("Distance", fontsize=16)
    ax.xaxis.set_label_coords(0.5, -0.12)
    ax.yaxis.set_label_coords(-0.08, 0.5)
    ax.legend(prop={"size": 14})
    ax.tick_params(axis='both', which='major', labelsize=12)
    plt.tight_layout()
    plt.show(block=False)
    fig.savefig(os.path.join(root_dir, "compare_distance.pdf"))
예제 #8
0
def main():
    root_dir = "../results_ver2"
    variants = ["Basic", "Dust", "Cloudy", "Windy", "RotationalLight"]
    labels = ["Basic", "Duststorm", "Cloudy", "Windy", "Rotational Light"]
    avg_window_size = 20
    dt = 1. / 50

    logfiles = []
    for var in variants:
        fpath = os.path.join(root_dir, var, "log.csv")
        logfiles.append(load_log_csv(fpath))

    fig, ax = plt.subplots()
    for logfile, label in zip(logfiles, labels):
        N = len(logfile['Timestep']) - 1
        reach_time = logfile['Timestep'][N]
        velo = logfile['actual_velocity_y'][N - avg_window_size -
                                            1:N].to_numpy()
        acc = (velo[1:] - velo[:-1]) / dt
        #acc_mean, acc_std = acc.mean(), acc.std()
        #ax.scatter(reach_time, acc_mean, s=np.sqrt(acc_std*1E5), label=label)
        velo_mean, velo_std = velo.mean(), velo.std()
        ax.scatter(reach_time,
                   velo_mean,
                   s=np.sqrt(velo_std * 1E5),
                   label=label)
    ax.set_xlabel("Landing Time", fontsize=16)
    ax.set_ylabel("Landing Strength", fontsize=16)
    ax.xaxis.set_label_coords(0.5, -0.12)
    ax.yaxis.set_label_coords(-0.08, 0.5)
    ax.legend(prop={"size": 14})
    ax.tick_params(axis='both', which='major', labelsize=12)
    plt.tight_layout()
    plt.show(block=False)
    import pdb
    pdb.set_trace()
예제 #9
0
def main(args):
    logfile = load_log_csv(args.log_path)
    ax = plot_vel(logfile)
    plt.show()
예제 #10
0
def main(args):
    logfile = load_log_csv(args.log_path)
    ax = plot_ttc(logfile, ylim=(0, 200))
    plt.show()