<jupyter_start><jupyter_text>Load Variables<jupyter_code>df = pd.read_csv('carla_sim.csv')
t = df['time'].values
sp = df['sp_v'].values
gt = df['speed'].values
throttle = df['throttle'].values
brake = df['brake'].values
plt.plot(t, gt)
plt.plot(t, sp)<jupyter_output><empty_output><jupyter_text>PLOT<jupyter_code>def get_array_from_time_interval(x, t, T):
    t0 = min(T)
    t1 = max(T)
    i1 = -1
    i0 = 0
    for i in range(len(t)):
        if t0 <= t[i]:
            i0 = deepcopy(i)
            break
    for i in range(i0, len(t)):
        if t1 <= t[i]:
            i1 = deepcopy(i)
            break

    return x[i0:i1], t[i0:i1]<jupyter_output><empty_output><jupyter_text>Plot 1<jupyter_code>plt.plot(t, sp, label='Setpoint', zorder=2, color='black', linestyle='--')
plt.plot(t, gt, label='Response', zorder=1, color='red', linewidth=2.)

plt.xlabel('Time $(s)$')
plt.ylabel('Speed $(m/s)$')
plt.legend(fontsize=7)
plt.savefig(f'img/sim_result.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()
plt.plot(t, throttle, color='black', linewidth=0.5)

plt.xlabel('Time $(s)$')
plt.ylabel('Throttle')
plt.ylim([0,None])
plt.savefig(f'img/sim_result_throttle.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()<jupyter_output><empty_output><jupyter_text>Plot 2<jupyter_code>T = [0, 4.5]
NAME = 'r1'
l1, lt1 = get_array_from_time_interval(gt, t, T)
l2, lt2 = get_array_from_time_interval(sp, t, T)
l3, lt3 = get_array_from_time_interval(throttle, t, T)
plt.plot(lt2, l2, label='Setpoint', zorder=2, color='black', linestyle='--')
plt.plot(lt1, l1, label='Response', zorder=1, color='red', linewidth=2.)

plt.xlabel('Time $(s)$')
plt.ylabel('Speed $(m/s)$')
plt.legend(fontsize=7)
plt.savefig(f'img/{NAME}.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()
plt.plot(lt3, l3, color='black', linewidth=1.25)

plt.xlabel('Time $(s)$')
plt.ylabel('Throttle')
plt.ylim([0,None])
plt.savefig(f'img/{NAME}_throttle.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()<jupyter_output><empty_output><jupyter_text><jupyter_code>T = [42, 52]
NAME = 'r2'
l1, lt1 = get_array_from_time_interval(gt, t, T)
l2, lt2 = get_array_from_time_interval(sp, t, T)
l3, lt3 = get_array_from_time_interval(throttle, t, T)
plt.plot(lt2, l2, label='Setpoint', zorder=2, color='black', linestyle='--')
plt.plot(lt1, l1, label='Response', zorder=1, color='red', linewidth=2.)

plt.xlabel('Time $(s)$')
plt.ylabel('Speed $(m/s)$')
plt.legend(fontsize=7)
plt.savefig(f'img/{NAME}.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()
plt.plot(lt3, l3, color='black', linewidth=1.25)

plt.xlabel('Time $(s)$')
plt.ylabel('Throttle')
plt.ylim([0,None])
plt.savefig(f'img/{NAME}_throttle.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()<jupyter_output><empty_output><jupyter_text><jupyter_code>T = [101, 106]
NAME = 'r3'
l1, lt1 = get_array_from_time_interval(gt, t, T)
l2, lt2 = get_array_from_time_interval(sp, t, T)
l3, lt3 = get_array_from_time_interval(throttle, t, T)
plt.plot(lt2, l2, label='Setpoint', zorder=2, color='black', linestyle='--')
plt.plot(lt1, l1, label='Response', zorder=1, color='red', linewidth=2.)

plt.xlabel('Time $(s)$')
plt.ylabel('Speed $(m/s)$')
plt.legend(fontsize=7)
plt.savefig(f'img/{NAME}.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()
plt.plot(lt3, l3, color='black', linewidth=1.25)

plt.xlabel('Time $(s)$')
plt.ylabel('Throttle')
plt.ylim([0,None])
plt.savefig(f'img/{NAME}_throttle.png', dpi=DPI, transparent=True, bbox_inches='tight')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2060791968767429, 'fraction_numerical': 0.02788622420524261, 'mean_word_length': 6.488517745302714, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '580333', 'license': 'MIT', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1557, 'n_words': 250, 'path': 'S4_COST_FUNCTION_MODIFICATIONS/cost0/Plot Sim CARLA.ipynb', 'repo_name': 'fadamsyah/Particle-Based-Optimization-for-Longitudinal-Control', 'size': '3586'}