workaround to fix sync issues when accessing vehicles light state

This commit is contained in:
Joel Moriana 2020-03-05 12:57:22 +01:00 committed by Marc Garcia Puig
parent 276720b4ca
commit d429a22978
2 changed files with 15 additions and 2 deletions

View File

@ -140,8 +140,11 @@ def main(args):
sumo_transform = BridgeHelper.get_sumo_transform(carla_actor.get_transform(), carla_actor.bounding_box.extent)
if args.sync_vehicle_lights:
carla_lights = carla_actor.get_light_state()
sumo_lights = BridgeHelper.get_sumo_lights_state(sumo_actor.signals, carla_lights)
carla_lights = carla.get_actor_light_state(carla_actor_id)
if carla_lights is not None:
sumo_lights = BridgeHelper.get_sumo_lights_state(sumo_actor.signals, carla_lights)
else:
sumo_lights = None
else:
sumo_lights = None

View File

@ -51,6 +51,16 @@ class CarlaSimulation(object):
def get_actor(self, actor_id):
return self.world.get_actor(actor_id)
# This is a workaround to fix synchronization issues when other carla
# clients remove an actor in carla without waiting for tick (e.g.,
# running sumo co-simulation and manual control at the same time)
def get_actor_light_state(self, actor_id):
try:
actor = self.get_actor(actor_id)
return actor.get_light_state()
except RuntimeError:
return None
def spawn_actor(self, blueprint, transform):
"""Spawns a new actor.
"""