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

CI test for performance metrics #1778

Merged
merged 822 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
822 commits
Select commit Hold shift + click to select a range
a24d965
Restore and update traffic histories vehicle replacement script. Fix …
saulfield Aug 3, 2022
d403d31
Revert incoming lanes change, since it's fixed on another PR
saulfield Aug 3, 2022
ba328e8
Merge branch 'develop' into comp-1
Gamenot Aug 3, 2022
6d869a9
Update README.md
Gamenot Aug 4, 2022
6709b1b
Remove print statement
saulfield Aug 4, 2022
bafcd63
Review suggestion
saulfield Aug 8, 2022
2fa0b4c
Clean up the instructions.
Adaickalavan Aug 9, 2022
dfb844f
Merge branch 'comp-1' into waymo-utils-1
Adaickalavan Aug 9, 2022
35b2895
Changes based on PR review
saulfield Aug 9, 2022
48c2be5
Merge branch 'saul/waymo-utils' into waymo-utils-1
Adaickalavan Aug 9, 2022
f2354be
Waymo tools and offline dataset extraction (#1545)
saulfield Aug 9, 2022
b61735d
Clean up the instructions.
Adaickalavan Aug 9, 2022
460bc27
Merge branch 'comp-1' into waymo-utils-1
Adaickalavan Aug 9, 2022
efa2203
Fix imports.
Adaickalavan Aug 9, 2022
eb8ece2
Fix bug when labelling vehicles (#1550)
saulfield Aug 9, 2022
95d77a1
Fix text.
Adaickalavan Aug 9, 2022
0ee7016
Merge branch 'comp-1' into waymo-utils-1
Adaickalavan Aug 9, 2022
bc02028
Fix waymo instructions.
Adaickalavan Aug 10, 2022
3f26774
Merge branch 'waymo-utils-1' into comp-x
Adaickalavan Aug 10, 2022
f8abdbb
Fix ToC.
Adaickalavan Aug 10, 2022
03e451a
Sync remote and local overview file.
Adaickalavan Aug 10, 2022
ba05408
Sync remote and local overview file.
Adaickalavan Aug 10, 2022
a9d9aa8
Fix missing dependency.
Adaickalavan Aug 10, 2022
2bdb643
Make format.
Adaickalavan Aug 10, 2022
57f2dc4
Improve instructions.
Adaickalavan Aug 10, 2022
f3a1e55
Merge branch 'develop' into comp-x
Adaickalavan Aug 10, 2022
2286401
Latest develop and waymo tool.
Adaickalavan Aug 10, 2022
ad42e05
Reiterate the mandatory use of TargetPose action space.
Adaickalavan Aug 10, 2022
7018ca0
Reiterate the mandatory use of TargetPose action space.
Adaickalavan Aug 10, 2022
a34573f
Merge branch 'comp-1' into comp-x
Adaickalavan Aug 10, 2022
e9b9ade
Fix plotting bug
saulfield Aug 10, 2022
bf0abae
Merge branch 'comp-1' into comp-x
Adaickalavan Aug 10, 2022
5bc869a
Merge branch 'develop' into comp-x
Adaickalavan Aug 10, 2022
d84b0d6
Merge branch 'develop' into comp-x
Adaickalavan Aug 11, 2022
16aefc0
Update zipping of folder.
Adaickalavan Aug 11, 2022
c97956e
Merge branch 'develop' into comp-x
Adaickalavan Aug 11, 2022
5aa897d
Add dataset explanation.
Adaickalavan Aug 11, 2022
ae78a3e
Update zipped folder.
Adaickalavan Aug 12, 2022
6b8f6d2
Fix issue where traffic lights are not in current dataset.
Gamenot Aug 12, 2022
6f5ecc8
Improve evaluation setup
Gamenot Aug 11, 2022
e5017cc
Add app key to the bubble_env clone command to address issues.
Gamenot Aug 12, 2022
e7b7647
Validate that evaluation dependencies are installed.
Gamenot Aug 12, 2022
457cdfc
Update readme with information on dependency install.
Gamenot Aug 12, 2022
eca68d4
Merge branch 'develop' into comp-1
Gamenot Aug 14, 2022
76808cd
Merge branch 'develop' into comp-x
Adaickalavan Aug 14, 2022
e13e15a
Merge branch 'comp-x' into comp-1
Adaickalavan Aug 14, 2022
f0626d4
Offline baseline 2 (#1543)
Gamenot Aug 14, 2022
8107bf3
Merge branch 'develop' into comp-1
Adaickalavan Aug 16, 2022
a216d4e
Range of time delta in TargetPose.
Adaickalavan Aug 16, 2022
2f80835
Change offline dataset naming.
Adaickalavan Aug 18, 2022
6774536
Merge branch 'develop' into comp-1
Gamenot Aug 18, 2022
cacff0f
Merge branch 'comp-add' into comp-1
Adaickalavan Aug 18, 2022
35a7df7
Merge branch 'develop' into comp-1
Adaickalavan Aug 18, 2022
54c6922
Remove scenario and traffic history prefix in name of offline dataset…
saulfield Aug 18, 2022
ab0ec88
Add instructions.
Adaickalavan Aug 19, 2022
b88da5e
Minor changes.
Adaickalavan Aug 19, 2022
07c123a
Minor changes.
Adaickalavan Aug 19, 2022
35d3575
Simplify instructions.
Adaickalavan Aug 20, 2022
58233c2
Simplify instructions.
Adaickalavan Aug 20, 2022
396faf9
Simplify instructions.
Adaickalavan Aug 20, 2022
965a00c
Beautify the table.
Adaickalavan Aug 20, 2022
62c6168
Add waymo dependencies.
Adaickalavan Aug 20, 2022
1251384
Add waymo dependencies.
Adaickalavan Aug 20, 2022
335101f
Bubble env seeds.
Adaickalavan Aug 20, 2022
7fa0ffc
Make Format.
Adaickalavan Aug 20, 2022
50ef281
Simplify instructions.
Adaickalavan Aug 20, 2022
acef818
Improve instructions.
Adaickalavan Aug 22, 2022
40b2e1c
Merge branch 'develop' into comp-1
Gamenot Aug 22, 2022
c3d06d2
Merge branch 'develop' into comp-1
Adaickalavan Aug 23, 2022
dfe4642
Merge branch 'develop' into comp-1
Adaickalavan Aug 23, 2022
5ce6909
Merge branch 'develop' into comp-1
Adaickalavan Aug 26, 2022
85d724d
Simplify code.
Adaickalavan Aug 26, 2022
70fc8e2
Offline baseline (#1572)
cz0204 Aug 29, 2022
bce2cf3
Add the phrase `visualize`.
Adaickalavan Aug 29, 2022
90382f0
Configure eval episode count.
Adaickalavan Aug 31, 2022
6ea8da4
Add a mirror for fallback install
Gamenot Sep 1, 2022
ad8e1a6
Remove pip extra index
Gamenot Sep 6, 2022
26d25de
Merge branch 'develop' into comp-1
Adaickalavan Sep 7, 2022
d12fc37
Limit TargetPose action range (#1622)
Adaickalavan Sep 8, 2022
34a93f0
Fix scenario path
Adaickalavan Sep 8, 2022
03b5241
Add multiprocess for eval.
Adaickalavan Sep 8, 2022
cca4237
Merge branch 'comp-1' into eval-mp
Adaickalavan Sep 8, 2022
f62f211
Multiprocess pool for eval.
Adaickalavan Sep 9, 2022
7d74ef7
Update cloudpickle version
Adaickalavan Sep 9, 2022
262d206
Use concurrent.futures.ProcessPoolExecutor .
Adaickalavan Sep 9, 2022
11921d0
Add mp_context.
Adaickalavan Sep 10, 2022
4583064
Revert temp changes.
Adaickalavan Sep 10, 2022
5270546
Update from develop branch.
Adaickalavan Sep 10, 2022
11c3842
Update from develop branch.
Adaickalavan Sep 10, 2022
9a59a1d
Ignore files during zip.
Adaickalavan Sep 10, 2022
1cf5adf
Fix name-error.
Adaickalavan Sep 10, 2022
bf8e5dd
Fix format.
Adaickalavan Sep 10, 2022
872a193
Multiprocessed evaluation.
Adaickalavan Sep 11, 2022
2c14fde
Add red-coloured ego agent to observation in pkl file. (#1627)
Adaickalavan Sep 14, 2022
c677953
Fix local traffic (#1628)
Gamenot Sep 14, 2022
d5fa226
Add example offline_dataset.
Adaickalavan Sep 14, 2022
b654e22
Move offline dataset.
Adaickalavan Sep 14, 2022
37d3799
Updates from develop.
Adaickalavan Sep 18, 2022
2690423
Add PR1630
Adaickalavan Sep 20, 2022
ea3315c
Update CQL example.
Adaickalavan Sep 28, 2022
f26df85
Envision fixes (#1651)
saulfield Oct 5, 2022
82f71a0
Bugfix trip meter sensor [closes #1656] (#1657)
Gamenot Oct 6, 2022
271a9c8
Fix signal observations (#1661)
saulfield Oct 6, 2022
1e5e50c
Goal position fixes (#1637)
saulfield Oct 6, 2022
8fa863b
Add gifs of single trained model navigating multiple scenarios.
Adaickalavan Oct 11, 2022
58a61aa
Improved example.
Adaickalavan Oct 12, 2022
e5548f8
Suppress websocket 'goodbye' messages
Gamenot Oct 17, 2022
8b7a09e
Bugfix envision resource path (#1682)
Gamenot Oct 26, 2022
3597596
Install smarts in track2 docker image to load offline dataset.
Adaickalavan Oct 27, 2022
a8c7e22
Use resource location for path (#1685)
Gamenot Oct 28, 2022
18f3645
Minor syntax update
Adaickalavan Oct 30, 2022
0097357
Read offline dataset in small chunks to avoid oom.
Adaickalavan Oct 30, 2022
e07d960
Improve costs.
Adaickalavan Nov 3, 2022
31ee15a
Update dockerfile.
Adaickalavan Nov 10, 2022
4098f4a
Updated overview
Adaickalavan Nov 22, 2022
642bfb8
Updated evaluation.html.
Adaickalavan Nov 22, 2022
b66b051
Updated terms_and_conditions.html
Adaickalavan Nov 22, 2022
c0d81ca
Updated rules.html
Adaickalavan Nov 22, 2022
95e86d7
Updated rules.html
Adaickalavan Nov 22, 2022
e70c57b
Updated data.html
Adaickalavan Nov 22, 2022
57a8087
Improved explanation.md file.
Adaickalavan Nov 22, 2022
d71d395
Remove readme preface.
Adaickalavan Nov 22, 2022
334d9ab
Improved competition.yaml
Adaickalavan Nov 22, 2022
c5839af
Merge branch 'develop' into metrics
Adaickalavan Nov 23, 2022
bee1d52
Merge branch 'develop' into metrics
Adaickalavan Nov 23, 2022
66d25a0
Moved files.
Adaickalavan Nov 23, 2022
98c908c
Update cost funcs.
Adaickalavan Nov 24, 2022
4bfe3ba
Merge branch 'develop' into metrics
Adaickalavan Nov 24, 2022
448050f
Reorganised metrics.
Adaickalavan Nov 24, 2022
c46906b
Add dataclass function.
Adaickalavan Nov 24, 2022
c0cdeb8
Refactored metrics wrapper.
Adaickalavan Nov 26, 2022
19717b3
Add docstring.
Adaickalavan Nov 26, 2022
851b15e
Prevent access to private items.
Adaickalavan Nov 26, 2022
57f2358
Remove copy_data
Adaickalavan Nov 26, 2022
6177246
Remove competition bundle and track2 folders.
Adaickalavan Nov 27, 2022
9835417
Merge branch 'develop' into metrics
Adaickalavan Nov 27, 2022
6493610
Revert md format change.
Adaickalavan Nov 27, 2022
7c959b5
Remove evaluation folder.
Adaickalavan Nov 27, 2022
a4652a3
Update to develop branch.
Adaickalavan Nov 27, 2022
01fad70
Fix docstring.
Adaickalavan Nov 27, 2022
0477f72
Fix docstring.
Adaickalavan Nov 27, 2022
3073f50
Make folder a module.
Adaickalavan Nov 27, 2022
4908418
Make method as property.
Adaickalavan Nov 27, 2022
cc28b26
Fix key error.
Adaickalavan Nov 27, 2022
2124216
Cost function returns Costs dataclass.
Adaickalavan Nov 27, 2022
33ef473
Make count and cost as frozen dataclass.
Adaickalavan Nov 28, 2022
278d4cd
CostFunc should return Cost dataclass.
Adaickalavan Nov 28, 2022
6980180
Update counts and costs.
Adaickalavan Nov 28, 2022
314cc81
Make Format.
Adaickalavan Nov 28, 2022
b66cb8e
Make Format.
Adaickalavan Nov 28, 2022
2f13875
Small modification.
Adaickalavan Nov 28, 2022
fa27aa7
Fix pytype and docstring.
Adaickalavan Nov 28, 2022
b10ccac
Fix pytype.
Adaickalavan Nov 28, 2022
d192c27
Check env compatibility for use of Metrics wrapper.
Adaickalavan Nov 28, 2022
f98197e
Prevent access to private variables.
Adaickalavan Nov 28, 2022
ec17661
Prevent access to private variables.
Adaickalavan Nov 28, 2022
fe228f6
Remove competition track1 folder.
Adaickalavan Nov 28, 2022
3dedf1c
Add changelog.
Adaickalavan Nov 28, 2022
bffa652
Merge branch 'develop' into metrics-2
Adaickalavan Nov 29, 2022
72ffff7
Merge branch 'develop' into metrics-1
Adaickalavan Nov 29, 2022
e0e2ac4
Check existence of mission goal before computing metric.
Adaickalavan Nov 29, 2022
fe6d588
Check existence of mission goal before computing metric.
Adaickalavan Nov 29, 2022
6178a7a
Simplification.
Adaickalavan Nov 29, 2022
c875f15
Add units.
Adaickalavan Nov 29, 2022
c3f71da
Add pytype.
Adaickalavan Nov 29, 2022
993cb7d
Minor
Adaickalavan Nov 29, 2022
4b8c126
Fix import paths.
Adaickalavan Nov 29, 2022
b180457
Revert circular imports.
Adaickalavan Nov 29, 2022
f0a2a3a
Revert circular imports.
Adaickalavan Nov 29, 2022
2048eac
Normalize linear jerk.
Adaickalavan Nov 30, 2022
78b4da2
Add explanation.
Adaickalavan Nov 30, 2022
5f3c1e8
Fix nomenclature.
Adaickalavan Nov 30, 2022
d5f7683
Update docstrings.
Adaickalavan Nov 30, 2022
5c9a0cf
Set jerk_linear_max
Adaickalavan Nov 30, 2022
dece048
Updated docstrings.
Adaickalavan Dec 1, 2022
a602078
Improve norm computation.
Adaickalavan Dec 1, 2022
8c40c72
Merge branch 'develop' into metrics-2
Adaickalavan Dec 2, 2022
39caf47
Remove unused type.
Adaickalavan Dec 2, 2022
d1af349
Provide privileged access.
Adaickalavan Dec 5, 2022
a4ee0bb
Add docstring
Adaickalavan Dec 5, 2022
70ea7c6
Build plan for each agent.
Adaickalavan Dec 5, 2022
d2cf303
Merge branch 'metrics-2' of https://github.com/huawei-noah/SMARTS int…
Adaickalavan Dec 5, 2022
24bfbca
Temporarily modified example for testing.
Adaickalavan Dec 5, 2022
2e0b381
Add temporary comment.
Adaickalavan Dec 5, 2022
f013f30
Check scenario
Adaickalavan Dec 5, 2022
437754b
Add docstring.
Adaickalavan Dec 5, 2022
298bb8c
Temp changes.
Adaickalavan Dec 6, 2022
1941dda
Remove dist_to_goal from cost funcs. Add completion template.
Adaickalavan Dec 6, 2022
e479bdf
Move running_mean function to math utils.
Adaickalavan Dec 6, 2022
ca87887
Add completion dataclass.
Adaickalavan Dec 6, 2022
756c233
Temp changes.
Adaickalavan Dec 6, 2022
157991e
Remove unused return value.
Adaickalavan Dec 7, 2022
739fb33
Add completion metric.
Adaickalavan Dec 7, 2022
cfe2c01
Minor.
Adaickalavan Dec 7, 2022
b90d983
Revert this debug commit.
Adaickalavan Dec 8, 2022
4bf3247
Fix from_front_bumper in Start.
Adaickalavan Dec 8, 2022
b254bca
Import types.
Adaickalavan Dec 8, 2022
f439328
Try single agent example.
Adaickalavan Dec 8, 2022
224a73a
Improve comments.
Adaickalavan Dec 8, 2022
38b5e0c
Fix pytype.
Adaickalavan Dec 8, 2022
234ffcb
Unify completion functions.
Adaickalavan Dec 8, 2022
a966def
Revert unified completion function.
Adaickalavan Dec 8, 2022
4d3dfef
Change score computation.
Adaickalavan Dec 8, 2022
fa4fdc5
Merge branch 'develop' into metrics-2
Adaickalavan Dec 9, 2022
1cbc38a
Add initial completion values to completion funcs.
Adaickalavan Dec 9, 2022
171f225
Fix completion metric calculation.
Adaickalavan Dec 9, 2022
0ae4417
Removed termination class.
Adaickalavan Dec 9, 2022
4ca4e5f
Removed termination class.
Adaickalavan Dec 9, 2022
1691ddb
Use max steps from agent specs.
Adaickalavan Dec 12, 2022
d2cba3a
Introduce single overall score.
Adaickalavan Dec 12, 2022
e4e72a5
Remove print statements.
Adaickalavan Dec 12, 2022
1c41822
Temp debug
Adaickalavan Dec 12, 2022
16b55a8
Merge branch 'develop' into metrics-1
Adaickalavan Dec 12, 2022
03bbfbd
Merge review changes.
Adaickalavan Dec 12, 2022
1a337e5
Add type assert.
Adaickalavan Dec 12, 2022
57aa422
Remove termination file.
Adaickalavan Dec 12, 2022
baebc56
Merge branch 'metrics-1' into metrics-2
Adaickalavan Dec 12, 2022
2245bf6
Add docstring.
Adaickalavan Dec 12, 2022
116df9b
Changed steps_adjusted and done check.
Adaickalavan Dec 12, 2022
0489671
Simplify if-else condition.
Adaickalavan Dec 12, 2022
0e5a425
Remove unused import.
Adaickalavan Dec 12, 2022
b5c3501
Simplify debug statements.
Adaickalavan Dec 12, 2022
90f1d28
Nearest starting lanes are tried in sequence to find a route.
Adaickalavan Dec 12, 2022
dce7025
Fix error messages and remove comments.
Adaickalavan Dec 12, 2022
d5fb181
Clean up.
Adaickalavan Dec 13, 2022
4690590
Typo.
Adaickalavan Dec 13, 2022
f6c8b50
Clean up.
Adaickalavan Dec 13, 2022
f239816
Revert test files.
Adaickalavan Dec 13, 2022
72532a2
Merge branch 'develop' into metrics-2
Adaickalavan Dec 14, 2022
5d32452
Merge branch 'develop' into metrics-2
Adaickalavan Dec 14, 2022
5cc772b
Merge branch 'develop' into metrics-2
Adaickalavan Dec 17, 2022
4482821
Remove unused.
Adaickalavan Dec 17, 2022
ce48b1c
Avoid waypoints as they are ill-defined when off-route.
Adaickalavan Dec 17, 2022
f9def1e
Avoid waypoints as they are ill-defined when off-route.
Adaickalavan Dec 17, 2022
88076da
Add search radius for nearest lanes.
Adaickalavan Dec 18, 2022
fb701fe
Remove debug line.
Adaickalavan Dec 18, 2022
956b267
Add test for metrics.
Adaickalavan Dec 19, 2022
b53f669
Test init, reset, records, and score.
Adaickalavan Dec 19, 2022
4e097a2
Made get_scenario fixture indirect and scoped it.
Adaickalavan Dec 19, 2022
2ad4ae4
Fix type.
Adaickalavan Dec 19, 2022
648be7f
Add test step off road.
Adaickalavan Dec 19, 2022
9285da1
Add end in junction test.
Adaickalavan Dec 19, 2022
c236956
Change to underscored function.
Adaickalavan Dec 19, 2022
23772dc
Rename test function.
Adaickalavan Dec 19, 2022
1d546df
Cleaned.
Adaickalavan Dec 19, 2022
0621e2a
Add test for vehicle ending in off route.
Adaickalavan Dec 20, 2022
14907dc
Separate proper and improper interface tests.
Adaickalavan Jan 4, 2023
fb5da49
Merge branch 'develop' into metrics-3
Adaickalavan Jan 6, 2023
2341428
Describe score range.
Adaickalavan Jan 9, 2023
e749f0e
Make humanness and rules to be maximized.
Adaickalavan Jan 11, 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
2 changes: 0 additions & 2 deletions examples/single_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from smarts.env.wrappers.single_agent import SingleAgent
from smarts.zoo.agent_spec import AgentSpec

logging.basicConfig(level=logging.INFO)


class ChaseViaPointsAgent(Agent):
def act(self, obs: Observation):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ rsa==4.9
Rtree==1.0.1
scipy==1.7.3
sh==1.14.3
shapely==2.0.0
Shapely==1.8.5.post1
six==1.16.0
soupsieve==2.3.2.post1
tableprint==0.9.1
Expand Down
6 changes: 1 addition & 5 deletions smarts/core/lanepoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
# to allow for typing to refer to class being defined (LinkedLanePoint)
from __future__ import annotations

import math
import queue
import warnings
from collections import defaultdict
from dataclasses import dataclass
from functools import lru_cache
from typing import List, NamedTuple, Optional, Sequence, Tuple
from typing import List, NamedTuple, Sequence, Tuple

import numpy as np
from scipy.spatial import KDTree
Expand All @@ -36,9 +34,7 @@
from smarts.core.road_map import RoadMap
from smarts.core.utils.math import (
fast_quaternion_from_angle,
lerp,
squared_dist,
vec_2d,
vec_to_radians,
)

Expand Down
47 changes: 24 additions & 23 deletions smarts/core/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,15 @@ def road_map(self) -> RoadMap:
"""The road map this plan is relative to."""
return self._road_map

def create_route(self, mission: Mission):
def create_route(self, mission: Mission, radius: Optional[float] = None):
"""Generates a route that conforms to a mission.
Args:
mission (Mission):
A mission the agent should follow. Defaults to endless if `None`.
radius (Optional[float]):
Radius (meter) to find the nearest starting lane for the given
mission. Defaults to `_default_lane_width` of the underlying
road_map.
"""
assert not self._route, "already called create_route()"
self._mission = mission or Mission.random_endless_mission(self._road_map)
Expand All @@ -335,45 +339,42 @@ def create_route(self, mission: Mission):

assert isinstance(self._mission.goal, PositionalGoal)

start_lane = self._road_map.nearest_lane(
start_lanes = self._road_map.nearest_lanes(
self._mission.start.point,
include_junctions=False,
include_junctions=True,
radius=radius,
)

if not start_lane:
# it's possible that the Mission's start point wasn't explicitly
# specified by a user, but rather determined during the scenario run
# from the current position of a vehicle, in which case it may be
# in a junction. But we only allow this if the previous query fails.
start_lane = self._road_map.nearest_lane(
self._mission.start.point,
include_junctions=True,
)
if start_lane is None:
if not start_lanes:
self._mission = Mission.endless_mission(Pose.origin())
raise PlanningError("Cannot find start lane. Route must start in a lane.")
start_road = start_lane.road
raise PlanningError("Starting lane not found. Route must start in a lane.")

via_roads = [self._road_map.road_by_id(via) for via in self._mission.route_vias]

end_lane = self._road_map.nearest_lane(
self._mission.goal.position,
include_junctions=False,
)
assert end_lane is not None, "route must end in a lane"
end_road = end_lane.road

via_roads = [self._road_map.road_by_id(via) for via in self._mission.route_vias]

self._route = self._road_map.generate_routes(
start_road, end_road, via_roads, 1
)[0]
# When an agent is in an intersection, the `nearest_lanes` method might
# not return the correct road as the first choice. Hence, nearest
# starting lanes are tried in sequence until a route is found or until
# all nearby starting lane options are exhausted.
for start_lane, _ in start_lanes:
self._route = self._road_map.generate_routes(
start_lane.road, end_lane.road, via_roads, 1
)[0]
if self._route.road_length > 0:
break

if len(self._route.roads) == 0:
self._mission = Mission.endless_mission(Pose.origin())
start_road_ids = [start_lane.road.road_id for start_lane, _ in start_lanes]
raise PlanningError(
"Unable to find a route between start={} and end={}. If either of "
"these are junctions (not well supported today) please switch to "
"roads and ensure there is a > 0 offset into the road if it is "
"after a junction.".format(start_road.road_id, end_road.road_id)
"after a junction.".format(start_road_ids, end_lane.road.road_id)
)

return
9 changes: 6 additions & 3 deletions smarts/core/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
Optional,
Sequence,
Tuple,
Union,
)

import cloudpickle
Expand Down Expand Up @@ -570,7 +571,7 @@ def get_vehicle_start_at_time(
Start(
np.array([pos_x + hhx, pos_y + hhy]),
Heading(heading),
from_front_bumper=False,
from_front_bumper=True,
),
speed,
)
Expand Down Expand Up @@ -717,7 +718,7 @@ def _extract_mission(mission, road_map):
the corresponding SMARTS mission types.
"""

def resolve_offset(offset, lane_length):
def resolve_offset(offset: Union[str, float], lane_length: float):
# epsilon to ensure we are within this edge and not the subsequent one
epsilon = 1e-6
lane_length -= epsilon
Expand All @@ -730,7 +731,9 @@ def resolve_offset(offset, lane_length):
else:
return float(offset)

def to_position_and_heading(road_id, lane_index, offset, road_map):
def to_position_and_heading(
road_id: str, lane_index: int, offset: Union[str, float], road_map: RoadMap
):
road = road_map.road_by_id(road_id)
lane = road.lane_at_index(lane_index)
offset = resolve_offset(offset, lane.length)
Expand Down
3 changes: 0 additions & 3 deletions smarts/core/tests/test_trajectory_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
# THE SOFTWARE.
import importlib.resources as pkg_resources
import math
import os
import random
from pathlib import Path
from unittest import mock

import numpy as np
import pytest
Expand Down
10 changes: 9 additions & 1 deletion smarts/env/hiway_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ def scenario_log(self) -> Dict[str, Union[float, str]]:
"mission_hash": str(hash(frozenset(scenario.missions.items()))),
}

@property
def scenario(self) -> Scenario:
"""Returns underlying scenario.

Returns:
Scenario: Current simulated scenario.
"""
return self._smarts.scenario

def seed(self, seed: int) -> int:
"""Sets random number generator seed number.

Expand Down Expand Up @@ -292,4 +301,3 @@ def close(self):
"""Closes the environment and releases all resources."""
if self._smarts is not None:
self._smarts.destroy()
self._smarts = None
2 changes: 0 additions & 2 deletions smarts/env/tests/test_frame_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def env(agent_specs):
scenarios=["scenarios/sumo/figure_eight"],
agent_specs=agent_specs,
headless=True,
visdom=False,
fixed_timestep_sec=0.01,
)

yield env
Expand Down
Loading