nuplan-devkit
nuplan-devkit copied to clipboard
How to directly get other agents' trajectories?
The code provides the method to get the detections of other agents. How can I get their past and future trajectories directly?
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".
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)
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.
I'll close the issue for inactivity. If you still are facing the problem with the current devkit version, feel free to reopen it!