motional / nuplan-devkit

The devkit of the nuPlan dataset.
https://www.nuplan.org
Other
674 stars 129 forks source link

Will the scenario be different when it is queried with different tokens in a same log_db file? #201

Closed alantes closed 1 year ago

alantes commented 1 year ago

I noticed that a log_db file has different tokens. So if I execute:

scenario = get_default_scenario_from_token(
    NUPLAN_DATA_ROOT, log_db, token, NUPLAN_MAPS_ROOT, NUPLAN_MAP_VERSION
)

Will there be any differences if the tokens are different while log_db remains the same?

For example, will scenario.get_number_of_iterations() be different?

alantes commented 1 year ago

Hello dear developers, I did some experiments but still feel confused about the structure of log_db files.

For example, when I choose the log_db file to be "/nuplan/dataset/nuplan-v1.1/mini/2021.07.16.00.51.05_veh-17_01352_01901.db" and select tokens 'c66d405b87ff5fbf' and '8596e888dceb5d90', the generated scenarios seem to be the same after visualize_scenario() (I mean, they may be consecutive steps in a single scenario). However, if I choose 'bcb90c35dc9559d7', the generated scenario will be totally different.

So, why do you stack different scenarios in a single log_gb file. Is there anything coherent that I did not get?

Thank you in advance!

alantes commented 1 year ago

Besides, although scenarios initialized with 'c66d405b87ff5fbf' and '8596e888dceb5d90' look like the same, if I test: '8596e888dceb5d90' in selected_scenario_1._lidarpc_tokens it will output False. The selected_scenario_1 is initialized with 'c66d405b87ff5fbf'.

So, is there duplicate scenarios in your log_db file?

alantes commented 1 year ago

Well, I did some more experiments and finally figured it out!

I executed the following code:

from nuplan.database.nuplan_db.nuplan_scenario_queries import get_scenarios_from_db
scenarios_generator = get_scenarios_from_db(
    log_db,
    filter_tokens=None,
    filter_types=None,
    filter_map_names=None,
    include_invalid_mission_goals=True,
)
delta_t = []
for i in range(len(scenarios_list) - 1):
    delta_t.append((scenarios_list[i+1]["timestamp"]-scenarios_list[i]["timestamp"])/1e6)
plt.scatter(range(len(delta_t)), delta_t)
plt.show()

ego_x = []
ego_y = []
for i in range(len(scenarios_list)):
    scenario = get_default_scenario_from_token(
        NUPLAN_DATA_ROOT, log_db, scenarios_list[i]["token"].hex(), NUPLAN_MAPS_ROOT, NUPLAN_MAP_VERSION
    )
    ego_x.append(scenario.initial_ego_state.center.x)
    ego_y.append(scenario.initial_ego_state.center.y)
plt.scatter(ego_x, ego_y)
plt.show()

Two plots are shown: image image

It seems that the timesteps of the tokens are consistent. And the recorded ego states are consistent. So, the trajectories stored in a log_db file are consistent.