Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no implementation of "player_future" sensor #22

Open
wxdublin opened this issue Nov 13, 2021 · 1 comment
Open

There is no implementation of "player_future" sensor #22

wxdublin opened this issue Nov 13, 2021 · 1 comment

Comments

@wxdublin
Copy link

I am trying to collect dataset using baselines/rulebased/autopilot/run.py. It worked but after I added "player_future" in the sensors list it still did not produce the player_future files. Looks like there is no player_future implementation?

@Morphlng
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants