class_docstr: SimulationSynchronization class is responsible for the synchronization of sumo and carla
  simulations.
docstr: Tick to simulation synchronization
docstr_tok: ["Tick","to","simulation","synchronization"]
code: def tick(self):
      """
      Tick to simulation synchronization
      """
      # -----------------
      # sumo-->carla sync
      # -----------------
      self.sumo.tick()
  
      # Spawning new sumo actors in carla (i.e, not controlled by carla).
      sumo_spawned_actors = self.sumo.spawned_actors - set(
          self.carla2sumo_ids.values()
      )
      for sumo_actor_id in sumo_spawned_actors:
          self.sumo.subscribe(sumo_actor_id)
          sumo_actor = self.sumo.get_actor(sumo_actor_id)
  
          carla_blueprint = BridgeHelper.get_carla_blueprint(
              sumo_actor, self.sync_vehicle_color
          )
          if carla_blueprint is not None:
              carla_transform = BridgeHelper.get_carla_transform(
                  sumo_actor.transform, sumo_actor.extent
              )
  
              carla_actor_id = self.carla.spawn_actor(
                  carla_blueprint, carla_transform
              )
              if carla_actor_id != INVALID_ACTOR_ID:
                  self.sumo2carla_ids[sumo_actor_id] = carla_actor_id
          else:
              self.sumo.unsubscribe(sumo_actor_id)
  
      # Destroying sumo arrived actors in carla.
      for sumo_actor_id in self.sumo.destroyed_actors:
          if sumo_actor_id in self.sumo2carla_ids:
              self.carla.destroy_actor(
                  self.sumo2carla_ids.pop(sumo_actor_id)
              )
  
      # Updating sumo actors in carla.
      for sumo_actor_id in self.sumo2carla_ids:
          carla_actor_id = self.sumo2carla_ids[sumo_actor_id]
  
          sumo_actor = self.sumo.get_actor(sumo_actor_id)
          carla_actor = self.carla.get_actor(carla_actor_id)
  
          carla_transform = BridgeHelper.get_carla_transform(
              sumo_actor.transform, sumo_actor.extent
          )
          if self.sync_vehicle_lights:
              carla_lights = BridgeHelper.get_carla_lights_state(
                  carla_actor.get_light_state(), sumo_actor.signals
              )
          else:
              carla_lights = None
  
          self.carla.synchronize_vehicle(
              carla_actor_id, carla_transform, carla_lights
          )
  
      # Updates traffic lights in carla based on sumo information.
      if self.tls_manager == "sumo":
          common_landmarks = (
              self.sumo.traffic_light_ids & self.carla.traffic_light_ids
          )
          for landmark_id in common_landmarks:
              sumo_tl_state = self.sumo.get_traffic_light_state(
                  landmark_id
              )
              carla_tl_state = (
                  BridgeHelper.get_carla_traffic_light_state(
                      sumo_tl_state
                  )
              )
  
              self.carla.synchronize_traffic_light(
                  landmark_id, carla_tl_state
              )
  
      # -----------------
      # carla-->sumo sync
      # -----------------
      self.carla.tick()
  
      # Spawning new carla actors (not controlled by sumo)
      carla_spawned_actors = self.carla.spawned_actors - set(
          self.sumo2carla_ids.values()
      )
      for carla_actor_id in carla_spawned_actors:
          carla_actor = self.carla.get_actor(carla_actor_id)
  
          type_id = BridgeHelper.get_sumo_vtype(carla_actor)
          color = (
              carla_actor.attributes.get("color", None)
              if self.sync_vehicle_color
              else None
          )
          if type_id is not None:
              sumo_actor_id = self.sumo.spawn_actor(type_id, color)
              if sumo_actor_id != INVALID_ACTOR_ID:
                  self.carla2sumo_ids[carla_actor_id] = sumo_actor_id
                  self.sumo.subscribe(sumo_actor_id)
  
      # Destroying required carla actors in sumo.
      for carla_actor_id in self.carla.destroyed_actors:
          if carla_actor_id in self.carla2sumo_ids:
              self.sumo.destroy_actor(
                  self.carla2sumo_ids.pop(carla_actor_id)
              )
  
      # Updating carla actors in sumo.
      for carla_actor_id in self.carla2sumo_ids:
          sumo_actor_id = self.carla2sumo_ids[carla_actor_id]
  
          carla_actor = self.carla.get_actor(carla_actor_id)
          sumo_actor = self.sumo.get_actor(sumo_actor_id)
  
          sumo_transform = BridgeHelper.get_sumo_transform(
              carla_actor.get_transform(),
              carla_actor.bounding_box.extent,
          )
          if self.sync_vehicle_lights:
              carla_lights = self.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
  
          self.sumo.synchronize_vehicle(
              sumo_actor_id, sumo_transform, sumo_lights
          )
  
      # Updates traffic lights in sumo based on carla information.
      if self.tls_manager == "carla":
          common_landmarks = (
              self.sumo.traffic_light_ids & self.carla.traffic_light_ids
          )
          for landmark_id in common_landmarks:
              carla_tl_state = self.carla.get_traffic_light_state(
                  landmark_id
              )
              sumo_tl_state = BridgeHelper.get_sumo_traffic_light_state(
                  carla_tl_state
              )
  
              # Updates all the sumo links related to this landmark.
              self.sumo.synchronize_traffic_light(
                  landmark_id, sumo_tl_state
              )
  
file_path: carla/Co-Simulation/Sumo/run_synchronization.py
imports: import argparse
  import logging
  import time
  import glob
  import os
  import sys
  from sumo_integration.bridge_helper import BridgeHelper
  from sumo_integration.carla_simulation import CarlaSimulation
  from sumo_integration.constants import INVALID_ACTOR_ID
  from sumo_integration.sumo_simulation import SumoSimulation
label_desc: Use image node_id 2 for calling the SimulationSynchronization obj's underlying member method code with example usage: obj.tick() without return types