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

Release version 1.0.2 #1819

Merged
merged 3,101 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3101 commits
Select commit Hold shift + click to select a range
292acd3
GitHub Actions: Update mac_requirements.txt
Gamenot Nov 28, 2022
9e25652
Envision: "All Simulation" Button (#1761)
qianyi-sun Nov 30, 2022
f586f33
GitHub Actions: Update requirements.txt
qianyi-sun Nov 30, 2022
f90705a
GitHub Actions: Update mac_requirements.txt
Gamenot Dec 5, 2022
9904e94
Speed up rllib test (#1767)
Gamenot Dec 6, 2022
04dcdfa
GitHub Actions: Update requirements.txt
Gamenot Dec 6, 2022
dbb44fc
GitHub Actions: Format
Gamenot Dec 6, 2022
9c823a5
Fix Envision visualization issue in "near real time" mode (#1766)
qianyi-sun Dec 6, 2022
3d7a1ae
GitHub Actions: Format
qianyi-sun Dec 6, 2022
82a05a7
Test rllibhiwayenv directly (#1769)
Gamenot Dec 8, 2022
280d478
GitHub Actions: Update requirements.txt
Gamenot Dec 8, 2022
3e1ec42
GitHub Actions: Update mac_requirements.txt
Gamenot Dec 12, 2022
f85dfb8
Updated use of shapely.geometry.Polygon and shapely.geometry.collecti…
Adaickalavan Dec 14, 2022
a142b6e
GitHub Actions: Update requirements.txt
Adaickalavan Dec 14, 2022
98706f9
GitHub Actions: Format
Adaickalavan Dec 14, 2022
44012d8
Suppress TraCI Error on simulationStep (#1770)
saulfield Dec 14, 2022
46acf1a
Performance metrics (#1753)
Adaickalavan Dec 14, 2022
67d58a7
Suppress the `DeprecationWarning` caused by the `trimesh` package (#1…
qianyi-sun Dec 16, 2022
5fe0964
Scenario Caching (#1764)
saulfield Dec 16, 2022
2872a54
GitHub Actions: Format
saulfield Dec 16, 2022
b8bf14f
GitHub Actions: Update cli.rst
saulfield Dec 16, 2022
3b3138d
GitHub Actions: Update mac_requirements.txt
Gamenot Dec 19, 2022
9aea454
rename all occurrences from `benchmark` to `diagnostic` (#1780)
qianyi-sun Dec 21, 2022
e52bfc8
GitHub Actions: Update requirements.txt
qianyi-sun Dec 21, 2022
237c29a
GitHub Actions: Update cli.rst
qianyi-sun Dec 21, 2022
57e8ba8
Fix `open-agent` setup error. (#1785)
Gamenot Dec 23, 2022
bdc1eb6
GitHub Actions: Update requirements.txt
Gamenot Dec 23, 2022
b5e2a86
Reorganize examples (#1784)
Adaickalavan Dec 23, 2022
491acb2
Removed trainer folder. (#1787)
Adaickalavan Dec 23, 2022
376bceb
Fix issues preventing minicity from working. (#1788)
Gamenot Dec 24, 2022
9e11f51
GitHub Actions: Update requirements.txt
Gamenot Dec 24, 2022
464de43
GitHub Actions: Update mac_requirements.txt
Gamenot Dec 26, 2022
a054332
Remove observation_adapter, action_adapter, reward_adapter, and info_…
Adaickalavan Dec 28, 2022
3754e9f
GitHub Actions: Update requirements.txt
Adaickalavan Dec 28, 2022
1b8d5b5
Move dataset generator tool (#1782)
Adaickalavan Dec 29, 2022
8891106
GitHub Actions: Update requirements.txt
Adaickalavan Dec 29, 2022
4d94867
GitHub Actions: Update mac_requirements.txt
Gamenot Jan 2, 2023
14149b5
Performance metrics - normalized, recomputed, overall score (#1772)
Adaickalavan Jan 5, 2023
31d3e8f
GitHub Actions: Update requirements.txt
Adaickalavan Jan 5, 2023
2c89263
Encapsulate traci connection utility.
Gamenot Dec 14, 2022
bdf7566
Retry connection persistently if process is alive.
Gamenot Dec 14, 2022
17fd99a
Update CHANGELOG.md
Gamenot Dec 14, 2022
be6c93e
Fix doctest.
Gamenot Dec 14, 2022
2654227
Fix for python3.7
Gamenot Dec 14, 2022
2b56a6f
Make format.
Gamenot Dec 14, 2022
e43b27f
Fix case where traci_conn is not set up.
Gamenot Dec 14, 2022
181b054
Fix error where sumo process is None.
Gamenot Dec 15, 2022
1fbd0b6
Clean up sumo traffic simulation class.
Gamenot Dec 15, 2022
69f2f97
Fix route finding bug.
Gamenot Dec 19, 2022
a60116c
Attempt another fix at connection
Gamenot Dec 19, 2022
310628c
Optimize connection check.
Gamenot Dec 19, 2022
603db5e
Fix formatting
Gamenot Dec 20, 2022
f8ad21b
Support up to SUMO 1.15.0
Gamenot Dec 20, 2022
99444ea
Update changelog.
Gamenot Dec 20, 2022
2579d55
Fix type errors
Gamenot Dec 21, 2022
9f0c8a9
Loosen sumo version
Gamenot Dec 21, 2022
4e492c5
Fix minimum sumo version
Gamenot Dec 21, 2022
89babdc
Remove SUMO home test.
Gamenot Dec 22, 2022
529933d
Use partition instead of split to prevent errors.
Gamenot Dec 22, 2022
479d2f1
Update CHANGELOG.md
Gamenot Dec 28, 2022
949ae1a
Update CHANGELOG.md
Gamenot Dec 28, 2022
9d1d960
Update CHANGELOG.md
Gamenot Dec 28, 2022
a0fa12e
Fix issues that occur when exceptions are thrown
Gamenot Dec 29, 2022
eee9d3e
Move sleep out of utility.
Gamenot Dec 29, 2022
ea346f8
Raise exception still.
Gamenot Dec 30, 2022
3286b94
Try optimization
Gamenot Dec 30, 2022
d510122
Improve the code quality.
Gamenot Dec 30, 2022
2cc0f75
GitHub Actions: Update requirements.txt
Gamenot Jan 5, 2023
6558768
Envision map fix (#1790)
saulfield Jan 5, 2023
e8bab4c
GitHub Actions: Update mac_requirements.txt
Gamenot Jan 9, 2023
94f72fa
CI test for performance metrics (#1778)
Adaickalavan Jan 13, 2023
754ebf2
GitHub Actions: Update requirements.txt
Adaickalavan Jan 13, 2023
ca1e5fd
GitHub Actions: Format
Adaickalavan Jan 13, 2023
d3d11e6
Fix notebook env
Gamenot Oct 11, 2022
5127862
Revert "Remove unused utility."
Gamenot Oct 11, 2022
c2b0b83
Add local version
Gamenot Oct 13, 2022
7caed9d
Update error with more information
Gamenot Oct 17, 2022
cab6cc1
Delete create_run_visualize.py
Gamenot Nov 16, 2022
97e35b5
GitHub Actions: Update requirements.txt
Gamenot Jan 16, 2023
2e51118
GitHub Actions: Format
Gamenot Jan 16, 2023
368ad92
GitHub Actions: Update mac_requirements.txt
Gamenot Jan 16, 2023
cba794a
Add road lines to RGB image observations (#1796)
saulfield Jan 18, 2023
7fd2909
GitHub Actions: Update requirements.txt
saulfield Jan 18, 2023
e9778cf
GitHub Actions: Format
saulfield Jan 18, 2023
9d94323
Revamped documentation (#1792)
Adaickalavan Jan 20, 2023
23cd773
GitHub Actions: Update requirements.txt
Adaickalavan Jan 20, 2023
97a00df
GitHub Actions: Format
Adaickalavan Jan 20, 2023
66cceab
Add base environment
Gamenot Jan 9, 2023
fca2e29
Close to a working environment.
Gamenot Jan 9, 2023
0f2db62
Simplify format_obs changes.
Gamenot Jan 10, 2023
5507637
Update original environments to support upgrades.
Gamenot Jan 10, 2023
8d0d0ae
Update documentation.
Gamenot Jan 10, 2023
70d9beb
Use class instead of assignment.
Gamenot Jan 10, 2023
1515d71
Fix name of attribute.
Gamenot Jan 10, 2023
70de5f7
Update an example.
Gamenot Jan 10, 2023
5ccd6e4
Large update of variable names.
Gamenot Jan 11, 2023
8a292bb
Fix leftover warning.
Gamenot Jan 11, 2023
009fe93
Fix multi-line string.
Gamenot Jan 11, 2023
2d221d8
Restore format obs conversion.
Gamenot Jan 11, 2023
13513bb
Fix new action.
Gamenot Jan 13, 2023
7bc7e07
Add conversion utility.
Gamenot Jan 13, 2023
7cf5a9f
Add missing header.
Gamenot Jan 13, 2023
968e276
Add observation space to HiWayV1 and comp env.
Gamenot Jan 13, 2023
dac40a8
Update metrics.
Gamenot Jan 13, 2023
ea9a6c0
Update examples.
Gamenot Jan 13, 2023
59b4ae6
Add missing interface for road map route.
Gamenot Jan 13, 2023
e0aa773
Standardize observation formatter names.
Gamenot Jan 13, 2023
34ac0dc
Revert most format obs changes.
Gamenot Jan 13, 2023
f9f11ad
Move the gymnasium environments and utilities.
Gamenot Jan 13, 2023
73aeba9
Remove unused imports.
Gamenot Jan 13, 2023
954a547
Update test examples.
Gamenot Jan 13, 2023
b07188b
Fix string warning.
Gamenot Jan 13, 2023
5d6b6b7
Fix rewards return for hiway-v1.
Gamenot Jan 13, 2023
eb057ed
Fix gymnasium warnings.
Gamenot Jan 13, 2023
08f5c02
make format
Gamenot Jan 13, 2023
cb0d9dc
Update resource loading.
Gamenot Jan 13, 2023
9a024b3
Benchmark
Gamenot Jan 13, 2023
05f7f33
Add worker logging to benchmark.
Gamenot Jan 15, 2023
cd8d48c
Add observation space demo to benchmark.
Gamenot Jan 15, 2023
f67ce1c
Comment on necessary improvements to observations.
Gamenot Jan 15, 2023
5c2ed17
Update observations.
Gamenot Jan 15, 2023
3b89aea
Make format.
Gamenot Jan 15, 2023
4996ffb
Make goals immutable
Gamenot Jan 16, 2023
330eadd
Add module substitution utility.
Gamenot Jan 17, 2023
1e201d3
Add `scl benchmark` utilities.
Gamenot Jan 17, 2023
edfbb78
Remove template types in strings.
Gamenot Jan 17, 2023
c162cfa
Update Makefile
Gamenot Jan 17, 2023
40026d7
Apply suggestion that truncated is set if policy fails.
Gamenot Jan 17, 2023
48f7d65
Fix documentation for RelativeTargetPose.
Gamenot Jan 17, 2023
0150194
Add `Score` object for metrics.
Gamenot Jan 17, 2023
b2ceaa4
Revert package resources distribution version.
Gamenot Jan 17, 2023
ee8241e
Fix spelling error.
Gamenot Jan 17, 2023
c8498f2
Remove pylint error suppression.
Gamenot Jan 17, 2023
66c5944
Fix symantics error.
Gamenot Jan 17, 2023
a1b2192
Fix key changes in format obs test.
Gamenot Jan 17, 2023
273d3c7
Update test single agent keys.
Gamenot Jan 17, 2023
eb3e4f9
make format.
Gamenot Jan 17, 2023
076db5b
Add agent action type configuration and limit TargetPose.
Gamenot Jan 18, 2023
1b0d595
Fix key error in format obs test.
Gamenot Jan 18, 2023
1634d42
Fix rgb image test parameterization issue.
Gamenot Jan 18, 2023
94aea72
Hook up seed to the hiway-env environment.
Gamenot Jan 18, 2023
54ce994
Move action space resolution to competition env.
Gamenot Jan 18, 2023
63143b7
remove multi_scenario environment.
Gamenot Jan 18, 2023
b427f7b
Refactor out multiple inheritance from observation converters.
Gamenot Jan 18, 2023
48702c0
Configure hiway env observation space options.
Gamenot Jan 18, 2023
72bcfde
Update hiway env configuration.
Gamenot Jan 19, 2023
42bf624
Move agent config.
Gamenot Jan 19, 2023
ddc0769
Disable env check in gym registration.
Gamenot Jan 19, 2023
fab95b0
Remove redundant assignment.
Gamenot Jan 19, 2023
3baf000
Remove needless type check.
Gamenot Jan 19, 2023
b9d4a05
Fix dictionary unpack.
Gamenot Jan 19, 2023
9de9af2
Clearly warn that offroad causes completion penalties.
Gamenot Jan 19, 2023
6c7d237
Mention why completion was penalized.
Gamenot Jan 19, 2023
4e60ccc
Cache space value.
Gamenot Jan 19, 2023
ee8fd40
Set mission to old location in gym observations.
Gamenot Jan 19, 2023
fdccd56
Rename hiway env v1 example.
Gamenot Jan 19, 2023
32dda7e
Add an api adaptor for gymnasium to gym<=0.21.
Gamenot Jan 19, 2023
3f26597
Allow old gym wrappers to work with gymnasium.
Gamenot Jan 19, 2023
f32f1d8
Allow more wrappers to work with new gymnasium env.
Gamenot Jan 19, 2023
50efcfb
Make format
Gamenot Jan 19, 2023
affa032
Condense imports.
Gamenot Jan 19, 2023
9a27d1f
Constrain the relative target pose speed to 28mps.
Gamenot Jan 19, 2023
7100a3c
Remove EpisodeLimit wrapper.
Gamenot Jan 19, 2023
900b68f
Add missing sstudio import.
Gamenot Jan 19, 2023
75748df
Make relative target pose the default action.
Gamenot Jan 19, 2023
3b42f75
Clean up comments.
Gamenot Jan 19, 2023
5ef2f33
Update the action space docstring.
Gamenot Jan 19, 2023
273861c
Fix the speed cap for relative target pose.
Gamenot Jan 19, 2023
a373ded
Fix issues with rebase.
Gamenot Jan 20, 2023
248630f
Update hiway env v1 example.
Gamenot Jan 20, 2023
b750c8c
Fix rebase issues.
Gamenot Jan 20, 2023
52740b6
Renamed camera_pos to camera_position.
Gamenot Jan 20, 2023
1235287
Set api reversion to be a gym wrapper instead.
Gamenot Jan 20, 2023
7f7210a
Remove useless examples.
Gamenot Jan 20, 2023
1683004
Revert marl benchmark changes.
Gamenot Jan 20, 2023
70b1841
Fill out auto-install
Gamenot Jan 20, 2023
866b61d
Rename benchmark example agent.
Gamenot Jan 20, 2023
7de62f1
Document hiway env v1.
Gamenot Jan 20, 2023
456e9af
Fix test observations.
Gamenot Jan 20, 2023
0eff7d0
Remove useless docstring.
Gamenot Jan 20, 2023
e9898ca
Rename competition metrics back to metrics.
Gamenot Jan 20, 2023
9b247a0
Add hiway-env-v1 to the environment documentation.
Gamenot Jan 20, 2023
55938c8
Set dynamic number of cpus for benchmark runner.
Gamenot Jan 20, 2023
6ddfc98
Add error tolerance configuration.
Gamenot Jan 20, 2023
ed949f1
Make worker logging explicit.
Gamenot Jan 21, 2023
69530e2
Fix cpu affinity check
Gamenot Jan 21, 2023
0019be4
Add hiway_v1 to example tests.
Gamenot Jan 21, 2023
a189c33
Fix sanity-test
Gamenot Jan 21, 2023
d3ce602
Fix format obs.
Gamenot Jan 21, 2023
9fb7bd1
Update metrics test.
Gamenot Jan 21, 2023
857959a
Fix rgb image test.
Gamenot Jan 21, 2023
d57a99b
Finish writing docstrings and scl help.
Gamenot Jan 21, 2023
088ea36
Fix pytype complaint.
Gamenot Jan 21, 2023
05dd059
Make format.
Gamenot Jan 21, 2023
56a4bae
Revert rl racing example.
Gamenot Jan 21, 2023
56d14ca
Fix pytype.
Gamenot Jan 21, 2023
ee27d45
Fix sanity test
saulfield Jan 21, 2023
41ce30a
Merge branch 'develop' into tucker/feature-hiway_v1
Gamenot Jan 21, 2023
5989cfe
Fix issues with benchmark utility.
Gamenot Jan 22, 2023
9ffc90e
Fix pytype errors.
Gamenot Jan 22, 2023
46f3108
Fix docstring test.
Gamenot Jan 22, 2023
b839100
Touch up interface.
Gamenot Jan 22, 2023
a59c6c3
Allow leaving out benchmark version.
Gamenot Jan 22, 2023
ef6f5fb
Add benchmark documentation.
Gamenot Jan 22, 2023
2a8d1d0
Update changelog.
Gamenot Jan 22, 2023
9ef2cab
Merge pull request #1793 from huawei-noah/tucker/feature-hiway_v1
Gamenot Jan 22, 2023
af51fef
GitHub Actions: Update requirements.txt
Gamenot Jan 22, 2023
182f0d3
Update SMARTS version to 1.0.0
Gamenot Jan 22, 2023
da2ebde
Fix documentation errors.
Gamenot Jan 23, 2023
9f607c6
GitHub Actions: Update requirements.txt
Gamenot Jan 23, 2023
266e62a
Merge branch 'master' into develop
Gamenot Jan 23, 2023
a6725ed
GitHub Actions: Update mac_requirements.txt
Gamenot Jan 23, 2023
5362d30
Fix small issues with benchmark. (#1802)
Gamenot Jan 24, 2023
298628b
GitHub Actions: Update requirements.txt
Gamenot Jan 24, 2023
f031092
Make sure server serves correct map glb file (#1804)
saulfield Jan 24, 2023
15b29b4
Fix waypoint observations for offline dataset generation (#1807)
saulfield Jan 26, 2023
ee85055
GitHub Actions: Update requirements.txt
saulfield Jan 26, 2023
e337e23
Automatically supply scenario path to Envision server (#1806)
Adaickalavan Jan 26, 2023
b6b191e
GitHub Actions: Update requirements.txt
Adaickalavan Jan 26, 2023
750e58e
GitHub Actions: Format
Adaickalavan Jan 26, 2023
2da6ca1
Change metrics to use info["env_obs"].
Gamenot Jan 26, 2023
1cdf902
Make format.
Gamenot Jan 26, 2023
6834f5c
Fix type test.
Gamenot Jan 26, 2023
47c0476
Change default instead assert.
Gamenot Jan 26, 2023
a58b990
Update smarts/env/gymnasium/wrappers/metric/completion.py
Gamenot Jan 26, 2023
57a83c3
Fix detach call.
Gamenot Jan 26, 2023
6da7407
Ensure hiway-v0 agent interfaces are populated.
Gamenot Jan 27, 2023
77644bb
Update changelog.
Gamenot Jan 27, 2023
f421367
GitHub Actions: Update requirements.txt
Gamenot Jan 27, 2023
21f20ba
Add action space formatting for hiway-v1.
Gamenot Jan 25, 2023
ed060c5
Update changelog.
Gamenot Jan 25, 2023
15f1cdc
Fix issues with action conversion.
Gamenot Jan 25, 2023
a102509
Rename observation formatter to match action.
Gamenot Jan 25, 2023
6c74fed
Add header.
Gamenot Jan 25, 2023
86cb0ec
Update license date.
Gamenot Jan 25, 2023
8fdd3f8
Fix docstring test.
Gamenot Jan 25, 2023
b4b0e50
Update smarts/env/gymnasium/utils/action_conversion.py
Gamenot Jan 27, 2023
dc92fa2
Update docstrings..
Gamenot Jan 27, 2023
f0a70f5
Compare action keys instead of space check.
Gamenot Jan 27, 2023
71510d3
Use key comparision instead of set cast.
Gamenot Jan 27, 2023
fb06383
Reduce observation formatting class use.
Gamenot Jan 24, 2023
9b18765
Fix observation description.
Gamenot Jan 24, 2023
7577765
Further shrink the number of classes.
Gamenot Jan 25, 2023
b37f290
Hide internal parameter.
Gamenot Jan 25, 2023
11bf1a9
Add unformatted option to hiway-v1 observation configuration.
Gamenot Jan 25, 2023
2af2b8e
Update changelog.
Gamenot Jan 25, 2023
08b12c5
Update smarts/core/controllers/__init__.py
Gamenot Jan 26, 2023
cc19b76
GitHub Actions: Update requirements.txt
Gamenot Jan 28, 2023
01f27af
Bump version to 1.0.2
Gamenot Jan 28, 2023
8c215a5
Merge branch 'master' into develop
Gamenot Jan 28, 2023
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Removed
### Security

## [1.0.2] 2023-01-27
### Added
- The `hiway-v1` environment can now be configured to provide an "unformatted" observation.
### Changed
- Scenario paths is no longer manually supplied to Envision server while setup. Scenario paths are automatically sent to Envision server from SMARTS during simulation startup phase.
- Updated "hiway-v1" with `gymnasium` action spaces using new `ActionsSpaceFormatter` utility.
### Fixed
- Fixed an issue where a sensor detach call when a bubble vehicle exits a bubble could cause a program crash.
- Fixed issue with "hiway-v0" where "agent_interfaces" was not populated.
- Add missing `distance_travelled` to the `hiway-v1` observations.

## [1.0.1] 2023-01-24
### Fixed
- Fixed issue where Driving SMARTS benchmark only did 2 evaluations per scenario instead of 50.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (C) 2022. Huawei Technologies Co., Ltd. All rights reserved.
Copyright (C) 2023. 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
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sanity-test: build-sanity-scenarios
./smarts/core/tests/test_dynamics_backend.py::test_set_pose \
./smarts/core/tests/test_sensors.py::test_waypoints_sensor \
./smarts/core/tests/test_smarts.py::test_smarts_doesnt_leak_tasks_after_reset \
./examples/tests/test_examples.py::test_examples[hiway_v1] \
./examples/tests/test_examples.py::test_examples[laner] \
./smarts/env/tests/test_social_agent.py::test_social_agents

Expand Down
11 changes: 2 additions & 9 deletions cli/envision.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ def envision_cli():

@envision_cli.command(name="start", help="Start an Envision server.")
@click.option("-p", "--port", help="Port Envision will run on.", default=8081)
@click.option(
"-s",
"--scenarios",
help="A list of directories where scenarios are stored.",
multiple=True,
default=["scenarios"],
)
@click.option(
"-c",
"--max_capacity",
Expand All @@ -49,8 +42,8 @@ def envision_cli():
default=500,
type=float,
)
def start_server(port, scenarios, max_capacity):
run(scenario_dirs=scenarios, max_capacity_mb=max_capacity, port=port)
def start_server(port, max_capacity):
run(max_capacity_mb=max_capacity, port=port)


envision_cli.add_command(start_server)
2 changes: 0 additions & 2 deletions cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def run_experiment(envision, envision_port, script_path, script_args):
"scl",
"envision",
"start",
"-s",
"./scenarios",
"-p",
str(envision_port),
],
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/containers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SMARTS docker images are hosted at `dockerhub <https://hub.docker.com/u/huaweino
# E.g. docker run --rm -it -v $PWD:/src -p 8081:8081 huaweinoah/smarts:v0.5.1

# If visualization is needed, run Envision server in the background.
$ scl envision start -s ./scenarios -p 8081 &
$ scl envision start -p 8081 &

# Build the scenario.
# This step is required on the first time, and whenever the scenario is modified.
Expand Down
4 changes: 2 additions & 2 deletions docs/sim/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Examples of common usage are as follows.

.. code-block:: bash

# Start envision and serve scenario assets out of ./scenarios
$ scl envision start --scenarios ./scenarios
# Start envision server
$ scl envision start

# Build all scenarios under given directories
$ scl scenario build-all ./scenarios
Expand Down
4 changes: 3 additions & 1 deletion envision/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def default(self, obj):
return bool(obj)
elif isinstance(obj, np.ndarray):
return [self.default(x) for x in obj]
elif isinstance(obj, Path):
return str(obj)

return super().default(obj)

Expand Down Expand Up @@ -292,7 +294,7 @@ def run_socket(endpoint, wait_between_retries):

run_socket(endpoint, wait_between_retries)

def send(self, state: types.State):
def send(self, state: Union[types.State, types.Preamble]):
"""Send the given envision state to the remote as the most recent state."""
if not self._headless and self._process.is_alive():
self._state_queue.put(state)
Expand Down
79 changes: 42 additions & 37 deletions envision/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from tornado.websocket import WebSocketClosedError

import smarts.core.models
from envision.types import State
from envision.web import dist as web_dist
from smarts.core.utils.file import path2hash

Expand All @@ -55,6 +54,9 @@
# Mapping of simulation ID to the Frames data store
FRAMES = {}

# Mapping of path to map geometry files
MAPS = {}


class AllowCORSMixin:
"""A mixin that adds CORS headers to the page."""
Expand Down Expand Up @@ -318,14 +320,24 @@ def on_close(self):
async def on_message(self, message):
"""Asynchronously receive messages from the Envision client."""
it = ijson.parse(message)
frame_time = None
# Find the first number value, which will be the frame time.
for prefix, event, value in it:
if prefix and event == "number":
frame_time = float(value)
break
assert isinstance(frame_time, float)
self._frames.append(Frame(timestamp=frame_time, data=message))
next(it) # Discard first entry: prefix="", event="start_array", value=None
prefix, event, value = next(it)
if prefix == "item" and event == "number":
# If the second event is a `number`, it is a payload message.
frame_time = float(value)
assert isinstance(frame_time, float)
self._frames.append(Frame(timestamp=frame_time, data=message))
elif prefix == "item" and event == "start_map":
# If the second event is a `start_map`, it is a preamble.
scenarios = [
value
for prefix, event, value in it
if prefix == "item.scenarios.item" and event == "string"
]
path_map = _index_map(scenarios)
MAPS.update(path_map)
else:
raise tornado.web.HTTPError(400, f"Bad request message.")


class StateWebSocket(tornado.websocket.WebSocketHandler):
Expand All @@ -346,9 +358,9 @@ def get_compression_options(self):
return {"compression_level": 6, "mem_level": 5}

async def open(self, simulation_id):
"""Open this socket to listen for webclient playback requests."""
"""Open this socket to listen for webclient playback requests."""
if simulation_id not in WEB_CLIENT_RUN_LOOPS:
raise tornado.web.HTTPError(404, f"Simuation `{simulation_id}` not found.")
raise tornado.web.HTTPError(404, f"Simulation `{simulation_id}` not found.")

frequency = 10
message_frame_volume = 100
Expand Down Expand Up @@ -422,20 +434,9 @@ async def serve_chunked(self, path: Path, chunk_size: int = 1024 * 1024):
class MapFileHandler(FileHandler):
"""This handler serves map geometry to the given endpoint."""

def initialize(self, scenario_dirs: Sequence):
"""Setup this handler. Finds and indexes all map geometry files in the given scenario
directories.
"""
path_map = {}
for dir_ in scenario_dirs:
path_map.update(
{
f"{path2hash(str(glb.parents[2].resolve()))}.glb": glb
for glb in Path(dir_).rglob("build/map/*.glb")
}
)

super().initialize(path_map)
def initialize(self):
"""Setup this handler."""
super().initialize(path_map=MAPS)


class SimulationListHandler(AllowCORSMixin, tornado.web.RequestHandler):
Expand Down Expand Up @@ -487,7 +488,7 @@ def get(self):
self.render(str(index_path))


def make_app(scenario_dirs: Sequence, max_capacity_mb: float, debug: bool):
def make_app(max_capacity_mb: float, debug: bool):
"""Create the envision web server application through composition of services."""

dist_path = Path(os.path.dirname(web_dist.__file__)).absolute()
Expand All @@ -505,7 +506,6 @@ def make_app(scenario_dirs: Sequence, max_capacity_mb: float, debug: bool):
(
r"/assets/maps/(.*)",
MapFileHandler,
dict(scenario_dirs=scenario_dirs),
),
(r"/assets/models/(.*)", ModelFileHandler),
(r"/(.*)", tornado.web.StaticFileHandler, dict(path=str(dist_path))),
Expand All @@ -514,20 +514,33 @@ def make_app(scenario_dirs: Sequence, max_capacity_mb: float, debug: bool):
)


def _index_map(scenario_dirs: Sequence[str]) -> Dict[str, Path]:
"""Finds and indexes all map geometry files in the given scenario directories."""
path_map = {}
for dir_ in scenario_dirs:
path_map.update(
{
f"{path2hash(str(glb.parents[2].resolve()))}.glb": glb
for glb in Path(dir_).rglob("build/map/map.glb")
}
)

return path_map


def on_shutdown():
"""Callback on shutdown of the envision server."""
logging.debug("Shutting down Envision")
tornado.ioloop.IOLoop.current().stop()


def run(
scenario_dirs: List[str],
max_capacity_mb: int = 500,
port: int = 8081,
debug: bool = False,
):
"""Create and run an envision web server."""
app = make_app(scenario_dirs, max_capacity_mb, debug=debug)
app = make_app(max_capacity_mb, debug=debug)
app.listen(port)
logging.debug("Envision listening on port=%s", port)

Expand All @@ -548,13 +561,6 @@ def main():
description="The Envision server broadcasts SMARTS state to Envision web "
"clients for visualization.",
)
parser.add_argument(
"--scenarios",
help="A list of directories where scenarios are stored.",
default=["./scenarios"],
type=str,
nargs="+",
)
parser.add_argument(
"--port",
help="Port Envision will run on.",
Expand All @@ -576,7 +582,6 @@ def main():
args = parser.parse_args()

run(
scenario_dirs=args.scenarios,
max_capacity_mb=args.max_capacity,
port=args.port,
debug=args.debug,
Expand Down
7 changes: 7 additions & 0 deletions envision/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class State(NamedTuple):
frame_time: float


class Preamble(NamedTuple):
"""Information for startup and synchronisation between client and server."""

scenarios: Sequence[str]
"""Directories of simulated scenarios."""


def format_actor_id(actor_id: str, vehicle_id: str, is_multi: bool):
"""A conversion utility to ensure that an actor id conforms to envision's actor id standard.
Args:
Expand Down
9 changes: 8 additions & 1 deletion examples/control/laner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ def main(scenarios, headless, num_episodes, max_episode_steps=None):

if not args.scenarios:
args.scenarios = [
str(Path(__file__).absolute().parents[2] / "scenarios" / "sumo" / "loop")
str(Path(__file__).absolute().parents[2] / "scenarios" / "sumo" / "loop"),
str(
Path(__file__).absolute().parents[2]
/ "scenarios"
/ "sumo"
/ "figure_eight"
),
]

build_scenarios(
Expand All @@ -81,4 +87,5 @@ def main(scenarios, headless, num_episodes, max_episode_steps=None):
scenarios=args.scenarios,
headless=args.headless,
num_episodes=args.episodes,
max_episode_steps=args.max_episode_steps,
)
6 changes: 6 additions & 0 deletions examples/tools/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def default_argument_parser(program: Optional[str] = None):
parser.add_argument(
"--headless", help="Run the simulation in headless mode.", action="store_true"
)
parser.add_argument(
"--max_episode_steps",
help="Maximum number of steps to run each episode for.",
type=int,
default=100,
)
parser.add_argument("--seed", type=int, default=42)
parser.add_argument(
"--sim-name",
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cloudpickle==1.6.0
colorama==0.4.6
colorful==0.5.5
constantly==15.1.0
coverage==7.0.5
coverage==7.1.0
cycler==0.11.0
dm-tree==0.1.8
eclipse-sumo==1.15.0
Expand Down Expand Up @@ -83,7 +83,7 @@ pandas==1.3.5
Pillow==9.4.0
pkgutil_resolve_name==1.3.10
pluggy==1.0.0
prometheus-client==0.15.0
prometheus-client==0.16.0
protobuf==3.19.6
psutil==5.9.4
py==1.11.0
Expand All @@ -107,7 +107,7 @@ ray==1.0.1.post1
redis==3.4.1
requests==2.28.2
requests-oauthlib==1.3.1
rich==13.2.0
rich==13.3.0
rsa==4.9
Rtree==1.0.1
scipy==1.7.3
Expand Down Expand Up @@ -136,10 +136,10 @@ typing_extensions==4.4.0
urllib3==1.26.14
visdom==0.2.3
wcwidth==0.2.6
websocket-client==1.4.2
websocket-client==1.5.0
Werkzeug==2.2.2
wrapt==1.14.1
yarl==1.8.2
yattag==1.15.0
zipp==3.11.0
zipp==3.12.0
zope.interface==5.5.2
3 changes: 2 additions & 1 deletion scenarios/sumo/intersections/2lane/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@
scenario=Scenario(
traffic=traffic,
map_spec=MapSpec(
source=Path(__file__).parent,
source=Path(__file__).parent.absolute(),
shift_to_origin=True,
lanepoint_spacing=1.0,
),
),
output_dir=Path(__file__).parent,
Expand Down
3 changes: 2 additions & 1 deletion scenarios/sumo/intersections/4lane/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@
},
ego_missions=ego_missions,
map_spec=MapSpec(
source=Path(__file__).parent,
source=Path(__file__).parent.absolute(),
shift_to_origin=True,
lanepoint_spacing=1.0,
),
)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = smarts
version = 1.0.1
version = 1.0.2
url = https://github.com/huawei-noah/SMARTS
long_description = file:utils/setup/README.pypi.md
long_description_content_type = text/markdown
Expand Down
Loading