Skip to content

Commit

Permalink
Update controllers for new shapes and solve multiple experiments error
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiopaniego committed Jan 9, 2024
1 parent 1c31e21 commit 3f490e8
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
#ChannelDropout(p=1.0),
Normalize()
])
image = AUGMENTATIONS_TEST(image=img_base)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def execute(self):
]

AUGMENTATIONS_TEST = Compose([
GridDropout(p=1.0, ratio=0.9)
GridDropout(p=1.0)
])

bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1)
Expand All @@ -139,7 +139,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand All @@ -147,7 +147,7 @@ def execute(self):
self.bird_eye_view_unique_images += 1
self.previous_bird_eye_view_image = img

velocity_dim = np.full((150, 50), self.previous_speed/30)
velocity_dim = np.full((200, 66), self.previous_speed/30)
new_img_vel = np.dstack((img, velocity_dim))
img = new_img_vel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand All @@ -149,7 +149,7 @@ def execute(self):
self.bird_eye_view_unique_images += 1
self.previous_bird_eye_view_image = img

velocity_dim = np.full((150, 50), self.previous_speed/30)
velocity_dim = np.full((200, 66), self.previous_speed/30)
new_img_vel = np.dstack((img, velocity_dim))
img = new_img_vel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def execute(self):
]

AUGMENTATIONS_TEST = Compose([
GridDropout(p=1.0, ratio=0.9)
GridDropout(p=1.0)
])

bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1)
Expand All @@ -140,7 +140,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand All @@ -154,7 +154,7 @@ def execute(self):
self.bird_eye_view_unique_images += 1
self.previous_bird_eye_view_image = img

velocity_dim = np.full((150, 50), self.previous_speed/30)
velocity_dim = np.full((200, 66), self.previous_speed/30)
new_img_vel = np.dstack((img, velocity_dim))
img = new_img_vel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def execute(self):

self.update_pose(self.pose.getPose3d())

image_shape=(50, 150)
image_shape=(66, 200)
img_base = cv2.resize(bird_eye_view_1, image_shape)

AUGMENTATIONS_TEST = Compose([
Expand All @@ -154,7 +154,7 @@ def execute(self):
self.bird_eye_view_unique_images += 1
self.previous_bird_eye_view_image = img

velocity_dim = np.full((150, 50), self.previous_speed/30)
velocity_dim = np.full((200, 66), self.previous_speed/30)
new_img_vel = np.dstack((img, velocity_dim))
img = new_img_vel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def execute(self):


AUGMENTATIONS_TEST = Compose([
GridDropout(p=1.0, ratio=0.9)
GridDropout(p=1.0)
])

bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import carla
from os import path
from albumentations import (
Compose, Normalize, RandomRain, RandomBrightness, RandomShadow, RandomSnow, RandomFog, RandomSunFlare, GridDropout, ChannelDropout, GaussNoise
Compose, Normalize, RandomRain, RandomBrightness, RandomShadow, RandomSnow, RandomFog, RandomSunFlare, GridDropout, ChannelDropout
)
from utils.constants import PRETRAINED_MODELS_DIR, ROOT_PATH
from utils.logger import logger
Expand Down Expand Up @@ -147,8 +147,7 @@ def execute(self):


AUGMENTATIONS_TEST = Compose([
#GridDropout(p=1.0, ratio=0.5),
GaussNoise(p=1.0, var_limit=(500.0, 1500.0))
GridDropout(p=1.0, ratio=0.9)
])

bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ def execute(self):
self.image_8 = img
elif type(self.image_9) is int:
self.image_9 = img
elif type(self.image_10) is int:
self.image_10 = img
else:
self.bird_eye_view_images += 1
if (self.image_9==img).all() == False:
if (self.image_10==img).all() == False:
self.bird_eye_view_unique_images += 1
self.image_1 = self.image_2
self.image_2 = self.image_3
Expand All @@ -184,9 +186,10 @@ def execute(self):
self.image_6 = self.image_7
self.image_7 = self.image_8
self.image_8 = self.image_9
self.image_9 = img
self.image_9 = self.image_10
self.image_10 = img

img = [self.image_1, self.image_4, self.image_9]
img = [self.image_1, self.image_5, self.image_10]
img = np.expand_dims(img, axis=0)

start_time = time.time()
Expand Down
41 changes: 23 additions & 18 deletions behavior_metrics/driver_carla.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def is_config_correct(app_configuration):

return is_correct

def generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times):
def generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times, app_configuration):
result = metrics_carla.get_aggregated_experiments_list(experiments_starting_time)

experiments_starting_time_dt = datetime.fromtimestamp(experiments_starting_time)
Expand Down Expand Up @@ -252,28 +252,33 @@ def generate_agregated_experiments_metrics(experiments_starting_time, experiment
'metric': 'suddenness_distance_speed_per_km',
'title': 'Suddenness distance speed per km per experiment'
},
{
'metric': 'dangerous_distance_pct_km',
'title': 'Percentage of dangerous distance per km'
},
{
'metric': 'close_distance_pct_km',
'title': 'Percentage of close distance per km'
},
{
'metric': 'medium_distance_pct_km',
'title': 'Percentage of medium distance per km'
},
{
'metric': 'great_distance_pct_km',
'title': 'Percentage of great distance per km'
},

{
'metric': 'completed_laps',
'title': 'Completed laps per experiment'
},
]

if app_configuration.task == 'follow_lane_traffic':
experiments_metrics_and_titles.append(
{
'metric': 'dangerous_distance_pct_km',
'title': 'Percentage of dangerous distance per km'
},
{
'metric': 'close_distance_pct_km',
'title': 'Percentage of close distance per km'
},
{
'metric': 'medium_distance_pct_km',
'title': 'Percentage of medium distance per km'
},
{
'metric': 'great_distance_pct_km',
'title': 'Percentage of great distance per km'
},
)

metrics_carla.get_all_experiments_aggregated_metrics(result, experiments_starting_time_str, experiments_metrics_and_titles)
metrics_carla.get_per_model_aggregated_metrics(result, experiments_starting_time_str, experiments_metrics_and_titles)
metrics_carla.get_all_experiments_aggregated_metrics_boxplot(result, experiments_starting_time_str, experiments_metrics_and_titles)
Expand Down Expand Up @@ -413,7 +418,7 @@ def main():
logger.info('Invalid task type. Try "follow_route", "follow_lane" or "follow_lane_traffic". Killing program...')
sys.exit(-1)
experiments_elapsed_times['total_experiments_elapsed_time'] = time.time() - experiments_starting_time
generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times)
generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times, app_configuration)
if app_configuration.experiment_random_spawn_point == True or app_configuration.task == 'follow_route':
if os.path.isfile('tmp_circuit.launch'):
os.remove('tmp_circuit.launch')
Expand Down

0 comments on commit 3f490e8

Please sign in to comment.