From ededf4de90e8bae84fd67f66f69f81745588a48e Mon Sep 17 00:00:00 2001 From: sergiopaniego Date: Fri, 3 May 2024 18:03:11 +0200 Subject: [PATCH] Updated TCP brain woking in 3 directions --- .../brains/CARLA/brain_carla_TCP_3.py | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/behavior_metrics/brains/CARLA/brain_carla_TCP_3.py b/behavior_metrics/brains/CARLA/brain_carla_TCP_3.py index 9e38fba3..353dbd94 100644 --- a/behavior_metrics/brains/CARLA/brain_carla_TCP_3.py +++ b/behavior_metrics/brains/CARLA/brain_carla_TCP_3.py @@ -88,7 +88,19 @@ def __init__(self, sensors, actuators, model=None, handler=None, config=None): # setup config = route_indexer.next() ''' - We currently hard-code the initial and target points + [WIP] WORKS WITH: + result['target_point'][1] *= -1 + self.target_point = torch.stack([result['target_point'][1], result['target_point'][0]], dim=1).to('cuda', dtype=torch.float32) + ''' + config.trajectory[0].x = 55.3 + config.trajectory[0].y = -109.0 + + config.trajectory[1].x = 80.0 + config.trajectory[1].y = -109.0 + + ''' + WORKS WITH: + self.target_point = torch.stack([result['target_point'][1], result['target_point'][0]], dim=1).to('cuda', dtype=torch.float32) ''' #config.trajectory[0].x = 55.3 #config.trajectory[0].y = -105.6 @@ -96,11 +108,29 @@ def __init__(self, sensors, actuators, model=None, handler=None, config=None): #config.trajectory[1].x = -30.0 #config.trajectory[1].y = -105.6 - config.trajectory[0].x = -3.3 - config.trajectory[0].y = 179.5 + # WORKS with result['target_point'][1] *= -1 + ''' + WORKS WITH: + result['target_point'][1] *= -1 + self.target_point = torch.stack(result['target_point'], dim=1).to('cuda', dtype=torch.float32) + ''' + #config.trajectory[0].x = -3.3 + #config.trajectory[0].y = 179.5 + + #config.trajectory[1].x = -3.3 + #config.trajectory[1].y = 120.6 + + # WORKS without result['target_point'][1] *= -1 + ''' + WORKS WITH: + #result['target_point'][1] *= -1 + self.target_point = torch.stack(result['target_point'], dim=1).to('cuda', dtype=torch.float32) + ''' + #config.trajectory[0].x = -7.43 + #config.trajectory[0].y = 125.5 - config.trajectory[1].x = -3.3 - config.trajectory[1].y = 120.6 + #config.trajectory[1].x = -7.43 + #config.trajectory[1].y = 170.6 # prepare route's trajectory (interpolate and add the GPS route) gps_route, route = interpolate_trajectory(world, config.trajectory) @@ -228,9 +258,9 @@ def execute(self): result['target_point'] = tuple(local_command_point) result['target_point'] = [torch.FloatTensor([result['target_point'][0]]), torch.FloatTensor([result['target_point'][1]])] - result['target_point'][1] *= -1 - + #result['target_point'][1] *= -1 self.target_point = torch.stack(result['target_point'], dim=1).to('cuda', dtype=torch.float32) + #self.target_point = torch.stack([result['target_point'][1], result['target_point'][0]], dim=1).to('cuda', dtype=torch.float32) state = torch.cat([speed, self.target_point, cmd_one_hot], 1)