Skip to content

Move dataset converter tool #1782

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

Merged
merged 5 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/traffic_histories_vehicle_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load_data_for_vehicle(

datafile = f"collected_observations/Agent-history-vehicle-{vehicle_id}.pkl"
# We read actions from a datafile previously-generated by the
# traffic_histories_to_observations.py script.
# `smarts/dataset/traffic_histories_to_observations.py` script.
# This allows us to test the action space to ensure that it
# can recreate the original behaviour.
with open(datafile, "rb") as pf:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import argparse
import logging
import math
Expand All @@ -10,7 +30,6 @@
from PIL import Image

from envision.client import Client as Envision
from smarts import sstudio
from smarts.core import seed as smarts_seed
from smarts.core.agent_interface import (
OGM,
Expand All @@ -30,9 +49,15 @@
from smarts.core.smarts import SMARTS
from smarts.core.sumo_traffic_simulation import SumoTrafficSimulation
from smarts.core.vehicle import VEHICLE_CONFIGS
from smarts.sstudio.scenario_construction import build_scenario


class ObservationRecorder:
"""
Generate SMARTS observations from the perspective of one or more
social/history vehicles within a SMARTS scenario.
"""

def __init__(
self,
scenario: str,
Expand All @@ -42,9 +67,7 @@ def __init__(
start_time: Optional[float] = None,
end_time: Optional[float] = None,
):
"""Generate Observations from the perspective of one or more
social/history vehicles within a SMARTS scenario.

"""
Args:
scenario (str):
A path to a scenario to run.
Expand Down Expand Up @@ -136,8 +159,7 @@ def _create_default_interface(
def collect(
self, vehicles_with_sensors: Optional[Sequence[int]], headless: bool = True
):
"""Generate Observations from the perspective of one or more
social/history vehicles within a SMARTS scenario.
"""Records SMARTS observations for selected vehicles.

Args:
vehicles_with_sensors (Sequence[int], optional):
Expand Down Expand Up @@ -391,7 +413,7 @@ def _record_data(
args = parser.parse_args()

if not args.no_build:
sstudio.build_scenario([args.scenario])
build_scenario(clean=False, scenario=args.scenario, seed=args.seed)

recorder = ObservationRecorder(
scenario=args.scenario,
Expand Down
2 changes: 0 additions & 2 deletions smarts/waymo/waymo_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# pytype: disable=import-error

# Text based Waymo Dataset Browser.
import argparse
import copy
Expand Down