Skip to content

Commit 8aff2c4

Browse files
committed
address comments
1 parent c19fe8c commit 8aff2c4

7 files changed

Lines changed: 35 additions & 31 deletions

File tree

src/trajdata/dataset_specific/mads/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
#
1516

1617
"""MADS dataset package exports."""
1718

src/trajdata/dataset_specific/mads/constant.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
#
1516

1617
"""Constants and enums for the MADS dataset loader."""
1718

@@ -25,7 +26,7 @@
2526
EGO_WIDTH: Final[float] = 2.11311007
2627
EGO_HEIGHT: Final[float] = 1.34435794
2728

28-
# by default, we support internal production v2 dataset, with clipgt-2.0.0 and above.
29+
# by default, we support v2 data, version clipgt-2.0.0, clipgt-2.3.0 and above.
2930
DATA_SRC: Final[str] = "v2"
3031

3132
# Allowed MADS data source tags.
@@ -53,7 +54,7 @@ def resolve_data_src(cli_override: Optional[str] = None) -> str:
5354

5455

5556
class ObstacleClassV1(Enum):
56-
"""Obstacle classes for MADS based on NDAS `obstacle_types.proto`."""
57+
"""Obstacle classes for MADS."""
5758

5859
# buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX
5960
OBSTACLE_CLASS_INVALID = 0

src/trajdata/dataset_specific/mads/mads_dataset.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
#
1516

1617
import argparse
1718
import glob
@@ -124,7 +125,7 @@ def compute_metadata(self, env_name: str, data_dir: str) -> EnvMetadata:
124125
# get all clip ids
125126
self.clip_duration = clip_duration
126127
clip_items = list(clip_dir.items())
127-
random.shuffle(clip_items)
128+
random.Random(42).shuffle(clip_items)
128129
self.clip_dir = dict(clip_items)
129130
clip_ids = list(clip_dir.keys())
130131
all_clips = [clip_id for clip_id, _ in clip_items[:]]
@@ -278,7 +279,7 @@ def get_scene(self, scene_info: SceneMetadata) -> Scene:
278279
)
279280

280281
@staticmethod
281-
def get_df_from_path(
282+
def get_ego_df_from_path(
282283
scene_path: str,
283284
scene_name: str,
284285
verbose: bool = False,
@@ -598,7 +599,7 @@ def get_row_first_seen(df: pd.DataFrame) -> pd.DataFrame:
598599
def get_agent_info(
599600
self, scene: Scene, cache_path: Path, cache_class: Type[SceneCache]
600601
) -> Tuple[List[AgentMetadata], List[List[AgentMetadata]]]:
601-
sorted_df = self.get_df_from_path(self.clip_dir[scene.name], scene.name)
602+
sorted_df = self.get_ego_df_from_path(self.clip_dir[scene.name], scene.name)
602603

603604
contain_obstacles: bool = False
604605
agent_list: List[AgentMetadata] = []
@@ -761,12 +762,10 @@ def cache_maps(
761762

762763
def _debug_dump_scene_df(data_src: Optional[str] = None) -> None:
763764
"""Debug helper to inspect one scene dataframe when run as a script."""
764-
scene_path = (
765-
"/lustre/fsw/portfolios/nvr/users/xweng/agentdriver_alpamayo/data/new_data"
766-
)
765+
scene_path = 'path/to/source/data'
767766
scene_name = "762e063d-6eb9-43ae-959c-e53af10b53f9"
768767
scene_path = os.path.join(scene_path, scene_name)
769-
ego_df: pd.DataFrame = MADSDataset.get_df_from_path(
768+
ego_df: pd.DataFrame = MADSDataset.get_ego_df_from_path(
770769
scene_path, scene_name, verbose=True, data_src=data_src
771770
)
772771

src/trajdata/dataset_specific/mads/mads_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
#
1516

1617
import multiprocessing
1718
import os

src/trajdata/dataset_specific/mads/tar_extractor.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
# Copyright (c) 2025 NVIDIA CORPORATION. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) <2026> NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
217
"""Tar extraction utilities for component data files.
318
419
Provides TarExtractor class for extracting tar archives to RAM filesystem

src/trajdata/dataset_specific/pai/pai_dataset.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def compute_metadata(self, env_name: str, data_dir: str) -> EnvMetadata:
5151
egomotion_dir = Path(self.data_dir) / "labels" / "egomotion"
5252
if not egomotion_dir.exists():
5353
raise FileNotFoundError(
54-
f"Expected PAI egomotion directory at {egomotion_dir}."
54+
f"Expected PhysicalAI-AV egomotion directory at {egomotion_dir}."
5555
)
5656

5757
clip_dir: Dict[str, str] = {}
@@ -85,7 +85,7 @@ def compute_metadata(self, env_name: str, data_dir: str) -> EnvMetadata:
8585
self.clip_duration = clip_duration
8686

8787
clip_items = list(clip_dir.items())
88-
random.shuffle(clip_items)
88+
random.Random(42).shuffle(clip_items)
8989
self.clip_dir = dict(clip_items)
9090

9191
all_clips = [clip_id for clip_id, _ in clip_items]
@@ -199,7 +199,7 @@ def _load_ego_df(scene_path: str) -> pd.DataFrame:
199199
return pd.read_parquet(scene_path)
200200

201201
@staticmethod
202-
def get_df_from_path(
202+
def get_ego_df_from_path(
203203
scene_path: str,
204204
scene_name: str,
205205
verbose: bool = False,
@@ -243,24 +243,10 @@ def get_df_from_path(
243243
elif all(key in ego_df.columns for key in prefixed_map.keys()):
244244
normalized = ego_df.rename(columns=prefixed_map).copy()
245245
else:
246+
expected_cols = [*col_map.keys(), *prefixed_map.keys()]
246247
missing = [
247248
key
248-
for key in [
249-
"x",
250-
"y",
251-
"z",
252-
"qx",
253-
"qy",
254-
"qz",
255-
"qw",
256-
"EgomotionEstimate.location.x",
257-
"EgomotionEstimate.location.y",
258-
"EgomotionEstimate.location.z",
259-
"EgomotionEstimate.orientation.x",
260-
"EgomotionEstimate.orientation.y",
261-
"EgomotionEstimate.orientation.z",
262-
"EgomotionEstimate.orientation.w",
263-
]
249+
for key in expected_cols
264250
if key not in ego_df.columns
265251
]
266252
raise KeyError(
@@ -359,7 +345,7 @@ def _interp(col_name: str) -> np.ndarray:
359345
def get_agent_info(
360346
self, scene: Scene, cache_path: Path, cache_class: Type[SceneCache]
361347
) -> Tuple[List[AgentMetadata], List[List[AgentMetadata]]]:
362-
ego_df = self.get_df_from_path(self.clip_dir[scene.name], scene.name)
348+
ego_df = self.get_ego_df_from_path(self.clip_dir[scene.name], scene.name)
363349
ego_df.set_index(["agent_id", "scene_ts"], inplace=True)
364350

365351
ego_metadata = AgentMetadata(

src/trajdata/utils/env_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ def get_raw_dataset(dataset_name: str, data_dir: str) -> RawDataset:
5858
if "mads" in dataset_name.lower():
5959
from trajdata.dataset_specific.mads import MADSDataset
6060

61-
return MADSDataset(dataset_name, data_dir, parallelizable=True, has_maps=False)
61+
return MADSDataset(dataset_name, data_dir, parallelizable=True, has_maps=True)
6262

6363
if "pai" in dataset_name.lower():
6464
from trajdata.dataset_specific.pai import PAIDataset
65+
6566
return PAIDataset(dataset_name, data_dir, parallelizable=True, has_maps=False)
6667

6768
raise ValueError(f"Dataset with name '{dataset_name}' is not supported")

0 commit comments

Comments
 (0)