Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1cd2aa6
Work on OpenScenarioXML Export.
Eric-Vin Nov 17, 2025
8c056c2
Initial OpenScenarioXML export implementation.
Eric-Vin Nov 18, 2025
048d3f0
Tidying up
Eric-Vin Nov 19, 2025
6ff049a
Fixed coordinate system
Eric-Vin Nov 25, 2025
0b45e3d
Updated dependencies and fixed wheelbase offset
Eric-Vin Nov 25, 2025
8ecd602
Added pedestrians to OpenScenarioXML export
Eric-Vin Dec 16, 2025
8685fac
Merge branch 'main' into OpenScenarioXML
Eric-Vin May 28, 2026
5e2b7e3
XOSC export improvements, fixes, and test.
Eric-Vin May 29, 2026
743cf43
Fixed metadrive import?
Eric-Vin May 29, 2026
992be25
Tweaked Metadrive real_time default.
Eric-Vin May 29, 2026
15c729a
Added documentation
Eric-Vin May 29, 2026
ab311ca
Minor fixes.
Eric-Vin May 29, 2026
54a2a5e
Fixed blank line
Eric-Vin May 29, 2026
25fe1a1
Another blank line?
Eric-Vin May 29, 2026
518c308
Fix scenariogeneration link
Eric-Vin May 29, 2026
96b3ee1
Fixed link
Eric-Vin May 29, 2026
f9557b5
Added support for parallel behaviors.
Eric-Vin May 30, 2026
2c1551d
Naming tweak.
Eric-Vin May 30, 2026
28f7c77
Small fix.
Eric-Vin May 30, 2026
2e62dc8
Consolidate PID controller code
Eric-Vin May 30, 2026
04003e1
Initial pure pursuit implementation and reorginization.
Eric-Vin Jun 1, 2026
6d802b2
Progress on controllers
Eric-Vin Jun 22, 2026
b163047
Added fix for lane order in backwards LaneGroups.
Eric-Vin Jul 6, 2026
4d6abc2
Additional controller tweaks.
Eric-Vin Jul 6, 2026
cdfef5b
Added followFromTrajectory method.
Eric-Vin Jul 6, 2026
9b5243e
Fix docs building.
Eric-Vin Jul 6, 2026
5924262
Added setOrientation functionality to driving domain
Eric-Vin Jul 6, 2026
ebc20b1
Added python floor to pairwise test.
Eric-Vin Jul 6, 2026
2887b04
Prepare for `apparent heading to` syntax.
Eric-Vin Jul 6, 2026
6c89a4a
Added `apparent heading to X from Y` operator.
Eric-Vin Jul 7, 2026
d2cd9e3
Added documentation.
Eric-Vin Jul 7, 2026
7bc9cbc
Added logic for dynamically rebuilding parser on changes.
Eric-Vin Jul 7, 2026
0e8e936
followFrom and followFromTrajectory now attempt to coerce pos to a ve…
Eric-Vin Jul 8, 2026
b9b1570
Added centerlines field to networks
Eric-Vin Jul 8, 2026
513299c
Renamed centerlineRegion
Eric-Vin Jul 8, 2026
502ebab
Added tests for imported record, require monitor, and terminate state…
Eric-Vin Jul 9, 2026
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ dmypy.json

*.cproject

# generated parser
# generated parser and checksum
src/scenic/syntax/parser.py
src/scenic/syntax/.parser_checksum

# generated media/output
simulation.gif
Expand Down
9 changes: 9 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ it to the replay, but this greatly increases the size of the encoded simulation.
can return to one later for further analysis), but it is not guaranteed to be
compatible across major versions of Scenic.

.. _xosc_export:

OpenScenarioXML Export
----------------------

Scenic provides experimental support for exporting completed simulations via `toOpenScenario`.
This function currently only supports cars and pedestrians, and may be subject to breaking changes
in the future.

.. seealso:: If you get exceptions or unexpected behavior when using the API, Scenic provides various debugging features: see :ref:`debugging`.

.. rubric:: Footnotes
Expand Down
15 changes: 15 additions & 0 deletions docs/reference/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ apparent heading of *OrientedPoint* [from *vector*]
---------------------------------------------------
The apparent heading of the OrientedPoint, with respect to the line of sight from ego (or the position provided with the optional from vector)

.. _apparent heading to {vector} [from {OrientedPoint}]:

apparent heading to *vector* [from *OrientedPoint*]
---------------------------------------------------
The apparent heading to the vector, with respect to the line of sight from ego (or the OrientedPoint provided with the optional from OrientedPoint)

.. _distance [from {vector}] to {vector}:
.. _distance from:

Expand Down Expand Up @@ -75,6 +81,15 @@ Whether an `Object`/`Region` intersects another `Object`/`Region`, i.e. whether

When working with 2D regions, it can be useful to check intersection with the :term:`footprint` of a region, e.g. when checking whether a car intersects a given lane. In this case, one would write :scenic:`car intersects lane.footprint` instead of :scenic:`car intersects lane`. For more details, see :term:`footprint`.

.. _{vector} (ahead of | behind | left of | right of) {region}:

*vector* (ahead of | behind | left of | right of) *OrientedPoint*
-----------------------------------------------------------------
Whether a vector is to a respective side of an `OrientedPoint` (i.e. within +- ~90 degrees from that direction), accounting for the heading of the `OrientedPoint`. These operators are convenient shorthand for comparing :sampref:`apparent heading to {vector} [from {OrientedPoint}]` to a range of values.

Note: For vectors very close to a boundary point (i.e. an apparent heading to the vector in (89.99, 90.01) or (-89.99, -90.01) for "ahead of" and "behind"), both operators will resolve to False.

Example: If an `OrientedPoint` had an apparent heading to a vector of 45 degrees, it would be both "ahead of" and "left of" the `OrientedPoint` but not "behind" or "right of".

Orientation Operators
=====================
Expand Down
5 changes: 4 additions & 1 deletion docs/simulators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ See the individual entries for details on each interface's capabilities and how
While Scenic aims to support multiple Python versions, some simulators may have more limited compatibility.
Be sure to check the documentation of each simulator to confirm which Python versions are supported.

.. note::
Scenic also supports outputing data in formats that may be imported into other simulators and tools (e.g. :ref:`xosc_export`).
For more details, see :ref:`serialization`.

.. contents:: List of Simulators
:local:

Expand Down Expand Up @@ -163,7 +167,6 @@ This interface is part of the VerifAI toolkit; documentation and examples can be

.. _VerifAI repository: https://github.com/BerkeleyLearnVerify/VerifAI


Deprecated
==========

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ metadrive = [
"metadrive-simulator >= 0.4.3",
"sumolib >= 1.21.0",
]
openscenario = [
"scenariogeneration"
]
test = [ # minimum dependencies for running tests (used for tox virtualenvs)
"pytest >= 7.0.0",
"pytest-cov >= 3.0.0",
Expand All @@ -68,6 +71,7 @@ test = [ # minimum dependencies for running tests (used for tox virtualenvs)
test-full = [ # like 'test' but adds dependencies for optional features
"scenic[test]", # all dependencies from 'test' extra above
"scenic[guideways]", # for running guideways modules
"scenic[openscenario]",
"astor >= 0.8.1",
'carla >= 0.9.12; python_version <= "3.12" and (platform_system == "Linux" or platform_system == "Windows")',
"dill",
Expand Down
37 changes: 29 additions & 8 deletions src/scenic/core/dynamics/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def alarmHandler(signum, frame):
try:
actions = self._runningIterator.send(None)
except StopIteration:
actions = () # behavior ended early
return None
return actions

def _stop(self, reason=None):
Expand All @@ -124,18 +124,39 @@ def _isFinished(self):
def _invokeInner(self, agent, subs):
import scenic.syntax.veneer as veneer

assert len(subs) == 1
sub = subs[0]
if not isinstance(sub, Behavior):
raise TypeError(f"expected a behavior, got {sub}")
sub._start(agent)
with veneer.executeInBehavior(sub):
# Validate all inner behaviors
for sub in subs:
if not isinstance(sub, Behavior):
raise TypeError(f"expected a behavior, got {sub}")
sub._start(agent)

# Create a generator for each inner behavior that yields the appropriate actions, cleaning up when done.
def make_inner_generator(sub):
try:
yield from sub._runningIterator
while sub._isRunning:
actions = sub._step()
if actions is None:
return
yield actions
finally:
if sub._isRunning:
sub._stop()

inner_generators = [make_inner_generator(sub) for sub in subs]

# Yield from a generator that zips all the inner generators together without padding, until all inner generators have terminated.
while True:
try:
raw_actions_list = next(itertools.zip_longest(*inner_generators))
yield tuple(
filter(
lambda x: x is not None,
itertools.chain.from_iterable(raw_actions_list),
)
)
except StopIteration:
return

def __repr__(self):
items = itertools.chain(
(repr(arg) for arg in self._args),
Expand Down
4 changes: 4 additions & 0 deletions src/scenic/core/object_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,10 @@ def distancePast(self, vec):
diff = self.position - vec
return diff.rotatedBy(-self.heading).y

def apparentHeadingTo(self, vec):
"""The apparent heading to a given point, from the perspective of this `OrientedPoint`."""
return normalizeAngle(self.position.angleTo(vec) - self.heading)

def toHeading(self) -> float:
return self.heading

Expand Down
Loading
Loading