Coder Social home page Coder Social logo

Comments (1)

Morphlng avatar Morphlng commented on May 26, 2024

player_future is not a sensor; it is the future trajectory based on current observation. The data collected by SaveToDiskWrapper does not contain this, it is post-processed by the process method in CARLADataset.

def process(
dataset_dir: str,
output_dir: str,
future_length: int = 80,
past_length: int = 20,
num_frame_skips: int = 5,
) -> None:
"""Converts a raw dataset to demonstrations for imitation learning.
Args:
dataset_dir: The full path to the raw dataset.
output_dir: The full path to the output directory.
future_length: The length of the future trajectory.
past_length: The length of the past trajectory.
num_frame_skips: The number of frames to skip.
"""
from oatomobile.utils import carla as cutil
# Creates the necessary output directory.
os.makedirs(output_dir, exist_ok=True)
# Iterate over all episodes.
for episode_token in tqdm.tqdm(os.listdir(dataset_dir)):
logging.debug("Processes {} episode".format(episode_token))
# Initializes episode handler.
episode = Episode(parent_dir=dataset_dir, token=episode_token)
# Fetches all `.npz` files from the raw dataset.
try:
sequence = episode.fetch()
except FileNotFoundError:
continue
# Always keep `past_length+future_length+1` files open.
assert len(sequence) >= past_length + future_length + 1
for i in tqdm.trange(
past_length,
len(sequence) - future_length,
num_frame_skips,
):
try:
# Player context/observation.
observation = episode.read_sample(sample_token=sequence[i])
current_location = observation["location"]
current_rotation = observation["rotation"]
# Build past trajectory.
player_past = list()
for j in range(past_length, 0, -1):
past_location = episode.read_sample(
sample_token=sequence[i - j],
attr="location",
)
player_past.append(past_location)
player_past = np.asarray(player_past)
assert len(player_past.shape) == 2
player_past = cutil.world2local(
current_location=current_location,
current_rotation=current_rotation,
world_locations=player_past,
)
# Build future trajectory.
player_future = list()
for j in range(1, future_length + 1):
future_location = episode.read_sample(
sample_token=sequence[i + j],
attr="location",
)
player_future.append(future_location)
player_future = np.asarray(player_future)
assert len(player_future.shape) == 2
player_future = cutil.world2local(
current_location=current_location,
current_rotation=current_rotation,
world_locations=player_future,
)
# Store to ouput directory.
np.savez_compressed(
os.path.join(output_dir, "{}.npz".format(sequence[i])),
**observation,
player_future=player_future,
player_past=player_past,
)
except Exception as e:
if isinstance(e, KeyboardInterrupt):
sys.exit(0)

from oatomobile.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.