motional / nuplan-devkit

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

Why is ego velocity_y much more smaller than ego_velocity_x #209

Closed alantes closed 1 year ago

alantes commented 1 year ago

Hello, developers! Thank you for your data and dev-kit!

In "2021.10.15.02.36.56_veh-53_02020_02442.db" of Singapore split, the ego vehicle ran a route like this: image

But the corresponding velocity_x among the way is like: image

While the velocity_y is like: image

To me, velocity_y is like noise rather than normal speed.

Here is my code:

velocity_x = []
velocity_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
    )
    velocity_x.append(scenario.initial_ego_state.agent.velocity.x)
    velocity_y.append(scenario.initial_ego_state.agent.velocity.y)
alantes commented 1 year ago

If I calculate velocity by magnitude and heading, the graphs seem much more correct:

import numpy as np
velocity_x = []
velocity_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
    )
    heading = scenario.initial_ego_state.rear_axle.heading
    velocity = scenario.initial_ego_state.dynamic_car_state.rear_axle_velocity_2d.magnitude()
    # velocity_x.append(scenario.initial_ego_state.dynamic_car_state.center_acceleration_2d.x)
    # velocity_y.append(scenario.initial_ego_state.dynamic_car_state.center_acceleration_2d.y)
    velocity_x.append(velocity * np.cos(heading))
    velocity_y.append(velocity * np.sin(heading))

v_x: image

v_y: image

patk-motional commented 1 year ago

Hi @alantes,

Sorry for the delay. The reason that the velocity_y is small is that the velocities are in the ego's frame. velocity_x is the longitudinal direction and velocity_y is the lateral direction. Hope this clears up some of your confusions