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

Add conditions to sstudio #1965

Merged
merged 61 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e5206d7
Add conditions to sstudio
Gamenot Apr 17, 2023
ba6169d
Update entry tactic to use a single condition.
Gamenot Apr 17, 2023
d9e57e8
Clean up naming.
Gamenot Apr 17, 2023
6d7e449
Add delay condition and subject conditions.
Gamenot Apr 28, 2023
1166e98
Remove circular import.
Gamenot May 3, 2023
2b47c50
Remove condition from entry_tactic.
Gamenot May 3, 2023
8780ea1
Prepare for evaluating conditions
Gamenot May 4, 2023
ec87202
Add conditions to id_actor_capture_manager.
Gamenot May 4, 2023
f4381a1
Test conditions in id capture manager.
Gamenot May 4, 2023
9e9b8d3
Deprecated sstudio mission start time.
Gamenot May 5, 2023
6c2bddd
Add back start_time but deprecate.
Gamenot May 5, 2023
d4d1677
Fix missing constant.
Gamenot May 5, 2023
2ba1928
Change NameError to DeprecationWarning for deprecation.
Gamenot May 5, 2023
006a4cc
Give GroupedLapMission entry tactic.
Gamenot May 5, 2023
afd5d49
Fix delay condition.
Gamenot May 5, 2023
58d23e6
Disallow abstract condition operations.
Gamenot May 5, 2023
bac5cf9
Move abstract condition constraints down.
Gamenot May 5, 2023
233dd44
Centralize listing of abstract conditions.
Gamenot May 5, 2023
5ddf0e9
Fix naming in error.
Gamenot May 5, 2023
4b92b79
Remove simplified negation.
Gamenot May 5, 2023
3a9004e
Make conditions solely true.
Gamenot May 5, 2023
0ee661c
Remove unused arguement.
Gamenot May 5, 2023
01efa0e
Add tests.
Gamenot May 5, 2023
4ad3411
Add vehicle type condition tests.
Gamenot May 5, 2023
675db3d
Add vehicle speed condition.
Gamenot May 5, 2023
4256a67
Add time window check for after.
Gamenot May 5, 2023
22e196f
Update subject condition.
Gamenot May 5, 2023
9222e71
Fix missing import
Gamenot May 5, 2023
cc05370
Finish ConditionState cases.
Gamenot May 5, 2023
31307db
Clarify operations.
Gamenot May 5, 2023
79f171a
Update condition descriptions.
Gamenot May 5, 2023
4360917
Fix logic for disjunction of expired condition state.
Gamenot May 5, 2023
ee8cf6d
Add test for dependee condition.
Gamenot May 8, 2023
a0aaa4a
Update condition with information requirements.
Gamenot May 9, 2023
47fe0e0
Update condition types and terminology.
Gamenot May 11, 2023
de21f79
Implement conditions in trap manager.
Gamenot May 11, 2023
ea43885
Bubble manager now inherits form ActorCaptureManager.
Gamenot May 11, 2023
e0d1986
Fix docstring test.
Gamenot May 11, 2023
8d7e5bc
Exclude waymo init files in header gen.
Gamenot May 11, 2023
25840d7
Fix type issues.
Gamenot May 11, 2023
8bc0a57
Update type condition tests.
Gamenot May 11, 2023
8f2de13
Use flags to control condition evaluation parameters.
Gamenot May 11, 2023
e6e3c46
Fix condition trigger.
Gamenot May 11, 2023
f0e896b
Address type issues.
Gamenot May 11, 2023
2991d66
Update changelog.
Gamenot May 11, 2023
469c620
Fix scenarios.
Gamenot May 11, 2023
f2436b2
Remove erroneous imports.
Gamenot May 12, 2023
4e47c67
Short circuit condition operators.
Gamenot May 12, 2023
32f3999
Fix unbound variable access in trap manager.
Gamenot May 12, 2023
732eeb1
Address reviews.
Gamenot May 12, 2023
6ebfe76
Fix unintentional scenario changes.
Gamenot May 12, 2023
7019205
Default wait_to_hijack_limit_s to 0.
Gamenot May 12, 2023
b657797
Allow for relative expiry on ExpireTrigger.
Gamenot May 12, 2023
f415d77
Wrap up PR.
Gamenot May 12, 2023
3bfefa6
Merge branch 'master' into tucker/add-sstudio_conditions
Gamenot May 12, 2023
5ce4081
Fix trap manager test.
Gamenot May 12, 2023
ee5c0c1
Refactor sstudio types.
Gamenot May 15, 2023
85d068f
Update scenarios.
Gamenot May 16, 2023
7a07ab4
Fix type test.
Gamenot May 16, 2023
1ece0de
Fix data formatting test.
Gamenot May 16, 2023
69f9410
Merge branch 'master' into tucker/add-sstudio_conditions
Gamenot May 17, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Added
- `visdom` can now be configured through the engine.ini configuration file `visdom:enabled`, `visdom:hostname`, and `visdom:port` (environment variables `SMARTS_VISDOM_ENABLED`, `SMARTS_VISDOM_HOSTNAME`, `SMARTS_VISDOM_PORT`.)
- Added an install extra that installs the requirements for all optional modules. Use `pip install .[all]`.
- Added `Condition`, `ConditionRequires`, `ConditionState` and various condition implementations to enable logical operations in scenarios.
### Changed
- Changed waypoints in sumo maps to use more incoming lanes into junctions.
- Increased the cutoff radius for filtering out waypoints that are too far away in junctions in sumo maps.
Expand All @@ -20,6 +21,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- `SumoTrafficSimulator` now uses the last vehicle subscription update to back `route_for_vehicle()`. This means that the routes of vehicles can still be determined even if `SumoTrafficSimulation` disconnects.
- Reward function in platoon RL example retrieves actor-of-interest from marked neighborhood vehicles.
- `dist_to_destination` metric cost function computes the route distance and end point for vehicle of interest contained in social agents, SMARTS traffic provider, SUMO traffic provider, and traffic history provider.
- `sstudio` generated scenario vehicle traffic IDs are now shortened.
### Deprecated
- `visdom` is set to be removed from the SMARTS object parameters.
### Fixed
Expand Down Expand Up @@ -83,6 +85,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Driving SMARTS 2023.3 benchmark and the metrics module now uses `actor_of_interest_re_filter` from scenario metadata to identify the lead vehicle.
- Included `RelativeTargetPose` action space to the set of allowed action spaces in `platoon-v0` env.
- `Collision.collidee_id` now gives the vehicle id rather than the name of the owner of the vehicle (usually the agent id.) `Collision.collidee_owner_id` now provides the id of the controlling `agent` (or other controlling entity in the future.) This is because 1) `collidee_id` should refer to the body and 2) in most cases the owner name would be `None`.
- Entry tactics now use conditions to determine when they should capture an actor.
### Deprecated
### Fixed
- Fixed issues related to waypoints in junctions on Argoverse maps. Waypoints will now be generated for all paths leading through the lane(s) the vehicle is on.
Expand Down
2 changes: 1 addition & 1 deletion bin/gen_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ files=""

if [[ $# -eq 0 ]]; then
# No specific file specified, collate all files excluding auto generated files of *_pb2.py and *_pb2_grpc.py
python_files="$(find ./baselines/marl_benchmark ./cli ./envision ./smarts -name '*.py' ! -name '*_pb2.py' ! -name '*_pb2_grpc.py')"
python_files="$(find ./baselines/marl_benchmark ./cli ./envision ./smarts -name '*.py' ! -name '*_pb2.py' ! -name '*_pb2_grpc.py' ! -wholename '**/waymo/**/__init__.py')"
js_files="$(find ./envision/web/src -name '*.js')"
files="$python_files $js_files"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
ego_missions = [
Mission(
route=route,
start_time=12, # Delayed start, to ensure road has prior traffic.
entry_tactic=TrapEntryTactic(
start_time=12, # Delayed start, to ensure road has prior traffic.
wait_to_hijack_limit_s=1,
zone=MapZone(
start=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -86,7 +94,9 @@
ego_missions = [
Mission(
route=route,
start_time=4, # Delayed start, to ensure road has prior traffic.
entry_tactic=TrapEntryTactic(
start_time=4, wait_to_hijack_limit_s=0
), # Delayed start, to ensure road has prior traffic.
)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -80,8 +88,11 @@
ego_missions = [
Mission(
route=route,
start_time=4, # Delayed start, to ensure road has prior traffic.
)
entry_tactic=TrapEntryTactic(
start_time=4,
wait_to_hijack_limit_s=1,
),
),
]

gen_scenario(
Expand Down
7 changes: 6 additions & 1 deletion scenarios/sumo/loop/scenario.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import random
import sys
from pathlib import Path

from smarts.core import seed
Expand Down Expand Up @@ -54,7 +55,11 @@
[
t.Mission(
route=t.RandomRoute(),
entry_tactic=t.IdEntryTactic("other_interest", patience=10),
entry_tactic=t.IdEntryTactic(
start_time=0.1,
actor_id="other_interest",
condition=t.TimeWindowCondition(0.1, 20.0),
),
)
],
)
Expand Down
18 changes: 13 additions & 5 deletions scenarios/sumo/merge/3lane_agents_1/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -71,12 +79,12 @@
]
)

route = Route(begin=("gneE6", 0, 10), end=("gneE4", 2, "max"))

ego_missions = [
Mission(
route=route,
start_time=15, # Delayed start, to ensure road has prior traffic.
)
Route(begin=("gneE6", 0, 10), end=("gneE4", 2, "max")),
entry_tactic=TrapEntryTactic(start_time=15, wait_to_hijack_limit_s=0),
),
]

gen_scenario(
Expand Down
20 changes: 17 additions & 3 deletions scenarios/sumo/merge/3lane_agents_2/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -73,8 +81,14 @@


ego_missions = [
Mission(Route(begin=("gneE6", 0, 10), end=("gneE4", 2, "max")), start_time=15),
Mission(Route(begin=("gneE3", 0, 10), end=("gneE4", 0, "max")), start_time=15),
Mission(
Route(begin=("gneE6", 0, 10), end=("gneE4", 2, "max")),
entry_tactic=TrapEntryTactic(start_time=15, wait_to_hijack_limit_s=0),
),
Mission(
Route(begin=("gneE3", 0, 10), end=("gneE4", 0, "max")),
entry_tactic=TrapEntryTactic(start_time=15, wait_to_hijack_limit_s=0),
),
]

gen_scenario(
Expand Down
5 changes: 3 additions & 2 deletions scenarios/sumo/platoon/merge_exit_sumo_t_agents_1/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@
ego_missions = [
EndlessMission(
begin=("E0", 2, 5),
start_time=31,
entry_tactic=TrapEntryTactic(wait_to_hijack_limit_s=0, default_entry_speed=0),
entry_tactic=TrapEntryTactic(
start_time=31, wait_to_hijack_limit_s=0, default_entry_speed=0
),
) # Delayed start, to ensure road has prior traffic.
]

Expand Down
14 changes: 12 additions & 2 deletions scenarios/sumo/straight/3lane_cruise_agents_1/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -76,7 +84,9 @@
ego_missions = [
Mission(
route=route,
start_time=17, # Delayed start, to ensure road has prior traffic.
entry_tactic=TrapEntryTactic(
start_time=17, wait_to_hijack_limit_s=0
), # Delayed start, to ensure road has prior traffic.
)
]

Expand Down
25 changes: 21 additions & 4 deletions scenarios/sumo/straight/3lane_cruise_agents_3/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
from pathlib import Path

from smarts.sstudio import gen_scenario
from smarts.sstudio.types import Flow, Mission, Route, Scenario, Traffic, TrafficActor
from smarts.sstudio.types import (
Flow,
Mission,
Route,
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
name="car",
Expand Down Expand Up @@ -72,9 +80,18 @@
)

ego_missions = [
Mission(Route(begin=("gneE3", 0, 10), end=("gneE3", 0, "max")), start_time=19),
Mission(Route(begin=("gneE3", 1, 10), end=("gneE3", 1, "max")), start_time=21),
Mission(Route(begin=("gneE3", 2, 10), end=("gneE3", 2, "max")), start_time=17),
Mission(
Route(begin=("gneE3", 0, 10), end=("gneE3", 0, "max")),
entry_tactic=TrapEntryTactic(start_time=19, wait_to_hijack_limit_s=0),
),
Mission(
Route(begin=("gneE3", 1, 10), end=("gneE3", 1, "max")),
entry_tactic=TrapEntryTactic(start_time=21, wait_to_hijack_limit_s=0),
),
Mission(
Route(begin=("gneE3", 2, 10), end=("gneE3", 2, "max")),
entry_tactic=TrapEntryTactic(start_time=17, wait_to_hijack_limit_s=0),
),
]

gen_scenario(
Expand Down
5 changes: 4 additions & 1 deletion scenarios/sumo/straight/3lane_cut_in_agents_1/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
SmartsLaneChangingModel,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
Expand Down Expand Up @@ -94,7 +95,9 @@
ego_missions = [
Mission(
route=route,
start_time=20, # Delayed start, to ensure road has prior traffic.
entry_tactic=TrapEntryTactic(
start_time=20, wait_to_hijack_limit_s=0.1
), # Delayed start, to ensure road has prior traffic.
)
]

Expand Down
5 changes: 4 additions & 1 deletion scenarios/sumo/straight/3lane_overtake_agents_1/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Scenario,
Traffic,
TrafficActor,
TrapEntryTactic,
)

normal = TrafficActor(
Expand Down Expand Up @@ -83,7 +84,9 @@
ego_missions = [
Mission(
route=route,
start_time=17, # Delayed start, to ensure road has prior traffic.
entry_tactic=TrapEntryTactic(
start_time=17, wait_to_hijack_limit_s=0.1
), # Delayed start, to ensure road has prior traffic.
)
]

Expand Down
8 changes: 7 additions & 1 deletion scenarios/sumo/zoo_intersection/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SocialAgentActor,
Traffic,
TrafficActor,
TrapEntryTactic,
)

# Traffic Vehicles
Expand Down Expand Up @@ -96,7 +97,12 @@
f"s-agent-{social_agent1.name}": (
[social_agent1],
[
EndlessMission(begin=("edge-south-SN", 0, 10), start_time=0.7),
EndlessMission(
begin=("edge-south-SN", 0, 10),
entry_tactic=TrapEntryTactic(
start_time=0.7, wait_to_hijack_limit_s=0.1
),
),
],
),
},
Expand Down
Loading