Skip to content

Commit

Permalink
Merge branch 'master' into zoo-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Adaickalavan committed Nov 15, 2023
2 parents ba31fe5 + c164c5c commit 9b15763
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 104 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Changed
### Deprecated
### Fixed
- Fixed an issue where `SMARTS` might not be explicitly destroyed in the `ros_driver`.
- Fixed issue where `SumoTrafficSimulation` could get locked up on reset if a scenario had only 1 map but multiple scenario variations.
- Fixed an issue where an out-of-scope method reference caused a pickling error.
- Fixed an issue where the `EnvisionDataFormatterArgs` default would use a locally defined lambda and cause a serialization failure.
- Fixed an issue where user configuration was being overridden.
- Fixed a `pkg_resources` deprecation warning in `python3.10` and up.
### Removed
### Security

Expand Down
28 changes: 25 additions & 3 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,32 @@ Demo Video
Prerequisites
-------------

+ ``python3 (3.8 or 3.9)``
+ ``python3 (3.8, 3.9, 3.10, 3.11)``
+ ``ubuntu (>=16.04)``

Installation
------------

Package
^^^^^^^

This includes SMARTS but none of the examples.

.. code-block:: bash
# For Mac OS X users, ensure XQuartz is pre-installed.
# Install the system requirements. You may use the `-y` option to enable
# automatic assumption of "yes" to all prompts to avoid timeout from
# waiting for user input.
$ bash utils/setup/install_deps.sh
# This should install the latest version of SMARTS from package index (generally PyPI).
$ pip install 'smarts[camera_obs,sumo,example]'
Development
^^^^^^^^^^^

Run the following commands to setup the SMARTS simulator.

.. code-block:: bash
Expand Down Expand Up @@ -61,9 +81,11 @@ Run the following commands to setup the SMARTS simulator.
# Install smarts with extras as needed. Extras include the following:
# `camera_obs` - needed for rendering camera observations, and for testing.
# `sumo` - needed for using SUMO scenarios.
# `test` - needed for testing.
# `test` - needed for running tests.
# `example` - needed for running examples.
$ pip install -e .[camera_obs,sumo,test,example]
# `--config-settings editable_mode=strict` - may be needed depending on version of setuptools.
# See https://github.com/huawei-noah/SMARTS/issues/2090.
$ pip install -e '.[camera_obs,sumo,test,example]' --config-settings editable_mode=strict
# Run sanity-test and verify they are passing.
# If tests fail, check './sanity_test_result.xml' for test report.
Expand Down
9 changes: 5 additions & 4 deletions envision/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class SingleAttributeOverride(NamedTuple):
"""The maximum number of elements an iterable attribute can contain."""


def _default_override():
return SingleAttributeOverride(True, None)


@dataclass(frozen=True)
class EnvisionStateFilter:
"""A state filtering tool."""
Expand All @@ -49,7 +53,4 @@ class EnvisionStateFilter:
def default(cls):
"""Give a new default filter."""

def default_override():
return SingleAttributeOverride(True, None)

return cls(defaultdict(default_override), defaultdict(default_override))
return cls(defaultdict(_default_override), defaultdict(_default_override))
6 changes: 5 additions & 1 deletion envision/data_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Operation(IntEnum):
_primitives = {int, float, str, VehicleType, TrafficActorType}


def _passthrough_method_1_arg(v):
return v


class ReductionContext:
"""Mappings between an object and its reduction to an ID."""

Expand Down Expand Up @@ -126,7 +130,7 @@ class EnvisionDataFormatterArgs(NamedTuple):
"""Data formatter configurations."""

id: Optional[str]
serializer: Callable[[list], Any] = lambda d: d
serializer: Callable[[list], Any] = _passthrough_method_1_arg
float_decimals: int = 2
bool_as_int: bool = True
enable_reduction: bool = True
Expand Down
3 changes: 0 additions & 3 deletions envision/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
from envision.web import dist as web_dist
from smarts.core.utils.file import path2hash

logging.basicConfig(level=logging.WARNING)


# Mapping of simulation IDs to a set of web client run loops
WEB_CLIENT_RUN_LOOPS = {}

Expand Down
8 changes: 5 additions & 3 deletions envision/tests/test_data_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
TIMESTEP_SEC = 0.1


class KeepLaneAgent(Agent):
def act(self, obs):
return "keep_lane"


@pytest.fixture
def agent_spec():
class KeepLaneAgent(Agent):
def act(self, obs):
return "keep_lane"

return AgentSpec(
interface=AgentInterface.from_type(
Expand Down
6 changes: 6 additions & 0 deletions examples/e2_single_agent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"""This example shows how you might run a SMARTS environment for single-agent work. SMARTS is
natively multi-agent so a single-agent wrapper is used."""
import argparse
import logging
import random
import sys
import warnings
from pathlib import Path
from typing import Final

logging.basicConfig(level=logging.ERROR)
warnings.filterwarnings("ignore")


import gymnasium as gym

SMARTS_REPO_PATH = Path(__file__).parents[1].absolute()
Expand Down
3 changes: 1 addition & 2 deletions examples/replay/replay_klws_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from smarts.env.utils.observation_conversion import ObservationOptions
from smarts.zoo.registry import make as zoo_make

logging.basicConfig(level=logging.INFO)

AGENT_ID = "Agent-007"


Expand Down Expand Up @@ -116,6 +114,7 @@ def main(scenarios, sim_name, headless, seed, speed, max_steps, save_dir, write)


if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
parser = default_argument_parser("klws-agent-example")
parser.add_argument(
"--speed",
Expand Down
90 changes: 45 additions & 45 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,86 @@ aiosignal==1.3.1
astunparse==1.6.3
attrs==23.1.0
Automat==22.10.0
cachetools==5.3.1
cachetools==5.3.2
certifi==2023.7.22
charset-normalizer==3.2.0
charset-normalizer==3.3.2
click==8.1.7
cloudpickle==2.2.1
cmake==3.27.5
constantly==15.1.0
coverage==7.3.1
cloudpickle==3.0.0
constantly==23.10.4
coverage==7.3.2
decorator==5.1.1
dm-tree==0.1.8
exceptiongroup==1.1.3
execnet==2.0.2
filelock==3.12.4
filelock==3.13.1
flatbuffers==23.5.26
frozenlist==1.4.0
fsspec==2023.10.0
future==0.18.3
gast==0.4.0
google-auth==2.23.1
google-auth==2.23.4
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
grpcio==1.51.3
Gymnasium==0.26.3
gymnasium-notices==0.0.1
h5py==3.9.0
h5py==3.10.0
hyperlink==21.0.0
idna==3.4
imageio==2.31.4
imageio==2.32.0
importlib-metadata==6.8.0
importlib-resources==6.1.0
importlib-resources==6.1.1
incremental==22.10.0
iniconfig==2.0.0
Jinja2==3.1.2
jsonschema==4.19.1
jsonschema==4.19.2
jsonschema-specifications==2023.7.1
keras==2.13.1
lazy_loader==0.3
libclang==16.0.6
lit==17.0.1
lz4==4.3.2
Markdown==3.4.4
Markdown==3.5.1
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdurl==0.1.2
mpmath==1.3.0
msgpack==1.0.7
networkx==3.1
numpy==1.24.3
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-cupti-cu11==11.7.101
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
nvidia-cufft-cu11==10.9.0.58
nvidia-curand-cu11==10.2.10.91
nvidia-cusolver-cu11==11.4.0.1
nvidia-cusparse-cu11==11.7.4.91
nvidia-nccl-cu11==2.14.3
nvidia-nvtx-cu11==11.7.91
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.18.1
nvidia-nvjitlink-cu12==12.3.52
nvidia-nvtx-cu12==12.1.105
oauthlib==3.2.2
opencv-python==4.8.1.78
opencv-python-headless==4.8.1.78
opt-einsum==3.3.0
packaging==23.1
packaging==23.2
Panda3D==1.10.13
panda3d-gltf==0.13
panda3d-simplepbr==0.10
pandas==2.0.3
Pillow==10.0.1
pkgutil_resolve_name==1.3.10
pluggy==1.3.0
protobuf==4.24.3
psutil==5.9.5
protobuf==4.25.0
psutil==5.9.6
py==1.11.0
py-cpuinfo==9.0.0
pyarrow==13.0.0
pyarrow==14.0.1
pyasn1==0.5.0
pyasn1-modules==0.3.0
pybullet==3.2.5
Pygments==2.16.1
pytest==7.4.2
pytest==7.4.3
pytest-benchmark==4.0.0
pytest-cov==4.1.0
pytest-forked==1.6.0
Expand All @@ -95,17 +95,17 @@ ray==2.5.1
referencing==0.30.2
requests==2.31.0
requests-oauthlib==1.3.1
rich==13.5.3
rpds-py==0.10.3
rich==13.6.0
rpds-py==0.12.0
rsa==4.9
scikit-image==0.21.0
scipy==1.10.1
shapely==2.0.1
shapely==2.0.2
six==1.16.0
sympy==1.12
tableprint==0.9.1
tensorboard==2.13.0
tensorboard-data-server==0.7.1
tensorboard-data-server==0.7.2
tensorboardX==2.6.2.2
tensorflow==2.13.1
tensorflow-estimator==2.13.0
Expand All @@ -114,18 +114,18 @@ tensorflow-probability==0.21.0
termcolor==2.3.0
tifffile==2023.7.10
tomli==2.0.1
torch==2.0.1
torchvision==0.15.2
trimesh==3.23.5
triton==2.0.0
Twisted==23.8.0
torch==2.1.0
torchvision==0.16.0
trimesh==4.0.3
triton==2.1.0
Twisted==23.10.0
typer==0.9.0
typing_extensions==4.5.0
tzdata==2023.3
urllib3==2.0.5
wcwidth==0.2.6
Werkzeug==2.3.7
wrapt==1.15.0
yattag==1.15.1
urllib3==2.0.7
wcwidth==0.2.9
Werkzeug==3.0.1
wrapt==1.16.0
yattag==1.15.2
zipp==3.17.0
zope.interface==6.0
zope.interface==6.1
11 changes: 8 additions & 3 deletions smarts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

try:
from importlib.metadata import version

import pkg_resources
VERSION = version("smarts")
except:
# This is now deprecated `https://setuptools.pypa.io/en/latest/pkg_resources.html`
import pkg_resources

# The full version, including alpha/beta/rc tags
VERSION = pkg_resources.get_distribution("smarts").version
# The full version, including alpha/beta/rc tags
VERSION = pkg_resources.get_distribution("smarts").version
2 changes: 0 additions & 2 deletions smarts/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import warnings
from typing import Any, Callable

warnings.simplefilter("once")

logger = logging.getLogger(__name__)


Expand Down
14 changes: 7 additions & 7 deletions smarts/ros/src/smarts_ros/scripts/ros_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,15 @@ def run_forever(self):

self._publish_state()
self._publish_agents(observations, dones)
except Exception as e:
if isinstance(e, rospy.ROSInterruptException):
raise e
except Exception as ex:
if isinstance(ex, rospy.ROSInterruptException):
raise ex
batch_mode = rospy.get_param("~batch_mode", False)
if not batch_mode:
raise e
raise ex
import traceback

rospy.logerr(f"SMARTS raised exception: {e}")
rospy.logerr(f"SMARTS raised exception: {ex}")
rospy.logerr(traceback.format_exc())
rospy.logerr("Will wait for next reset...")
self._smarts = None
Expand All @@ -712,8 +712,8 @@ def run_forever(self):

except rospy.ROSInterruptException:
rospy.loginfo("ROS interrupted. exiting...")

self._reset() # cleans up the SMARTS instance...
finally:
self._reset() # cleans up the SMARTS instance...


if __name__ == "__main__":
Expand Down
2 changes: 0 additions & 2 deletions smarts/zoo/agent_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from smarts.core.agent import Agent
from smarts.core.agent_interface import AgentInterface

warnings.simplefilter("once")


@dataclass
class AgentSpec(object):
Expand Down
Loading

0 comments on commit 9b15763

Please sign in to comment.