nuplan-devkit icon indicating copy to clipboard operation
nuplan-devkit copied to clipboard

Traffic Light Localization

Open asafDahan opened this issue 2 years ago • 5 comments

Exploring the code I see that Traffic light status contains the TrafficLightStatusType, lane_connector_id and timestamp:

class TrafficLightStatusData:
    """Traffic light status."""

    status: TrafficLightStatusType  # Status: green, red
    lane_connector_id: int  # lane connector id, where this traffic light belongs to
    timestamp: int  # Timestamp

Is there anywhere in the map a localization information of traffic lights (World/Ego vehicle coordinates)?

Thanks in advance

asafDahan avatar May 28 '23 11:05 asafDahan

You can retrieve the lane connector from the map-api with the provided id. The lane connector object should contain localization information, e.g. in the polygon.

Best Daniel

DanielDauner avatar May 28 '23 12:05 DanielDauner

Thanks for your quick reply. Do you have any idea, why is the following code retrieves only Nones as the LaneConnectors?

log_db_files = discover_log_dbs(NUPLAN_DB_FILES)
scenario_type_token_map = get_scenario_type_token_map(log_db_files)
log_db_file, token = scenario_type_token_map['on_traffic_light_intersection'][0]
scenario = get_default_scenario_from_token(NUPLAN_DATA_ROOT, log_db_file, token, NUPLAN_MAPS_ROOT, NUPLAN_MAP_VERSION)


for iter in range(scenario.get_number_of_iterations()):
    tl_status_at_iter = list(scenario.get_traffic_light_status_at_iteration(iteration=iter))
    for tl_status in tl_status_at_iter:
        a = scenario.map_api.get_map_object(tl_status.lane_connector_id, SemanticMapLayer.LANE_CONNECTOR)
        if a is not None: 
            print(a)

asafDahan avatar May 28 '23 13:05 asafDahan

That's strange. As far as I can tell, your code should work. Maybe the id requires casting to str() before using it with the map-api, as done here in the IDM planner.

DanielDauner avatar May 28 '23 13:05 DanielDauner

That worked! Thank you very much :)!

asafDahan avatar May 28 '23 13:05 asafDahan

I was following https://github.com/motional/nuplan-devkit/issues/71#issuecomment-1171226958 way of thought to receive the traffic light location. image

But on the last phase, when trying to check which of the traffic lights indicated using the stopline has the relevant lane connector, I see that I cannot load a traffic element object because scenario.map_api.get_available_map_objects() does not contain SemanticMapLayer.Traffic_light. Is there another way to get the information of the traffic light based on it's ID?

I'ml wish to retrieve the following values: https://github.com/motional/nuplan-devkit/issues/71#issuecomment-1173888000

asafDahan avatar May 28 '23 16:05 asafDahan