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

Parallel observations #1687

Merged
merged 153 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
dbed456
Use test validation
Gamenot Oct 25, 2022
e40f508
Extract renderer out of vehicle object
Gamenot Oct 26, 2022
a9ae849
Add todos specific to me.
Gamenot Oct 26, 2022
e26892d
Move step sensors to vehicle index.
Gamenot Oct 26, 2022
401dc8d
Black format
Gamenot Oct 26, 2022
b2387f4
Format isort
Gamenot Oct 26, 2022
a6b1a48
Add missing observations to AgentType.Full
Gamenot Oct 26, 2022
c3f624e
Working example, needs persistant workers.
Gamenot Oct 28, 2022
d027f06
Add missing map
Gamenot Oct 28, 2022
c68e197
Make format
Gamenot Oct 28, 2022
a9dff6f
Persist processes to get performance.
Gamenot Oct 28, 2022
2ce0b42
Test that local and remote observations are equal
Gamenot Oct 28, 2022
7003d92
Write out what is TODO.
Gamenot Oct 28, 2022
7467fdb
Separate out the frame code from smarts
Gamenot Nov 1, 2022
a29aa8f
Approach better performance
Gamenot Nov 3, 2022
73b2f9d
Pass in constants
Gamenot Nov 3, 2022
d74511c
Restoring tests
Gamenot Nov 4, 2022
0fad382
Generate headers when formatting.
Gamenot Nov 4, 2022
b9be3c1
Remove 3.8 greater code.
Gamenot Nov 4, 2022
2bc7173
Fix envision test
Gamenot Nov 4, 2022
7a9682b
Improved parallelism
Gamenot Nov 10, 2022
f252a61
Make format
Gamenot Nov 10, 2022
0a949e9
Extract sensors to sensor manager, extract render.
Gamenot Nov 16, 2022
afd5d10
Use global environment constants.
Gamenot Nov 21, 2022
0cbcd7f
Update timeout options
Gamenot Nov 21, 2022
b971961
Optimize unpack method.
Gamenot Nov 21, 2022
adea1b8
Make format
Gamenot Nov 21, 2022
622f8fa
Remove saved camera time for reproduction.
Gamenot Nov 23, 2022
6575d30
Update changelog
Gamenot Nov 23, 2022
335de88
Add matching for dataclass types.
Gamenot Nov 23, 2022
27f0280
Fix renderer issue
Gamenot Nov 23, 2022
21a3fa3
Prepare to swap from old observe method.
Gamenot Nov 23, 2022
6316369
Remove reduntant counter utility
Gamenot Nov 24, 2022
68b57e6
Remove sensor count after deletion
Gamenot Nov 24, 2022
b602eb3
Delete count if sensor has been removed.
Gamenot Nov 24, 2022
2213aed
Finish up sensor manager
Gamenot Nov 24, 2022
333a22a
Add engine debug option
Gamenot Nov 24, 2022
e8ecdb9
Remove actor references to directly removed sensors
Gamenot Nov 24, 2022
257d3b0
Improve typing
Gamenot Nov 24, 2022
b3f6d43
Ensure all sensors are serializable
Gamenot Nov 24, 2022
829f9a5
Fix lidar sensor attach error.
Gamenot Nov 24, 2022
17750c4
Fix sensor setup
Gamenot Nov 28, 2022
d312552
Fix logical error
Gamenot Nov 28, 2022
55ecb3a
Swap observe
Gamenot Nov 28, 2022
fae8537
Make format
Gamenot Nov 28, 2022
ace64a4
Fix sensor issue.
Gamenot Nov 28, 2022
34cdf85
Disable debugging feature mode
Gamenot Nov 30, 2022
53abb3a
Fix done criteria test
Gamenot Nov 30, 2022
c81d451
Use a renderer reference rather than private attr.
Gamenot Dec 1, 2022
34476c1
Fix issue with test boids using local traffic
Gamenot Dec 2, 2022
ccfd148
Fix boid done behaviour
Gamenot Dec 2, 2022
d89a9bf
Fix problem with bubble hijacking test.
Gamenot Dec 2, 2022
51534c3
Stabilize cpu use
Gamenot Dec 2, 2022
453d2c2
Set number of observation workers in test.
Gamenot Dec 2, 2022
d314936
Fix missing import
Gamenot Dec 2, 2022
4c9c9c3
Fix hijacking test
Gamenot Dec 2, 2022
de2c68a
Make tests headless.
Gamenot Dec 2, 2022
7aa0842
Fix test shutdown.
Gamenot Dec 2, 2022
51e57eb
Fix test_sensors.
Gamenot Dec 2, 2022
7f16fbc
Fix renderer and shutdown tests.
Gamenot Dec 2, 2022
3f86f03
Fix test signal observations.
Gamenot Dec 2, 2022
0e8565f
Make sensor logging info
Gamenot Dec 2, 2022
4c9b1d3
Remove test setup.
Gamenot Dec 5, 2022
c70aaa3
Fix formatting test.
Gamenot Dec 5, 2022
1a3ea36
Move the unpacking utility
Gamenot Dec 5, 2022
ce57adf
Update tests to not run parallel comparison test
Gamenot Dec 5, 2022
f0aff97
add Empty ActionSpaceType
qianyi-sun Dec 15, 2022
974f139
Mark sensors mutable or unmutable.
Gamenot Dec 22, 2022
1923a80
Get sensors from sensor manager instead of vehicle
Gamenot Dec 22, 2022
2f146ff
Register all vehicle sensors with sensor manager.
Gamenot Dec 22, 2022
6311609
Fix test error.
Gamenot Dec 22, 2022
16382b1
Fix dataclass diff tool.
Gamenot Dec 22, 2022
a6a184d
Synchronize sensors back to smarts.
Gamenot Dec 22, 2022
ac16f00
Update test
Gamenot Dec 22, 2022
3226587
Exclude full sensors from test for now.
Gamenot Dec 22, 2022
8b7ce21
Fix missing method call.
Gamenot Dec 22, 2022
8aa7373
Remove reference to actor in vehicle index.
Gamenot Dec 22, 2022
d0f249c
Fix type errors.
Gamenot Dec 28, 2022
3e1067c
Fix scenario resource location errors.
Gamenot Dec 28, 2022
2c017f4
Fix make test.
Gamenot Dec 28, 2022
cc76204
Fix recursion error
Gamenot Dec 30, 2022
0a6d4a9
Fix: sensors did not sync to sensor manager.
Gamenot Dec 31, 2022
f7f1b71
Split tests in two files to ignore baseline test.
Gamenot Dec 31, 2022
85426d3
Fix types test
Gamenot Dec 31, 2022
8598eb2
Add typehint for method.
Gamenot Dec 31, 2022
3fb7fcd
Fix bug with terminating a worker.
Gamenot Jan 3, 2023
49b9b03
Lower default retries to 0
Gamenot Jan 3, 2023
c1c6539
Rename serialization
Gamenot Jan 4, 2023
8c0136d
Fix call of serializer.
Gamenot Jan 4, 2023
584e646
Black format
Gamenot Jan 4, 2023
497df15
Ensure serialization of roadmap always works.
Gamenot Jan 4, 2023
e1fa51e
Fix issue with daemon processes.
Gamenot Jan 4, 2023
3441b7a
Fix docstrings.
Gamenot Jan 4, 2023
48c525b
Fix type failure.
Gamenot Jan 4, 2023
0712cc8
Remove unused test
Gamenot Jan 4, 2023
da271ce
Fix tests.
Gamenot Jan 4, 2023
b115bea
Fix docstring test.
Gamenot Jan 4, 2023
451800e
Add type-hints.
Gamenot Jan 4, 2023
9383213
Fix issues.
Gamenot Feb 16, 2023
7cf28b3
Switch to using engine configuration.
Gamenot Feb 16, 2023
34f88be
Fix misreferenced sensor.
Gamenot Feb 16, 2023
88bcb93
Remove unecessary xml changes.
Gamenot Feb 16, 2023
a306f36
Update changelog.
Gamenot Feb 16, 2023
1d03f2c
Touch up changes to lane following controller.
Gamenot Feb 16, 2023
3c240d1
Update changelog.
Gamenot Feb 16, 2023
0d3e2fd
make format
Gamenot Feb 16, 2023
5417926
Move sensor interface and implementations to sensor.py.
Gamenot Feb 16, 2023
f54fc8c
Ensure shudown test does not break.
Gamenot Feb 17, 2023
7c5bd8e
Separate observation resolution implementations.
Gamenot Feb 17, 2023
aaa0568
Update based on master action space changes.
Gamenot Feb 18, 2023
fe48ef7
Fix docstrings.
Gamenot Feb 22, 2023
95f4575
Update temporary engine settings.
Gamenot Feb 22, 2023
8a4430b
Fix typing test.
Gamenot Feb 22, 2023
775df20
Fix replace.
Gamenot Mar 1, 2023
d257bdd
Move sensors resolving implementations to appropriate locations.
Gamenot Mar 6, 2023
e29e318
Fix sanity tests.
Gamenot Mar 6, 2023
a83a6cb
Add ray based sensor resolver.
Gamenot Mar 6, 2023
3cb509f
Fix pytype test.
Gamenot Mar 10, 2023
4598817
Fix vehicle inde errors.
Gamenot Mar 10, 2023
30a072d
Fix shutdown test.
Gamenot Mar 10, 2023
9c52c58
Fix tests.
Gamenot Mar 10, 2023
f792bbc
Update changelog.
Gamenot Mar 13, 2023
e93d5e4
Revert "owner" role back to "actor" role.
Gamenot Mar 13, 2023
c792346
Make format
Gamenot Mar 13, 2023
1769d5c
Fix tests.
Gamenot Mar 13, 2023
545c9b9
Touch up scenario changes.
Gamenot Mar 13, 2023
dc1fe0b
Resolve todos.
Gamenot Mar 13, 2023
305fbd3
Remove unused fields.
Gamenot Mar 13, 2023
fbef548
Fix test description
Gamenot Mar 13, 2023
347b8fd
Let unpack be used for comparison.
Gamenot Mar 13, 2023
7cc8366
fix tests
Gamenot Mar 28, 2023
af2427c
Update logging naming.
Gamenot Apr 5, 2023
fcee963
Ensure ray sensor resolver works.
Gamenot Apr 6, 2023
e6ba79c
Fix warnings and type errors.
Gamenot Apr 6, 2023
7b442ac
Fix missing init files.
Gamenot Apr 10, 2023
958746a
Add headers.
Gamenot Apr 10, 2023
fac1237
Add missing docstrings.
Gamenot Apr 11, 2023
0c6b139
Fix changed method name.
Gamenot Apr 11, 2023
ce5aca5
make format
Gamenot Apr 11, 2023
475cc1e
Address all comments.
Gamenot Apr 17, 2023
018219a
Merge branch 'master' into tucker/feature-parallel_observations
Gamenot Apr 17, 2023
165a3cb
Find issue with un-updated sensor.
Gamenot Apr 18, 2023
4dad936
Fix issues.
Gamenot Apr 20, 2023
a367a75
Merge branch 'master' into tucker/feature-parallel_observations
Gamenot Apr 20, 2023
28cb9f9
Fix base tests syntax.
Gamenot Apr 20, 2023
7acd5a5
Fix test.
Gamenot Apr 20, 2023
6a6632d
Remove excess prints.
Gamenot Apr 20, 2023
dcbc6d7
Clean up tests.
Gamenot Apr 20, 2023
74fd2d2
Futher clean-up of code.
Gamenot Apr 20, 2023
2770644
Remove redundant configuration.
Gamenot Apr 20, 2023
03ec739
Install rllib on /examples and /env.
Gamenot Apr 20, 2023
b22fddb
Fix argument error.
Gamenot Apr 20, 2023
f610673
Fix ray test directory.
Gamenot Apr 21, 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
5 changes: 4 additions & 1 deletion .github/workflows/ci-base-tests-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- ./smarts/env/tests/test_rllib_hiway_env.py
- ./smarts/sstudio
- ./examples/tests --ignore=./examples/tests/test_learning.py
- ./smarts/ray
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -29,7 +30,9 @@ jobs:
. ${{env.venv_dir}}/bin/activate
pip install --upgrade pip
pip install wheel==0.38.4
pip install -e .[camera_obs,opendrive,rllib,test,test_notebook,torch,train,gym,argoverse]
pip install -e .[camera_obs,opendrive,test,test_notebook,torch,train,gym,argoverse]
if echo ${{matrix.tests}} | grep -q -e "env" -e "examples"; then pip install -e .[rllib]; fi
if echo ${{matrix.tests}} | grep -q "/ray"; then pip install -e .[ray]; fi
- name: Run smoke tests
run: |
. ${{env.venv_dir}}/bin/activate
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-base-tests-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- ./smarts/env/tests/test_rllib_hiway_env.py
- ./smarts/core --nb-exec-timeout 65536 --ignore=./smarts/core/tests/test_notebook.py
- ./smarts/env --ignore=./smarts/env/tests/test_rllib_hiway_env.py
- ./smarts/ray
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -48,6 +49,8 @@ jobs:
pip install wheel==0.38.4
pip install -r utils/setup/mac_requirements.txt
pip install -e .[camera_obs,opendrive,rllib,test,test_notebook,torch,train,argoverse]
if echo ${{matrix.tests}} | grep -q -e "/env" -e "/examples"; then pip install -e .[rllib]; fi
if echo ${{matrix.tests}} | grep -q "/ray"; then pip install -e .[ray]; fi
- name: Run smoke tests
run: |
. ${{env.venv_dir}}/bin/activate
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Added baseline example, consisting of training, inference, and zoo agent registration, for the platooning task in Driving SMARTS 2023.3 benchmark.
- Documented the challenge objective, desired inference code structure, and use of baseline example, for Driving SMARTS 2023.3 benchmark, i.e., platooning task.
- Added a new scenario consisting of merge-exit map, sumo lead vehicle, and traffic, for the vehicle-following task.
- Added a `SensorManager` which manages placing sensors on actors in the simulations.
- The `VehicleState` now has the `bounding_box_points` property to get the vehicle minimum bounding box as a set of points.
- Added engine configuration options for `core:debug`, `core:observation_workers`, and `core:reset_retries`.
- Explained in the docs that agents may spawn at different times in multiagent scenarios.
- Added `RaySensorResolver` as an alternative parallel resolver.
- Added `[ray]` option for `smarts` package. This currently conflicts with `[rllib]`.
- Added engine `observation_workers` configuration which can be used to configure the number of parallel sensor workers: 0 runs the sensors on the local thread, >=1 runs using the multiprocessing backing.
- Added engine `sensor_parallelization` configuration of sensor parallelization backing, options ("mp"|"ray"): "mp" python multiprocessing, "ray" ray worker backing.
- Added engine `reset_retries` configuration engine retries before the simulator will raise an error on reset.
### Changed
- The trap manager, `TrapManager`, is now a subclass of `ActorCaptureManager`.
- Considering lane-change time ranges between 3s and 6s, assuming a speed of 13.89m/s, the via sensor lane acquisition range was increased from 40m to 80m, for better driving ability.
- The `AgentType.Full` now includes `road_waypoints`, `accelerometer`, and `lane_positions`.
- `ActionSpaceType` has been moved from `controller` to its own file.
- `VehicleState` has been moved to its own file.
- Sensors are no longer added and configured in the `agent_manager`. They are instead managed in the `sensor_manager`.
- Renamed all terminology relating to actor to owner in `VehicleIndex`.
- Renamed all terminology relating to shadow actor to shadower in `VehicleIndex`.
- `Collision` has been moved from `smarts.core.observations` to `smarts.core.vehicle_state`.
- The trap manager, `TrapManager`, is now a subclass of `ActorCaptureManager`.
- Considering lane-change time ranges between 3s and 6s, assuming a speed of 13.89m/s, the via sensor lane acquisition range was increased from 40m to 80m, for better driving ability.
- Modified naming of benchmark used in NeurIPS 2022 from driving-smarts-competition-env to driving-smarts-v2022.
- Sstudio generated scenario vehicle traffic ids are now shortened.
### Deprecated
Expand All @@ -33,6 +50,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Fixed issues related to waypoints in SUMO maps. Waypoints in junctions should now return all possible paths through the junction.
### Removed
- Removed the deprecated `waymo_browser` utility.
- Removed camera observation `created_at` attribute from metadata to make observation completely reproducible.
### Security

## [1.0.11] # 2023-04-02
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ sanity-test: build-sanity-scenarios
test-learning: build-all-scenarios
pytest -v -s -o log_cli=1 -o log_cli_level=INFO ./examples/tests/test_learning.py

.PHONY: test-long-determinism
test-long-determinism:
scl scenario build --clean scenarios/sumo/minicity
PYTHONHASHSEED=42 pytest -v \
--forked \
./smarts/env/tests/test_determinism.py::test_long_determinism

.PHONY: test-memory-growth
test-memory-growth: build-all-scenarios
PYTHONHASHSEED=42 pytest -v \
Expand All @@ -54,13 +61,6 @@ test-memory-growth: build-all-scenarios
rm -f .coverage.*
rm -f .coverage*

.PHONY: test-long-determinism
test-long-determinism:
scl scenario build --clean scenarios/sumo/minicity
PYTHONHASHSEED=42 pytest -v \
--forked \
./smarts/env/tests/test_determinism.py::test_long_determinism

.PHONY: benchmark
benchmark: build-all-scenarios
pytest -v ./smarts/env/tests/test_benchmark.py
Expand Down Expand Up @@ -143,7 +143,7 @@ clean:
rm -f .coverage*

.PHONY: format
format:
format: gen-header
echo "isort, version `isort --version-number`"
isort -m VERTICAL_HANGING_INDENT --skip-gitignore --ac --tc --profile black ./baselines ./cli ./envision ./examples/ ./utils/ ./scenarios/ ./smarts ./zoo
black --version
Expand Down
2 changes: 1 addition & 1 deletion docs/sim/agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ A pre-configured `interface` can be extended by supplying extra `kwargs`. For ex

agent_interface = AgentInterface.from_type(
requested_type = AgentType.Standard,
lidar = True,
lidar_point_cloud = True,
)

Custom interface
Expand Down
5 changes: 3 additions & 2 deletions examples/tools/pybullet_sumo_orientation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

import numpy as np

from smarts.core.actor_role import ActorRole
from smarts.core.actor import ActorRole
from smarts.core.chassis import BoxChassis
from smarts.core.coordinates import Heading, Pose
from smarts.core.scenario import Scenario
from smarts.core.sumo_traffic_simulation import SumoTrafficSimulation
from smarts.core.utils import pybullet
from smarts.core.utils.pybullet import bullet_client as bc
from smarts.core.vehicle import VEHICLE_CONFIGS, Vehicle, VehicleState
from smarts.core.vehicle import VEHICLE_CONFIGS, Vehicle
from smarts.core.vehicle_state import VehicleState

TIMESTEP_SEC = 1 / 240
INITIAL_KINEMATICS_VEHICLES = 50
Expand Down
11 changes: 7 additions & 4 deletions examples/tools/pybullet_vehicle_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def look_at(client, position=(0, 0, 0), top_down=True):
)


# pytype: disable=name-error
def run(client, vehicle, plane_body_id, sliders, n_steps=1e6):
prev_friction_sum = None

Expand All @@ -50,9 +51,8 @@ def run(client, vehicle, plane_body_id, sliders, n_steps=1e6):
)

client.stepSimulation()
vehicle.sync_to_renderer()

frictions_ = frictions(sliders)
frictions_ = frictions(sliders, client)

if prev_friction_sum is not None and not math.isclose(
sum(frictions_.values()), prev_friction_sum
Expand All @@ -74,7 +74,10 @@ def run(client, vehicle, plane_body_id, sliders, n_steps=1e6):
)


def frictions(sliders):
# pytype: enable=name-error


def frictions(sliders, client):
return dict(
lateralFriction=client.readUserDebugParameter(sliders["lateral_friction"]),
spinningFriction=client.readUserDebugParameter(sliders["spinning_friction"]),
Expand Down Expand Up @@ -128,7 +131,7 @@ def frictions(sliders):
path = str(path.absolute())
plane_body_id = client.loadURDF(path, useFixedBase=True)

client.changeDynamics(plane_body_id, -1, **frictions(sliders))
client.changeDynamics(plane_body_id, -1, **frictions(sliders, client))

pose = pose = Pose.from_center((0, 0, 0), Heading(0))
vehicle = Vehicle(
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ rllib =
opencv-python==4.1.2.30
opencv-python-headless==4.1.2.30
ray[rllib]==1.4.0
ray =
ray~=2.2.0
ros =
catkin_pkg
rospkg
Expand Down
4 changes: 3 additions & 1 deletion smarts/core/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ def __hash__(self) -> int:
return hash(self.actor_id)

def __eq__(self, other) -> bool:
return self.__class__ == other.__class__ and hash(self) == hash(other)
return self.__class__ == other.__class__ and hash(self.actor_id) == hash(
other.actor_id
)
2 changes: 1 addition & 1 deletion smarts/core/actor_capture_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __make_new_social_vehicle(sim, agent_id, initial_speed):
social_agent_spec,
social_agent_model,
)
vehicles = sim.vehicle_index.vehicles_by_actor_id(agent_id)
vehicles = sim.vehicle_index.vehicles_by_owner_id(agent_id)

return vehicles[0] if len(vehicles) else None

Expand Down
5 changes: 4 additions & 1 deletion smarts/core/agent_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from enum import IntEnum
from typing import List, Optional, Tuple, Union

from smarts.core.controllers import ActionSpaceType
from smarts.core.controllers.action_space_type import ActionSpaceType
from smarts.core.lidar_sensor_params import BasicLidar
from smarts.core.lidar_sensor_params import SensorParams as LidarSensorParams

Expand Down Expand Up @@ -367,10 +367,13 @@ def from_type(requested_type: AgentType, **kwargs):
interface = AgentInterface(
neighborhood_vehicle_states=True,
waypoint_paths=True,
road_waypoints=True,
drivable_area_grid_map=True,
occupancy_grid_map=True,
top_down_rgb=True,
lidar_point_cloud=True,
accelerometer=True,
lane_positions=True,
Comment on lines 367 to +376
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This updates AgentType.Full to have more observations.

signals=True,
action=ActionSpaceType.Continuous,
)
Expand Down
Loading