class_docstr: BridgeHelper provides methos to ease the co-simulation between sumo and carla.
class_docstr_tok: ["BridgeHelper","provides","methos","to","ease","the","co-simulation","between","sumo","and","carla","."]
docstr: Returns an appropriate blueprint based on the received sumo actor.
docstr_tok: ["Returns","an","appropriate","blueprint","based","on","the","received","sumo","actor","."]
code: def get_carla_blueprint(sumo_actor, sync_color=False):
      """
      Returns an appropriate blueprint based on the received sumo actor.
      """
      blueprint_library = BridgeHelper.blueprint_library
      type_id = sumo_actor.type_id
  
      if type_id in [bp.id for bp in blueprint_library]:
          blueprint = blueprint_library.filter(type_id)[0]
          logging.debug(
              "[BridgeHelper] sumo vtype %s found in carla blueprints",
              type_id,
          )
      else:
          blueprint = BridgeHelper._get_recommended_carla_blueprint(
              sumo_actor
          )
          if blueprint is not None:
              logging.warning(
                  "sumo vtype %s not found in carla. The following blueprint will be used: %s",
                  type_id,
                  blueprint.id,
              )
          else:
              logging.error(
                  "sumo vtype %s not supported. No vehicle will be spawned in carla",
                  type_id,
              )
              return None
  
      if blueprint.has_attribute("color"):
          if sync_color:
              color = "{},{},{}".format(
                  sumo_actor.color[0],
                  sumo_actor.color[1],
                  sumo_actor.color[2],
              )
          else:
              color = random.choice(
                  blueprint.get_attribute("color").recommended_values
              )
          blueprint.set_attribute("color", color)
  
      if blueprint.has_attribute("driver_id"):
          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")
  
      logging.debug(
          """[BridgeHelper] sumo vtype %s will be spawned in carla with the following attributes:
              \tblueprint: %s
              \tcolor: %s""",
          type_id,
          blueprint.id,
          sumo_actor.color
          if blueprint.has_attribute("color")
          else (-1, -1, -1),
      )
  
      return blueprint
  
file_path: carla/Co-Simulation/Sumo/sumo_integration/bridge_helper.py
imports: import json
  import logging
  import math
  import os
  import random
  import carla
  import traci
  from .sumo_simulation import SumoSignalState, SumoVehSignal
label_desc: Use image node_id 4 for calling the BridgeHelper obj's underlying member method code with example usage: obj.get_carla_blueprint(sumo_actor, sync_color) and returns: blueprint, None