Skip to content

Commit

Permalink
Added log agent
Browse files Browse the repository at this point in the history
TayYim authored Jun 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2a23a7e commit 5828e59
Showing 2 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions srunner/scenariomanager/carla_data_provider.py
Original file line number Diff line number Diff line change
@@ -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

4 changes: 3 additions & 1 deletion srunner/scenariomanager/scenarioatomics/atomic_behaviors.py
Original file line number Diff line number Diff line change
@@ -4425,7 +4425,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)
@@ -4442,6 +4442,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),

0 comments on commit 5828e59

Please sign in to comment.