commaSteeringControl / commaSteeringControl.py
nuwandavek's picture
change features
13f2b77
raw
history blame
2.29 kB
import datasets
import pandas as pd
import pyarrow as pa
PLATFORMS = ["ACURA_RDX_2020", "AUDI_A3_3RD_GEN"]
_URLS = [f'https://huggingface.co/datasets/commaai/commaSteeringControl/resolve/main/data/{platform}.zip' for platform in PLATFORMS]
_DESCRIPTION = "Steering controls dataset from cars running openpilot"
N = 600
class CommaSteeringControl(datasets.ArrowBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"t": datasets.Array2D(shape=(1, N), dtype='float'),
"latActive": datasets.Array2D(shape=(1, N), dtype='bool'),
"steeringPressed": datasets.Array2D(shape=(1, N), dtype='bool'),
"vEgo": datasets.Array2D(shape=(1, N), dtype='float'),
"aEgo": datasets.Array2D(shape=(1, N), dtype='float'),
"steeringAngleDeg": datasets.Array2D(shape=(1, N), dtype='float'),
"steer": datasets.Array2D(shape=(1, N), dtype='float'),
"steerFiltered": datasets.Array2D(shape=(1, N), dtype='float'),
"roll": datasets.Array2D(shape=(1, N), dtype='float'),
"latAccelSteeringAngle": datasets.Array2D(shape=(1, N), dtype='float'),
"latAccelDesired": datasets.Array2D(shape=(1, N), dtype='float'),
"latAccelLocalizer": datasets.Array2D(shape=(1, N), dtype='float'),
"epsFwVersion": datasets.Array2D(shape=(1, N), dtype='string'),
}
)
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download(_URLS)
return [
datasets.SplitGenerator(
name=PLATFORMS[i],
gen_kwargs={
"files": dl_manager.iter_archive(downloaded_files[i])
}
) for i in range(len(downloaded_files))
]
def _generate_tables(self, files):
for path in files:
df = pd.read_csv(path[1])
pa_table = pa.Table.from_pandas(df)
# print(pa_table)
yield path[0], pa_table
# def _get_examples_iterable_for_split(self, split_generator):
# for path in split_generator.gen_kwargs['files']:
# df = pandas.read_csv(path[1])
# yield path[0], df
# ds = CommaSteeringControl(use_auth_token=True)
# dp = ds.as_streaming_dataset(split="AUDI_A3_3RD_GEN")
# for p in dp:
# print(p)
# break