Skip to content

tactics2d.dataset_parser

ArgoverseParser

This class implements a parser for Argoverse dataset. The default size of the participants are referred to the official visualization toolkit.

Reference

Wilson, Benjamin, et al. "Argoverse 2: Next generation datasets for self-driving perception and forecasting." arXiv preprint arXiv:2301.00493 (2023).

parse_map(file, folder)

This function parses a map from a single Argoverse json file.

Parameters:

Name Type Description Default
file str

The name of the map file. The file is expected to be a json file (.json).

required
folder str

The path to the folder containing the map data.

required

Returns:

Name Type Description
map_ Map

A map object.

parse_trajectory(file, folder)

This function parses trajectories from a single Argoverse parquet file. Because the duration of the scenario has been well articulated, the parser will not provide an option to select time range within a single scenario. The states were collected at 10Hz.

Parameters:

Name Type Description Default
file str

The name of the trajectory data file. The file is expected to be a parquet file.

required
folder str

The path to the folder containing the trajectory data.

required

Returns:

Name Type Description
participants dict

A dictionary of participants. The keys are the ids of the participants. The values are the participants.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

DLPParser

This class implements a parser of the Dragon Lake Parking Dataset.

Reference

Shen, Xu, et al. "Parkpredict: Motion and intent prediction of vehicles in parking lots." 2020 IEEE Intelligent Vehicles Symposium (IV). IEEE, 2020.

parse_trajectory(file, folder, stamp_range=None)

This function parses trajectories from a series of DLP dataset files. The states were collected at 25Hz.

Parameters:

Name Type Description Default
file Union[int, str]

The id or the name of the trajectory file. The file is expected to be a json file (.json). If the input is an integer, the parser will parse the trajectory data from the following files: DJI_%04d_agents.json % file, DJI_%04d_frames.json % file, DJI_%04d_instances.json % file, DJI_%04d_obstacles.json % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required
stamp_range Tuple[float, float]

The time range of the trajectory data to parse. The unit of time stamp is millisecond (ms). If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
participants dict

A dictionary of vehicles. The keys are the ids of the vehicles. The values are the vehicles.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

InteractionParser

This class implements a parser for INTERACTION dataset.

Reference

Zhan, Wei, et al. "Interaction dataset: An international, adversarial and cooperative motion dataset in interactive driving scenarios with semantic maps." arXiv preprint arXiv:1910.03088 (2019).

get_time_range(file, folder)

This function gets the time range of a single trajectory data file.

Parameters:

Name Type Description Default
file Union[int, str]

The id or the name of the trajectory file. If the input is an integer, the parser will parse the trajectory data from the following files: vehicle_tracks_%03d.csv % file, pedestrian_tracks_%03d.csv % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required

Returns:

Name Type Description
actual_stamp_range Tuple[int, int]

The time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

parse_pedestrians(participants, file_path, time_range=None)

This function parses the pedestrian trajectory file in INTERACTION dataset. Because the original dataset does not distinguish cyclist and pedestrian, this function calls a type guesser, which is built from other datasets, to guess the type of the participants.

Parameters:

Name Type Description Default
participants dict

A dictionary of participants.

required
file_path str

The path to the pedestrian trajectory file.

required
time_range Tuple[float, float]

The time range of the trajectory data to parse. The unit of time stamp is millisecond (ms). If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
participants dict

A dictionary of participants. The keys are the ids of the participants. The values are the participants.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

parse_trajectory(file, folder, time_range=None)

Parse the trajectory data of INTERACTION dataset. The states were collected at 10Hz.

Parameters:

Name Type Description Default
file Union[int, str]

The id or the name of the trajectory file. If the input is an integer, the parser will parse the trajectory data from the following files: vehicle_tracks_%03d.csv % file, pedestrian_tracks_%03d.csv % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required
time_range Tuple[float, float]

The time range of the trajectory data to parse. The unit of time stamp is millisecond (ms). If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
participants dict

A dictionary of participants. The keys are the ids of the participants. The values are the participants.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

parse_vehicle(file_path, time_range=None)

This function parses the vehicle trajectory file in INTERACTION dataset.

Parameters:

Name Type Description Default
file_path str

The path to the vehicle trajectory file.

required
time_range Tuple[float, float]

The time range of the trajectory data to parse. The unit of time stamp is millisecond (ms). If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
vehicles dict

A dictionary of vehicles. The keys are the ids of the vehicles. The values are the vehicles.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond (ms).

LevelXParser

This class implements a parser for the series of datasets collected by the Institute for Automotive Engineering (ika) of RWTH Aachen University. Because the commercial version of the datasets are held by LevelXData, we call this series of datasets LevelX-series datasets. The datasets include: highD, inD, rounD, exiD, uniD.

Reference

Krajewski, Robert, et al. "The highd dataset: A drone dataset of naturalistic vehicle trajectories on german highways for validation of highly automated driving systems." 2018 21st international conference on intelligent transportation systems (ITSC). IEEE, 2018.

Bock, Julian, et al. "The ind dataset: A drone dataset of naturalistic road user trajectories at german intersections." 2020 IEEE Intelligent Vehicles Symposium (IV). IEEE, 2020.

Krajewski, Robert, et al. "The round dataset: A drone dataset of road user trajectories at roundabouts in germany." 2020 IEEE 23rd International Conference on Intelligent Transportation Systems (ITSC). IEEE, 2020.

Moers, Tobias, et al. "The exiD dataset: A real-world trajectory dataset of highly interactive highway scenarios in Germany." 2022 IEEE Intelligent Vehicles Symposium (IV). IEEE, 2022.

Bock, Julian, et al. "Highly accurate scenario and reference data for automated driving." ATZ worldwide 123.5 (2021): 50-55.

__init__(dataset='')

Initialize the parser.

Parameters:

Name Type Description Default
dataset str

The dataset you want to parse. The available choices are: highD, inD, rounD, exiD, uniD.

''

get_location(file, folder)

This function retrieves the location from which a trajectory data file is obtained.

Parameters:

Name Type Description Default
file Union[int, str]

The id or the name of the trajectory file. If the input is an integer, the parser will parse the trajectory data from the following files: %02d_recordingMeta.csv % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required

Returns:

Name Type Description
location_id int

The id of the location.

get_stamp_range(file, folder)

This function gets the time range of a single trajectory data file.

Parameters:

Name Type Description Default
file Union[int, str]

The id or the name of the trajectory file. If the input is an integer, the parser will parse the trajectory data from the following files: %02d_tracksMeta.csv" % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required

Returns:

Name Type Description
actual_stamp_range Tuple[int, int]

The time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond.

parse_map(**kwargs)

TODO: provide an API similar to other parsers to parse the map data. At present the map data are self-built and can be parsed by the Lanelet2Parser.

parse_trajectory(file, folder, stamp_range=None)

This function parses the trajectory data of LevelX-series datasets. The states were collected at 25Hz.

Parameters:

Name Type Description Default
file int

The id or the name of the trajectory file. If the input is an integer, the parser will parse the trajectory data from the following files: %02d_tracks.csv % file and %02d_tracksMeta.csv % file. If the input is a string, the parser will extract the integer id first and repeat the above process.

required
folder str

The path to the folder containing the trajectory data.

required
stamp_range Tuple[int, int]

The time range of the trajectory data to parse. The unit of time stamp is millisecond. If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
participants dict

A dictionary of participants. The keys are the ids of the participants. The values are the participants.

actual_stamp_range Tuple[int, int]

The actual time range of the trajectory data. The first element is the start time. The second element is the end time. The unit of time stamp is millisecond.

NuPlanParser

This class implements a parser for NuPlan dataset.

Reference

Caesar, Holger, et al. "nuplan: A closed-loop ml-based planning benchmark for autonomous vehicles." arXiv preprint arXiv:2106.11810 (2021).

get_location(file, folder)

This function gets the location of a single trajectory data file.

Parameters:

Name Type Description Default
file str

The name of the trajectory data file. The file is expected to be a sqlite3 database file (.db).

required
folder str

The path to the folder containing the trajectory file.

required

Returns:

Name Type Description
location str

The location of the trajectory data file.

parse_map(file, folder)

This function parses a map from a single NuPlan map file. The map file is expected to be a geopackage file (.gpkg).

TODO: the parsing of lane connectors is not implemented yet.

A NuPlan map includes the following layers: 'baseline_paths', 'carpark_areas', 'generic_drivable_areas', 'dubins_nodes', 'lane_connectors', 'intersections', 'boundaries', 'crosswalks', 'lanes_polygons', 'lane_group_connectors', 'lane_groups_polygons', 'road_segments', 'stop_polygons', 'traffic_lights', 'walkways', 'gen_lane_connectors_scaled_width_polygons', 'meta'. In this parser, we only parse the following layers: 'boundaries', 'lanes_polygons', 'lane_connectors', 'carpark_areas', 'crosswalks', 'walkways', 'stop_polygons', 'traffic_lights'

parse_trajectory(file, folder, stamp_range=None)

This function parses trajectories from a single NuPlan database file.

Parameters:

Name Type Description Default
file str

The name of the trajectory data file. The file is expected to be a sqlite3 database file (.db).

required
folder str

The path to the folder containing the trajectory file.

required
stamp_range Tuple[float, float]

The time range of the trajectory data to parse. If the stamp range is not given, the parser will parse the whole trajectory data.

None

Returns:

Name Type Description
participants dict

A dictionary of participants. The keys are the ids of the participants. The values are the participants.

stamps List[int]

The actual time range of the trajectory data. Because NuPlan collects data at an unstable frequency, the parser will return a list of time stamps.

WOMDParser

This class implements a parser for Waymo Open Motion Dataset (WOMD).

Reference

Ettinger, Scott, et al. "Large scale interactive motion forecasting for autonomous driving: The waymo open motion dataset." Proceedings of the IEEE/CVF International Conference on Computer Vision. 2021.

Because loading the tfrecord file is time consuming, the trajectory and the map parsers provide two ways to load the file. The first way is to load the file directly from the given file path. The second way is to load the file from a tf.data.TFRecordDataset object. If the tf.data.TFRecordDataset object is given, the parser will ignore the file path.

get_scenario_ids(dataset)

This function get the list of scenario ids from the given tfrecord file.

Parameters:

Name Type Description Default
dataset TFRecordDataset

The dataset to parse.

required

Returns:

Name Type Description
id_list List[str]

A list of scenario ids looking like ["637f20cafde22ff8", ...].

parse_map(scenario_id=None, **kwargs)

This function parses the map from a single WOMD file.

Parameters:

Name Type Description Default
scenario_id str

The id of the scenario to parse. If the scenario id is not given, the first scenario in the file will be parsed.

None

Other Parameters:

Name Type Description
dataset TFRecordDataset

The dataset to parse.

file str

The name of the trajectory file. The file is expected to be a tfrecord file (.tfrecord).

folder str

The path to the folder containing the tfrecord file.

Returns:

Name Type Description
map_ Map

A map object.

Raises:

Type Description
KeyError

Either dataset or file and folder should be given as keyword arguments.

parse_trajectory(scenario_id=None, **kwargs)

This function parses trajectories from a single WOMD file. Because the duration of the scenario has been well articulated, the parser will not provide an option to select time range within a single scenario. The states were collected at 10Hz.

Parameters:

Name Type Description Default
scenario_id Union[str, int]

The id of the scenario to parse. If the scenario id is a string, the parser will search for the scenario id in the file. If the scenario id is an integer, the parser will parse scenario_id-th scenario in the file. If the scenario id is None or is not found, the first scenario in the file will be parsed.

None

Other Parameters:

Name Type Description
dataset TFRecordDataset

The dataset to parse.

file str

The name of the trajectory file. The file is expected to be a tfrecord file (.tfrecord).

folder str

The path to the folder containing the tfrecord file.

Returns:

Name Type Description
participants dict

A dictionary of participants. If the scenario id is not found, return None.

stamps List[int]

The actual time range of the trajectory data. Because WOMD collects data at an unstable frequency, the parser will return a list of time stamps.

Raises:

Type Description
KeyError

Either dataset or file and folder should be given as keyword arguments.