Skip to content

Commit

Permalink
set sumo vehicle id to corresponding carla vehicle role name
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyuan0124 committed Jul 21, 2023
1 parent eb338a5 commit fe546ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions co-simulation/bridge/carla_integration/bridge_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _get_recommended_carla_blueprint(sumo_actor):
return random.choice(blueprints)

@staticmethod
def get_carla_blueprint(sumo_actor, sync_color=False):
def get_carla_blueprint(sumo_actor, sumo_id, sync_color=False):
"""
Returns an appropriate blueprint based on the received sumo actor.
"""
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_carla_blueprint(sumo_actor, sync_color=False):
driver_id = random.choice(blueprint.get_attribute('driver_id').recommended_values)
blueprint.set_attribute('driver_id', driver_id)

blueprint.set_attribute('role_name', 'sumo_driver')
blueprint.set_attribute('role_name', sumo_id)

logging.debug(
'''[BridgeHelper] sumo vtype %s will be spawned in carla with the following attributes:
Expand Down
2 changes: 1 addition & 1 deletion co-simulation/bridge/carla_integration/synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def tick(self):
sumo_spawned_actors = self.sumo.spawned_actors - set(self.carla2sumo_ids.values())
for sumo_actor_id in sumo_spawned_actors:
sumo_actor = self.sumo.get_actor(sumo_actor_id)
carla_blueprint = BridgeHelper.get_carla_blueprint(sumo_actor, self.sync_vehicle_color)
carla_blueprint = BridgeHelper.get_carla_blueprint(sumo_actor, sumo_actor_id, self.sync_vehicle_color)
if carla_blueprint is not None:
carla_transform = BridgeHelper.get_carla_transform(sumo_actor.transform,
sumo_actor.extent)
Expand Down

0 comments on commit fe546ed

Please sign in to comment.