code: def get_scene_layout(carla_map):
      """
      Function to extract the full scene layout to be used as a full scene description to be
      given to the user
      :return: a dictionary describing the scene.
      """
  
      def _lateral_shift(transform, shift):
          transform.rotation.yaw += 90
          return (
              transform.location
              + shift * transform.get_forward_vector()
          )
  
      topology = [x[0] for x in carla_map.get_topology()]
      topology = sorted(topology, key=lambda w: w.transform.location.z)
  
      # A road contains a list of lanes, a each lane contains a list of waypoints
      map_dict = dict()
      precision = 0.05
      for waypoint in topology:
          waypoints = [waypoint]
          nxt = waypoint.next(precision)
          if len(nxt) > 0:
              nxt = nxt[0]
              while nxt.road_id == waypoint.road_id:
                  waypoints.append(nxt)
                  nxt = nxt.next(precision)
                  if len(nxt) > 0:
                      nxt = nxt[0]
                  else:
                      break
  
          left_marking = [
              _lateral_shift(w.transform, -w.lane_width * 0.5)
              for w in waypoints
          ]
          right_marking = [
              _lateral_shift(w.transform, w.lane_width * 0.5)
              for w in waypoints
          ]
  
          lane = {
              "waypoints": waypoints,
              "left_marking": left_marking,
              "right_marking": right_marking,
          }
  
          if map_dict.get(waypoint.road_id) is None:
              map_dict[waypoint.road_id] = {}
          map_dict[waypoint.road_id][waypoint.lane_id] = lane
  
      # Generate waypoints graph
      waypoints_graph = dict()
      for road_key in map_dict:
          for lane_key in map_dict[road_key]:
              # List of waypoints
              lane = map_dict[road_key][lane_key]
  
              for i in range(0, len(lane["waypoints"])):
                  next_ids = [
                      w.id
                      for w in lane["waypoints"][
                          i + 1 : len(lane["waypoints"])
                      ]
                  ]
  
                  # Get left and right lane keys
                  left_lane_key = (
                      lane_key - 1
                      if lane_key - 1 != 0
                      else lane_key - 2
                  )
                  right_lane_key = (
                      lane_key + 1
                      if lane_key + 1 != 0
                      else lane_key + 2
                  )
  
                  # Get left and right waypoint ids only if they are valid
                  left_lane_waypoint_id = -1
                  if left_lane_key in map_dict[road_key]:
                      left_lane_waypoints = map_dict[road_key][
                          left_lane_key
                      ]["waypoints"]
                      if i < len(left_lane_waypoints):
                          left_lane_waypoint_id = left_lane_waypoints[
                              i
                          ].id
  
                  right_lane_waypoint_id = -1
                  if right_lane_key in map_dict[road_key]:
                      right_lane_waypoints = map_dict[road_key][
                          right_lane_key
                      ]["waypoints"]
                      if i < len(right_lane_waypoints):
                          right_lane_waypoint_id = right_lane_waypoints[
                              i
                          ].id
  
                  # Get left and right margins (aka markings)
                  lm = carla_map.transform_to_geolocation(
                      lane["left_marking"][i]
                  )
                  rm = carla_map.transform_to_geolocation(
                      lane["right_marking"][i]
                  )
  
                  # Waypoint Position
                  wl = carla_map.transform_to_geolocation(
                      lane["waypoints"][i].transform.location
                  )
  
                  # Waypoint Orientation
                  wo = lane["waypoints"][i].transform.rotation
  
                  # Waypoint dict
                  waypoint_dict = {
                      "road_id": road_key,
                      "lane_id": lane_key,
                      "position": [
                          wl.latitude,
                          wl.longitude,
                          wl.altitude,
                      ],
                      "orientation": [wo.roll, wo.pitch, wo.yaw],
                      "left_margin_position": [
                          lm.latitude,
                          lm.longitude,
                          lm.altitude,
                      ],
                      "right_margin_position": [
                          rm.latitude,
                          rm.longitude,
                          rm.altitude,
                      ],
                      "next_waypoints_ids": next_ids,
                      "left_lane_waypoint_id": left_lane_waypoint_id,
                      "right_lane_waypoint_id": right_lane_waypoint_id,
                  }
                  waypoints_graph[
                      map_dict[road_key][lane_key]["waypoints"][i].id
                  ] = waypoint_dict
  
      return waypoints_graph
  
imports: import glob
  import os
  import sys
  import carla
  import random
label_desc: Use image node_id 1 for calling a global function with example usage: get_scene_layout(carla_map) and returns: waypoints_graph, unknown