Commit 5f137045 authored by Moritz Klischat's avatar Moritz Klischat
Browse files

unique names traci simulations

parent ff6b02f0
import copy
import logging
import math
import random
import sys
import time
from collections import defaultdict
from functools import lru_cache
from typing import Dict, Union
......@@ -40,7 +42,7 @@ __copyright__ = "TUM Cyber-Physical Systems Group"
__credits__ = ["ZIM Projekt ZF4086007BZ8"]
__version__ = "2021.1"
__maintainer__ = "Moritz Klischat"
__email__ = "commonroad-i06@in.tum.de"
__email__ = "commonroad@lists.lrz.de"
__status__ = "Released"
......@@ -82,6 +84,7 @@ class SumoSimulation:
self._lc_inaction = 0 # Flag indicates that SUMO is performing a lane change for the ego
self.lateral_position_buffer = dict() # stores lateral position [ego_vehicle_id,float]
self.logger: logging.Logger = None
self._traci_label = None
self.initialized = False
@property
......@@ -165,7 +168,7 @@ class SumoSimulation:
np.random.seed(self.conf.random_seed)
cmd.extend(['--seed', str(self.conf.random_seed)])
traci.start(cmd, label=self.conf.scenario_name)
traci.start(cmd, label=self.traci_label)
# simulate until ego_time_start
self.__presimulation_silent(self.conf.presimulation_steps)
......@@ -259,6 +262,13 @@ class SumoSimulation:
self._ego_vehicles[ego_vehicle.id] = ego_vehicle
@property
def traci_label(self):
"""Unique label to identify simulation"""
if self._traci_label is None:
self._traci_label = self.conf.scenario_name + time.strftime("%H%M%S") + str(random.randint(0, 100))
return self._traci_label
@property
def ego_vehicles(self) -> Dict[int, EgoVehicle]:
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment