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

How to directly get other agents' trajectories?

Open Kguo-cs opened this issue 2 years ago • 3 comments

The code provides the method to get the detections of other agents. How can I get their past and future trajectories directly?

Kguo-cs avatar Apr 12 '22 12:04 Kguo-cs

By the way, there may be a bug in the "filter_agents" and "extract_and_pad_agent_states" functions of "agent_preprocessing.py". The "token" of the "box" should be changed into "track_token".

Kguo-cs avatar Apr 13 '22 12:04 Kguo-cs

The code provides the method to get the detections of other agents. How can I get their past and future trajectories directly?

I have not been able to find a function which does this. My workaround is slow but does give the whole trajectory for an agent:

from nuplan.planning.scenario_builder.nuplan_db.nuplan_scenario import NuPlanScenario
from nuplan.planning.simulation.observation.smart_agents.idm_agents.utils import convert_box3d_to_se2, create_path_from_se2
from nuplan.planning.simulation.path.interpolated_path import InterpolatedPath

def get_agent_trajectory(scenario: NuPlanScenario, agent_track_token: str) -> InterpolatedPath:
    path = []
    for t in range(scenario.get_number_of_iterations()):
        detections = scenario.get_detections_at_iteration(t)
        for box in detections.boxes:
            if box.track_token == agent_track_token:
                path.append(convert_box3d_to_se2(box))

    return create_path_from_se2(path)

aalec avatar May 30 '22 15:05 aalec

Hi!

Sorry for the late reply. You can try using get_past_tracked_objects() and 'get_future_tracked_objects()'. This will give you all the detected agents in a given range past or future.

To convert it into a trajectory or path, you would need to do something like @aalec has suggested.

The bug should be fixed since the new update.

patk-motional avatar Jun 16 '22 22:06 patk-motional

I'll close the issue for inactivity. If you still are facing the problem with the current devkit version, feel free to reopen it!

gianmarco-motional avatar Sep 13 '22 03:09 gianmarco-motional