diff --git a/srunner/scenariomanager/carla_data_provider.py b/srunner/scenariomanager/carla_data_provider.py index efdbe7da8..7e97f6a03 100644 --- a/srunner/scenariomanager/carla_data_provider.py +++ b/srunner/scenariomanager/carla_data_provider.py @@ -70,6 +70,7 @@ class CarlaDataProvider(object): # pylint: disable=too-many-public-methods _grp = None # type: GlobalRoutePlanner _runtime_init_flag = False _lock = threading.Lock() + _latest_scenario = "" @staticmethod def set_local_planner(plan): @@ -268,6 +269,20 @@ def get_global_route_planner(): """ return CarlaDataProvider._grp + @staticmethod + def set_ego_route(route): + """ + set the ego route + """ + CarlaDataProvider._ego_vehicle_route = route + + @staticmethod + def get_ego_route(): + """ + @return the ego route + """ + return CarlaDataProvider._ego_vehicle_route + @staticmethod def get_all_actors(): """ @@ -1023,6 +1038,20 @@ def set_traffic_manager_port(tm_port): """ CarlaDataProvider._traffic_manager_port = tm_port + @staticmethod + def set_latest_scenario(scenario_name): + """ + Set the latest scenario + """ + CarlaDataProvider._latest_scenario = scenario_name + + @staticmethod + def get_latest_scenario(): + """ + Get the latest scenario + """ + return CarlaDataProvider._latest_scenario + @staticmethod def cleanup(): """ @@ -1061,7 +1090,9 @@ def cleanup(): CarlaDataProvider._rng = random.RandomState(CarlaDataProvider._random_seed) CarlaDataProvider._grp = None CarlaDataProvider._runtime_init_flag = False + CarlaDataProvider._latest_scenario = "" @property def world(self): return self._world + diff --git a/srunner/scenariomanager/scenarioatomics/atomic_behaviors.py b/srunner/scenariomanager/scenarioatomics/atomic_behaviors.py index 9f875b084..1385dd3c5 100644 --- a/srunner/scenariomanager/scenarioatomics/atomic_behaviors.py +++ b/srunner/scenariomanager/scenarioatomics/atomic_behaviors.py @@ -4428,7 +4428,7 @@ def update(self): # Check which scenarios can be triggered blackboard = py_trees.blackboard.Blackboard() - for black_var_name, scen_location in self._blackboard_list: + for black_var_name, scen_location, scen_name in self._blackboard_list: # Close enough scen_distance = route_location.distance(scen_location) @@ -4445,6 +4445,8 @@ def update(self): _ = blackboard.set(black_var_name, True) self._triggered_scenarios.append(black_var_name) + CarlaDataProvider.set_latest_scenario(scen_name) + if self._debug: self._world.debug.draw_point( scen_location + carla.Location(z=4),