Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import numpy as np
import main
import replicate_Kountouriotis_et_al_2016
import matplotlib.pyplot as plt
import calculate_parallel_curves
import batch_functions
# Input variables
trial_time_in_seconds = 6
time_ploted = 3 # similar to Kountouriotis
# Get the center line, as well as the locations of the agent throughout the simulation
agent_x_array,agent_y_array = batch_functions.get_agent_location(main.magical_dictionary)
center_arc_x,center_arc_y = replicate_Kountouriotis_et_al_2016.center_curve_x_array,replicate_Kountouriotis_et_al_2016.center_curve_y_array
full_road_x, full_road_y = replicate_Kountouriotis_et_al_2016.center_x_array,replicate_Kountouriotis_et_al_2016.center_y_array
first_straight_x,first_straight_y = replicate_Kountouriotis_et_al_2016.center_initial_straight_x_array,replicate_Kountouriotis_et_al_2016.center_initial_straight_y_array
last_straight_x,last_straight_y = replicate_Kountouriotis_et_al_2016.center_last_straight_x_array,replicate_Kountouriotis_et_al_2016.center_last_straight_y_array
# Adjust arrays to isolate agent_x and y coordinates to specific road segments (Note: last straight segment isn't analyzed here because the agent doesn't travel along it, only waypoints do)
first_straight_only_agent_x,first_straight_only_agent_y = calculate_parallel_curves.slice_agentArray_wrt_roadSegment(agent_x_array,agent_y_array,"first_straight",replicate_Kountouriotis_et_al_2016.firstStraightResolution)
arc_only_agent_x,arc_only_agent_y = calculate_parallel_curves.slice_agentArray_wrt_roadSegment(agent_x_array,agent_y_array,"middle_arc",replicate_Kountouriotis_et_al_2016.firstStraightResolution)
# Calculate error for road segments seperately
error_over_time_for_curve = batch_functions.get_bias_over_time(arc_only_agent_x,arc_only_agent_y,0,(-1*replicate_Kountouriotis_et_al_2016.centerCircleRadius), replicate_Kountouriotis_et_al_2016.centerCircleRadius)
error_over_time_for_first_straight = batch_functions.get_straight_bias_over_time(first_straight_only_agent_x, first_straight_only_agent_y,0,(-1*replicate_Kountouriotis_et_al_2016.centerCircleRadius), replicate_Kountouriotis_et_al_2016.centerCircleRadius,first_straight_x,first_straight_y)
# Bring together total error across full road
error_over_time = np.concatenate((error_over_time_for_first_straight,error_over_time_for_curve),axis=None)
time_array = np.linspace(0,trial_time_in_seconds,len(error_over_time))
# ====================================================================================================================
# Create a plot!
fig2 = plt.figure(2,figsize=(4.5,7), constrained_layout=True)
ax2 = plt.axes(xlim=(-1,1), ylim=(0,time_ploted))
trajectory = ax2.plot(error_over_time,time_array,c='red')
center_line = plt.axvline(x = 0, color = 'black', linestyle = '--')
# for i in range(0,len(error_over_time)):
# ax2.plot(error_over_time[i],time_array[i], marker='.', c='red')
plt.title('FP Distance:'+ str(round(main.farpoint_distance)) + ', FP Gain:' + str(main.derivative_farPoint_gain) + ', NP Gains:' + str(main.derivative_nearPoint_gain) + ',' + str(main.proportional_nearPoint_gain))
plt.xlabel('steering bias (m):')
plt.ylabel('time (s)')
# fig2 = plt.figure(2,figsize=(7,6), constrained_layout=True)
# ax2 = plt.axes(xlim=(-30,70), ylim=(-70,30))
# center_arc = ax2.plot(center_arc_x,center_arc_y,c='black',ls='--')
# inside_last_straight = ax2.plot(replicate_Kountouriotis_et_al_2016.inside_x_array,replicate_Kountouriotis_et_al_2016.inside_y_array,c='black')
# outside_last_straight = ax2.plot(replicate_Kountouriotis_et_al_2016.outside_x_array,replicate_Kountouriotis_et_al_2016.outside_y_array,c='black')
# center_arc = ax2.plot(agent_x_array[7],agent_y_array[7], marker='.', c='red')
# center_arc = ax2.plot(0,-60, marker='.', c='red')
plt.show()