workaround to fix sync issues when accessing vehicles light state
This commit is contained in:
parent
276720b4ca
commit
d429a22978
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue