### Install scenariogeneration Source: https://github.com/pyoscx/scenariogeneration/blob/main/README.md Installs the scenariogeneration package using pip. This is the primary method to get started with the library. ```bash pip install scenariogeneration ``` -------------------------------- ### Install pdoc3 Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to install the pdoc3 package for generating documentation. ```sh pip install pdoc3 ``` -------------------------------- ### Install Build Package Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to install the 'build' package if it's not already installed. ```sh pip install build ``` -------------------------------- ### New Example for Variable Usage Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md A new example file, 'examples/xosc/variable_usage.py', has been added to demonstrate the usage of variables within the scenario generation process. ```python # New example: examples/xosc/variable_usage.py ``` -------------------------------- ### Generate Documentation Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Commands to navigate to the documentation directory and execute the documentation generation script. ```sh cd docu ./generate_documentation.sh ``` -------------------------------- ### Build Release Artifacts Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to build the source distribution and wheel for the project. ```sh python3 -m build ``` -------------------------------- ### Project Dependencies Source: https://github.com/pyoscx/scenariogeneration/blob/main/requirements-dev.txt Lists the essential Python packages required for the project, including development tools for code formatting and quality assurance. ```text black isort pytest pylint ``` -------------------------------- ### Prepare and Push Release Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Commands to stage changes, commit them with a message, and push to the remote repository. ```sh git add -u git commit -m "prep release" git push ``` -------------------------------- ### OpenDRIVE Class and Example Validation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Confirms that all OpenDRIVE (xodr) classes and examples have been validated against OpenDRIVE 1.7, with updates to links and lanes to ensure validation success. ```python # Conceptual validation process # def validate_xodr_file(filepath, schema_version='1.7'): # # Load XODR file and validate against the corresponding schema # pass # # Example of updating lane data # # lane.width = new_width # # lane.type = new_type ``` -------------------------------- ### Commit and Push Documentation Changes Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Commands to navigate to the documentation repository, stage changes, commit them, and push to the remote. ```sh cd ../pyoscx.github.io git add commit -m "Your commit message" git push ``` -------------------------------- ### Copy Generated Documentation Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Commands to copy the newly generated documentation files into the sibling repository. ```sh cp -rf generated/* ../pyoscx.github.io ``` -------------------------------- ### Upload to PyPI Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to upload the built distribution files to the Python Package Index (PyPI). ```sh twine upload dist/* ``` -------------------------------- ### Clone Documentation Repository Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to clone the sibling repository that hosts the project's GitHub Pages documentation. ```sh git clone https://github.com/pyoscx/pyoscx.github.io ``` -------------------------------- ### Push Tags Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to push all local tags to the remote repository. ```sh git push --tags ``` -------------------------------- ### Tag Release Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to create an annotated tag for the release. ```sh git tag -a "v0.15.X" -m "Version 0.15.X" ``` -------------------------------- ### Fix in pyproject.toml for Dependency Installation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md A fix has been applied to the pyproject.toml file to resolve issues with the installation of project dependencies. ```python # Fix in pyproject.toml for installation of dependencies. ``` -------------------------------- ### OpenSCENARIO Enumeration Handling Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Explains the expanded enumeration handling in OpenSCENARIO, including support for parameters (starting with '$'), string inputs matching enumeration names, and parsing of parameters. Exception types for enumerations have also been made more consistent. ```python # Example of enumeration with parameter # enum_param = Enumeration('MyEnum', ['Value1', '$ParamValue']) # Example of string input matching enumeration name # enum_str = Enumeration('MyEnum', ['Value1', 'Value2']) # enum_str.set_value('Value1') ``` -------------------------------- ### Direct Junction Creation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces the ability to create direct junctions within the scenario. Includes a new function `create_direct_junction` and updates to `add_successor`/`add_predecessor` to enable automation of direct junction connections. Examples for entry and exit are provided. ```APIDOC create_direct_junction(junction_struct) - Creates a direct junction. - Parameters: - junction_struct: The junction structure to create. add_successor(direct_junction, enable_automation) - Adds a successor to a junction, enabling automation. - Parameters: - direct_junction: The direct junction to add the successor to. - enable_automation: Boolean to enable automation. add_predecessor(direct_junction, enable_automation) - Adds a predecessor to a junction, enabling automation. - Parameters: - direct_junction: The direct junction to add the predecessor to. - enable_automation: Boolean to enable automation. ``` -------------------------------- ### OpenSCENARIO Enumeration Parameter Parsing Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Explains the capability to parse parameters (starting with '$') within OpenSCENARIO enumerations, allowing for dynamic enumeration values. ```python # Example of parsing enumeration parameter # from xosc import Enumeration # enum_def = Enumeration('TrafficLightState', ['Red', 'Yellow', 'Green', '$DefaultState']) # scenario_params = {'DefaultState': 'Green'} # parsed_value = enum_def.parse_value('$DefaultState', scenario_params) # print(parsed_value) # Output: Green ``` -------------------------------- ### OpenSCENARIO XSD Tests Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Details the addition of extensive XSD tests for each class in the xosc module and all examples, ensuring compatibility with OpenSCENARIO versions 1.0, 1.1, and 1.2. ```python # Example of how XSD tests might be structured (conceptual) # import pytest # from xosc import Scenario # from lxml import etree # def test_scenario_xsd_validation(): # scenario = Scenario() # # ... generate scenario content ... # xml_string = scenario.to_xml() # xml_tree = etree.fromstring(xml_string) # # ... load XSD and validate xml_tree against it ... # assert validation_successful ``` -------------------------------- ### ScenarioGenerator Class Updates Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Details changes to the `ScenarioGenerator` class, including updates to catalog writing, parameter declarations moved to a superclass, and new naming options for scenario generation. It also covers the encapsulation of xosc examples within the class for easier testing. ```python # Example of new naming option # scenario_generator = ScenarioGenerator(base_name='MyScenario', naming_option='parameter_no_list') # Example of encapsulated xosc examples # scenario_generator.load_example('example_scenario.xosc') ``` -------------------------------- ### Remove Build Artifacts Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/pypi_stuffs.md Command to remove old distribution files before building a new release. ```sh rm -rf dist ``` -------------------------------- ### RoadMarks with Multiple Lines Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md RoadMarks can now accommodate multiple lines, enabling the creation of double road marks. New standards for double road marks (solid-solid, solid-broken, broken-solid, broken-broken) have been added, along with examples for custom road marks. ```python # Example of creating a double road mark (conceptual): # from pyoscx.scenariogeneration import RoadMark # road_mark = RoadMark(type='solid', width=0.15) # double_road_mark = RoadMark(type='broken', width=0.15, next_road_mark=road_mark) ``` -------------------------------- ### Visualize Scenarios with esmini Source: https://github.com/pyoscx/scenariogeneration/blob/main/README.md Demonstrates how to use the esmini utility from the scenariogeneration package to visualize generated scenarios. It requires specifying the path to the esmini executable and selecting which scenario or road to run. ```python from scenariogeneration import esmini def Scenario(ScenarioGenerator): pass if __name__ == "__main__": s = Scenario() esmini(s,esminipath ='path to esmini', index_to_run = 'first') ``` -------------------------------- ### Updated Documentation for Artifacts and GitHub Pages Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Documentation has been updated to provide guidance on creating artifacts and generating documentation for the project's GitHub pages. ```python # Updated documentation for creating artifacts and generating documentation for https://github.com/pyoscx/pyoscx.github.io ``` -------------------------------- ### Lane Merge/Split Generators Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Highlights the addition of generators for easy creation of lane merges and splits, with examples provided in 'highway_example_with_merge_and_split.py'. ```python Easy creation of lane merge/splits with generators. See "highway_example_with_merge_and_split.py" ``` -------------------------------- ### Scenario Creation with License and Date Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Licenses can now be added directly during Scenario creation. The 'creation_date' can also be added to the file header as an optional input. ```python # Example usage: # from pyoscx.scenariogeneration import Scenario # scenario = Scenario(license='MIT', creation_date='2023-01-01') ``` -------------------------------- ### Switch to pyproject.toml Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The project has transitioned to using pyproject.toml for build system configuration and dependency management, aligning with modern Python packaging standards. ```python # Switch to pyproject.toml ``` -------------------------------- ### OpenSCENARIO V1.2.0 Implementation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Highlights the implementation of OpenSCENARIO V1.2.0 features, including `AnimationAction`, `LightStateAction`, `SpeedProfileAction`, `RelativeClearanceCondition`, `VariableActions`, and more. It notes the replacement of `FollowMode` with `FollowingMode` and the update of `osc_minor_version` to 1.2. ```python # Example of setting osc_minor_version # from xosc import Scenario # scenario = Scenario(osc_minor_version='1.2') # Example of VariableAction # from xosc import VariableAction # var_action = VariableAction(variable_name='my_var', value='10', type='int') # scenario.add_event(event_name='my_event', action=var_action) ``` -------------------------------- ### OpenSCENARIO V1.2.0 Features Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Lists several key features implemented for OpenSCENARIO V1.2.0, including `AnimationAction`, `LightStateAction`, `SpeedProfileAction`, `RelativeClearanceCondition`, and `VariableActions`. It also notes changes like `FollowingMode` replacing `FollowMode`. ```python # Example of AnimationAction # from xosc import AnimationAction, AnimationFile # anim_action = AnimationAction(animation_file=AnimationFile(filepath='path/to/animation.anim')) # Example of LightStateAction # from xosc import LightStateAction, LightState # light_action = LightStateAction(state=LightState.HEADLIGHT_ON, light_type='mainBeam') ``` -------------------------------- ### CatalogLoader Implementation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces a new `CatalogLoader` that allows loading a catalog and reading from it multiple times without reloading the file. The old `CatalogReader` will be removed in future releases. ```APIDOC CatalogLoader - Loads a catalog file and allows reading from it multiple times without reloading. - Methods: - load(catalog_file): Loads the catalog file. - read(): Reads data from the loaded catalog. ``` -------------------------------- ### Xosc Enum Access with __getitem__ Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Xosc enums now support the __getitem__ method, allowing for direct access to enum members. For example, Followmode['position'] can now be used. ```python # Example usage: # from pyoscx.xosc.enums import Followmode # position_value = Followmode['position'] ``` -------------------------------- ### ScenarioGenerator Usage Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Illustrates how to use the ScenarioGenerator class to parametrize and generate OpenSCENARIO and OpenDRIVE XMLs. It covers parameterization using dictionaries or lists of dictionaries and implementing road and scenario generation methods. ```python # Inherit from ScenarioGenerator # class MyScenario(ScenarioGenerator): # def __init__(self): # super().__init__() # self.parameters = { # 'param1': [1, 2, 3], # 'param2': ['A', 'B'] # } # # Or use a list of dicts: # # self.parameters = [ # # {'param1': 1, 'param2': 'A'}, # # {'param1': 2, 'param2': 'B'} # # ] # # def road(self): # # Return an xodr.OpenDrive object # pass # # def scenario(self): # # Return an xosc.Scenario object # # road_network = xosc.RoadNetwork(self.road_file) # pass # # # To generate scenarios: # generator = MyScenario() # generator.generate() ``` -------------------------------- ### OpenSCENARIO V1.2.0 Features Overview Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Provides an overview of key features implemented for OpenSCENARIO V1. -------------------------------- ### Project Dependencies Source: https://github.com/pyoscx/scenariogeneration/blob/main/requirements.txt Lists the core Python libraries required for the scenario generation project. This includes libraries for numerical computation, geometric curve generation, and XML parsing. ```python numpy scipy pyclothoids xmlschema>=3.3.1,<=3.4.5 lxml ``` -------------------------------- ### ScenarioGenerator Attributes Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Explains useful attributes that can be set in the ScenarioGenerator's init method to control the generation process, such as generating all roads or customizing naming conventions. ```APIDOC ScenarioGenerator Attributes: - generate_all_road: (boolean) If true, generates one road per scenario. If false, only unique roads are created. - naming: (string) Determines the naming convention for generated XML files. - 'numerical': Scenarios are named with an increasing index. - 'parameter': Filenames include parameters and their values (can lead to long names). - 'parameter_no_lists': Filenames include parameters and their values, but list values are replaced with an integer index. - number_of_parallel_writings: (integer) Specifies the number of parallel processes to use for writing XML files. ``` -------------------------------- ### ParameterCondition Handling Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Addresses a bug fix for `ParameterCondition` to ensure it correctly handles all possible values. ```python # Example of ParameterCondition (assuming 'parameter' and 'value' are defined) # from xosc import ParameterCondition # param_condition = ParameterCondition(parameter='some_parameter', value='some_value', rule='equal_to') ``` -------------------------------- ### esmini Helper Updates Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The esmini helper now creates its own folder and does not generate scenarios in the esmini folder. Two additional inputs have been added to set the generation folder and a resource path for esmini. ```APIDOC esmini_helper.set_generation_folder(folder_path) - Sets the folder where scenarios are generated. - Parameters: - folder_path: The path to the generation folder. esmini_helper.set_resource_path(resource_path) - Sets the resource path for esmini. - Parameters: - resource_path: The path to the esmini resources. ``` -------------------------------- ### Direct Junction Creation Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Demonstrates how to create a direct junction using DirectJunctionCreator. It shows adding successor and predecessor roads and then connecting them using add_connection, optionally specifying lanes. ```python from scenariogeneration import xodr junction_id = 100 direct_junction = xodr.DirectJunctionCreator(junction_id,'my_direct_junction') first_road = xodr.create_road([xodr.Line(300)], id= 1, left_lanes=3, right_lanes=4) continuation_road = xodr.create_road([xodr.Line(300)], id= 2, left_lanes=3, right_lanes=3) off_ramp = xodr.create_road([xodr.Spiral(-0.00001,-0.02,length=150)], id= 3, left_lanes=0, right_lanes=1) first_road.add_successor(xodr.ElementType.junction, junction_id) continuation_road.add_predecessor(xodr.ElementType.junction, junction_id) off_ramp.add_predecessor(xodr.ElementType.junction, junction_id) direct_junction.add_connection( incoming_road = first_road, linked_road = continuation_road) direct_junction.add_connection( incoming_road = first_road, linked_road = off_ramp, incoming_lane_id=-4, linked_lane_id = -1) odr = xodr.OpenDrive('myroad') odr.add_road(first_road) odr.add_road(continuation_road) odr.add_road(off_ramp) odr.add_junction_creator(direct_junction) odr.adjust_roads_and_lanes() ``` -------------------------------- ### OpenSCENARIO UserDefinedAction Implementation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Confirms the correct implementation of `UserDefinedAction` in OpenSCENARIO, ensuring custom actions are handled properly. ```python # Example of UserDefinedAction # from xosc import UserDefinedAction, Action # custom_action = UserDefinedAction(name='MyCustomAction', namespace='com.example') # action_wrapper = Action(user_defined_action=custom_action) ``` -------------------------------- ### OpenSCENARIO VariableActions and Conditions Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Replaces `ParameterActions` and `ParameterConditions` with the more comprehensive `VariableActions` and `VariableConditions` in OpenSCENARIO, aligning with newer specifications. ```python # Example of VariableAction # from xosc import VariableAction # var_action = VariableAction(variable_name='speed', value='60', type='double', operation='equals') # Example of VariableCondition # from xosc import VariableCondition # var_condition = VariableCondition(variable_name='distance', value='100', rule='less_than') ``` -------------------------------- ### ParameterReader for ParameterDeclarations Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces the ParameterReader, a new utility similar to CatalogReader, designed to read parameter declarations for scenarios and translate them into xosc objects. ```python ParameterReader (similar to catalog reader but for parameterdeclaration of the scenario) ``` -------------------------------- ### Scenario Generation with Prettyprint Option Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces the 'prettyprint' option for scenario generation functions. Setting 'prettyprint' to false can significantly speed up the generation of large batches of scenarios. ```python from pyoscx.scenariogeneration import ScenarioGenerator # Example: Generating scenarios with prettyprint disabled for speed # generator = ScenarioGenerator() # scenarios = generator.generate(num_scenarios=10000, prettyprint=False) ``` -------------------------------- ### __eq__ Method Implementation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Details the implementation of the __eq__ method across all classes to facilitate comparisons, with noted limitations in the xodr module due to generated IDs. This feature aids in generating unique roads. ```python added __eq__ to all classes, (some limitations in the xodr module where the ids are generated) ``` -------------------------------- ### Esmini Paths Support for Spaces Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The esmini paths now support spaces, allowing for more flexible path definitions that may include spaces in directory or file names. ```python # support space in esmini paths ``` -------------------------------- ### Version Handling for ActivateControllerAction Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Version handling during the parsing of ActivateControllerAction has been fixed, ensuring correct interpretation of controller activation actions. ```python # Version handling while parsing ActivateControllerAction ``` -------------------------------- ### Weather Class Initialization Changes Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Illustrates the updated initialization for the Weather class, making all inputs optional and introducing new classes for subelements like Fog, Sun, Precipitation, and Wind to support OpenSCENARIO V1.1.0. This change enhances flexibility in defining weather conditions. ```python previous init: __init__(self,cloudstate,sun_intensity,sun_azimuth,sun_elevation,precipitation,precipitation_intensity,visual_fog_range = 100000,fog_bounding_box = None) new init: __init__(self,cloudstate=None,atmosphericPressure=None,temperature=None,sun=None,fog=None,precipitation=None,wind=None) ``` -------------------------------- ### New Black Formatting Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The project now utilizes Black for code formatting, ensuring consistent and PEP 8 compliant code style across the codebase. ```python # New Black formatting ``` -------------------------------- ### OpenSCENARIO Pretty Print Optimization Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Implements an optimization for more efficient 'pretty print' functionality when writing XML files in OpenSCENARIO, improving performance for large files. ```python # Example of pretty printing XML output # from xosc import Scenario # scenario = Scenario() # # ... generate scenario ... # xml_output = scenario.to_xml(pretty_print=True) # print(xml_output) ``` -------------------------------- ### Parsing Trajectory Parameters Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The project now includes the capability to parse trajectory parameters, enabling more detailed control and definition of object trajectories. ```python # Add parsing of trajectory parameters ``` -------------------------------- ### AdjustablePlanview for Complex Geometries Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Introduces the `AdjustablePlanview` feature, designed to assist in creating road geometries that form loops or require precise connections, particularly when spirals are involved. It facilitates the creation of smooth road transitions between existing road segments. ```python # AdjustablePlanview is used for complex geometries, especially loops with spirals. # It helps create smooth road connections between existing road segments. # Requires the junction to be a predecessor of the road with AdjustablePlanview. ``` -------------------------------- ### xosc Module Overview Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md The xosc module handles OpenSCENARIO V1.0.0, V1.1.0, and V1.2.0. It acts as an XML file generator, simplifying the creation of OpenSCENARIO hierarchies by abstracting away unnecessary XML levels. Some XML elements are compressed into higher-level classes for user convenience. ```APIDOC OpenSCENARIO Module (xosc): Purpose: Generate OpenSCENARIO XML files. Versions Supported: V1.0.0, V1.1.0, V1.2.0. Key Features: - XML hierarchy generation with abstraction of low-level XML elements. - Simplified creation of Story, Act, and ManeuverGroup. - Support for specifying OpenSCENARIO minor version for output. - Parsing of existing .xosc files into Python objects. Dependencies: None explicitly mentioned for core functionality. Limitations: Some interfaces may change with new standard versions; refer to release notes. Example Usage: - Creating a scenario: `sce = Scenario()` - Adding elements: `sce.add_story(...)`, `sce.add_act(...)` - Parsing a file: `scenario = ParseOpenScenario('path/to/file.xosc')` ``` -------------------------------- ### Esmini Runner Replayer Window Size Handling Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The handling of the replayer window size in the esmini runner has been fixed, improving its usability and display. ```python # fix esmini runner replayer window size handling ``` -------------------------------- ### Support for geo_reference Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The project now includes support for 'geo_reference', likely for handling geographical referencing information within scenarios. ```python # support for geo_reference added. ``` -------------------------------- ### OpenSCENARIO Multiple Controllers and Roles Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Enables the addition of multiple controllers to entities and introduces the concept of 'Roles' in OpenSCENARIO, allowing for more complex entity management and behavior definition. ```python # Example of assigning multiple controllers to an entity # from xosc import Entity, Controller # entity = Entity(name='Car1', controller_id='controller_1') # entity.add_controller(Controller(id='controller_2', name='AdaptiveCruiseControl')) # Example of defining a Role # from xosc import Role # ego_role = Role(name='EgoVehicle', value='ego') ``` -------------------------------- ### Automatic Story, Act, and ManeuverGroup Generation Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Demonstrates how the xosc module simplifies scenario creation by automatically generating top-level layers like Story, Act, and ManeuverGroup when adding sub-classes. This is useful for simple scenarios where these layers are not explicitly needed. Warning: Avoid using more than one of these calls (except add_story) as each will create a new story. ```python from scenariogeneration.xosc.xosc_generator import Scenario # Example usage (conceptual): # sce = Scenario() # sce.add_maneuvergroup(maneuver_group) # This will automatically create the necessary Story and Act layers if they don't exist. ``` -------------------------------- ### Parse .xosc File to Python Object Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Illustrates how to parse an existing OpenSCENARIO (.xosc) file into its corresponding Python object representation using the ParseOpenScenario function. This allows for modification of existing scenario files. The function can handle Scenario, Catalog, and ParameterValueDistribution files. ```python from scenariogeneration.xosc.parser import ParseOpenScenario # scenario = ParseOpenScenario('my_non_python_made_scenario.xosc') ``` -------------------------------- ### NumPy Documentation Standard for Docstrings Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Docstrings within the project have been updated to conform to the NumPy documentation standard, improving consistency and readability of code documentation. ```python # Docstrings updated to NumPy standard. # Example: # def my_function(param1, param2): # """Summary of function. # # Parameters # ---------- # param1 : int # Description of param1. # param2 : str # Description of param2. # # Returns # ------- # bool # Description of return value. # """ # pass ``` -------------------------------- ### OpenDRIVE ParkingSpace and SignalReference Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces new object types for OpenDRIVE (xodr), including `ParkingSpace` and `SignalReference`, enhancing the representation of road elements. ```python # Example of ParkingSpace # from xodr import ParkingSpace, RoadObject # parking_space = ParkingSpace(id=1, name='P1') # road_object = RoadObject(id=10, name='ParkingArea', type='parking', parking_space=parking_space) # Example of SignalReference # from xosc import SignalReference, TrafficSignalController # signal_ref = SignalReference(ref_id='traffic_light_1') # controller = TrafficSignalController(id=1, name='MainController', signal_references=[signal_ref]) ``` -------------------------------- ### Length Parameter for Signal Objects Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Signal objects now support a 'Length' parameter, providing more detailed configuration options for signals. ```python # Length parameter for signal objects. ``` -------------------------------- ### Direct Junction Creation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces new Junction creators, replacing the old junction functionality. Common and Direct junction creators are now available. The old way of creating direct junctions was buggy and less reliable. ```python # Example of using the new DirectJunctionCreator (conceptual): # from pyoscx.scenariogeneration import DirectJunctionCreator # junction_creator = DirectJunctionCreator() # junction_creator.create(...) ``` -------------------------------- ### RelativeLanePosition Class Initialization Changes Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Details the changes in the initialization signature for the RelativeLanePosition class to accommodate new optional inputs and handle OpenSCENARIO V1.1.0 specifications. The order of parameters has been updated, and 'ds' is now optional. ```python previous init: __init__(self,s,offset,lane_id,entity,orientation=Orientation()): new init: __init__(self,lane_id,entity,offset=0,ds=None,dsLane=None,orientation=Orientation()) ``` -------------------------------- ### Convert OpenSCENARIO Version Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Demonstrates how to parse an OpenSCENARIO file and convert it to an older version using the xosc module. This is useful when a simulator requires a specific OpenSCENARIO version. ```python from scenariogeneration import xosc scenario = xosc.ParseOpenScenario("multiple_maneuvers_1.xosc") scenario.header.setVersion(minor=0) scenario.write_xml("multiple_maneuvers_0.xosc") ``` -------------------------------- ### Esmini Runner Headless Mode Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The esmini runner now supports running in headless mode, which means without the replay visualization. This is controlled by the 'headless' input key. ```python # Example usage (conceptual): # esmini_runner.run(scenario_file='path/to/scenario.xosc', headless=True) ``` -------------------------------- ### ScenarioGenerator Naming Options Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces new naming options for the `ScenarioGenerator` class, including a base name that can be changed and a 'parameter_no_list' option for integer increments in lists. ```python # Example of using naming options # from xosc import ScenarioGenerator # generator = ScenarioGenerator(base_name='MyScenario', naming_option='parameter_no_list') # scenario_name = generator.generate_scenario_name(index=5) # print(scenario_name) # Output: MyScenario_5 ``` -------------------------------- ### LongitudinalDistanceAction Parameters Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The LongitudinalDistanceAction now correctly accepts 'accelerationRate' and 'decelerationRate' as inputs, ensuring proper configuration of longitudinal control actions. ```python # class LongitudinalDistanceAction: # def __init__(self, accelerationRate: float, decelerationRate: float): # self.accelerationRate = accelerationRate # self.decelerationRate = decelerationRate ``` -------------------------------- ### Encoding in xosc_reader Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The 'xosc_reader' now includes encoding support, ensuring correct handling of files with different character encodings. ```python # add encoding in xosc_reader ``` -------------------------------- ### CatalogReader for xosc Module Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Introduces the CatalogReader function within the xosc module, capable of reading catalogs and translating them into xosc objects, with initial support for Vehicle and Pedestrian. ```python CatalogReader - new function in the xosc module, which can read a catalog and translate to a xosc object (works for Vehicle and Pedestrian in the first implementation) ``` -------------------------------- ### Creating and Connecting Roads in a Junction (Cartesian) Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Demonstrates how to use CommonJunctionCreator to add roads to a junction using Cartesian geometry and establish connections between them. It covers adding roads with specified positions and headings, and then creating connections with default or specific lane mappings. ```python from scenariogeneration import xodr road1 = xodr.create_road(xodr.Line(100), id=1, left_lanes=2, right_lanes=2) road2 = xodr.create_road(xodr.Line(100), id=2, left_lanes=1, right_lanes=1) road3 = xodr.create_road(xodr.Line(100), id=3, left_lanes=2, right_lanes=2) junction_creator = xodr.CommonJunctionCreator(id = 100, name='my_junction') junction_creator.add_incoming_road_cartesian_geometry(road1, x = 0, y = 0, heading=0, road_connection='successor') junction_creator.add_incoming_road_cartesian_geometry(road2, x = 50, y = 50, heading=3.1415*3/2, road_connection='predecessor') junction_creator.add_incoming_road_cartesian_geometry(road3, x = 100, y = 0, heading=-3.1415, road_connection='predecessor') junction_creator.add_connection(road_one_id = 1, road_two_id = 3) junction_creator.add_connection(road_one_id = 1, road_two_id = 2, lane_one_id = 2, lane_two_id = 1) junction_creator.add_connection(road_one_id = 2, road_two_id = 3, lane_one_id = -1, lane_two_id = 2) odr = xodr.OpenDrive('myroad') odr.add_road(road1) odr.add_road(road2) odr.add_road(road3) odr.add_junction_creator(junction_creator) odr.adjust_roads_and_lanes() ``` -------------------------------- ### Typehinting Implementation Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Typehinting has been implemented throughout the project, improving code clarity, maintainability, and enabling static analysis tools to catch type errors. ```python # Typehinting ``` -------------------------------- ### Parser ParameterDeclarations in Environment Class Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md A bug related to parsing ParameterDeclarations within the Environment class has been fixed, ensuring accurate parsing of environment parameters. ```python # Parser ParameterDeclarations in class Environment ``` -------------------------------- ### OpenDRIVE Road Network Generation Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Explains the functionality of the xodr module for generating OpenDRIVE road networks. It emphasizes the use of automation algorithms to handle the complexity of the OpenDRIVE standard, including geometrical dependencies and lane linking. ```python # The xodr module handles OpenDRIVE road network generation. # It includes automation algorithms for creating complex road hierarchies. # Example usage involves patching geometries and creating lane links. # Refer to the documentation for specific examples and coverage details. ``` -------------------------------- ### OpenSCENARIO Encoding for XML Writing Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Addresses a bug fix related to encoding, ensuring that XML files can be written with more options and correctly handle various encodings. ```python # Example of specifying encoding when writing XML # from xosc import Scenario # scenario = Scenario() # # ... generate scenario ... # xml_output = scenario.to_xml(encoding='utf-8') # with open('scenario.xosc', 'w', encoding='utf-8') as f: # f.write(xml_output) ``` -------------------------------- ### OpenSCENARIO Road Linkage and Lane Widths Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Adds features for road linkage with different lane widths and allows `LaneDef` to generate lanes with individual widths in OpenSCENARIO. ```python # Example of LaneDef with individual width # from xodr import LaneDef, LaneSection # lane_section = LaneSection(idx=0) # lane_def_left = LaneDef(id=-1, width=3.5) # lane_def_right = LaneDef(id=1, width=4.0) # lane_section.add_lane_def(lane_def_left) # lane_section.add_lane_def(lane_def_right) ``` -------------------------------- ### OpenDRIVE UserData and Lane Widths Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Details new features in OpenDRIVE (xodr) handling, including `UserData` implementation, road linkage with different lane widths, and the ability for `LaneDef` to generate lanes with individual widths. ```python # Example of LaneDef with individual width # from xodr import LaneDef, LaneSection # lane_section = LaneSection(idx=0) # lane_def_left = LaneDef(id=-1, width=3.5) # lane_def_right = LaneDef(id=1, width=4.0) # lane_section.add_lane_def(lane_def_left) # lane_section.add_lane_def(lane_def_right) # Example of UserData # from xodr import UserData # user_data = UserData(name='custom_data', value='some_value') ``` -------------------------------- ### Boolean Parsing from '0' and '1' Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Boolean values can now be parsed from the string representations '0' and '1'. ```python # Example of parsing a boolean from a string: # value = parse_boolean('1') # Returns True # value = parse_boolean('0') # Returns False ``` -------------------------------- ### Fix Argument Composition Issues in Esmini Runner Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Issues with argument composition in the esmini runner have been resolved, ensuring that arguments are correctly passed and processed. ```python # fix argument composition issues in esmini runner ``` -------------------------------- ### Test Matrix for Python Versions in GitHub Workflows Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md A test matrix for various Python versions has been added to the GitHub workflows, ensuring continuous integration and testing across supported Python environments. ```python # Added test matrix for python versions in github workflows ``` -------------------------------- ### OpenSCENARIO OverrideControllerValueAction Inputs Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Adds more input options to `OverrideControllerValueAction` in OpenSCENARIO, providing greater flexibility in controlling vehicle behavior. ```python # Example of OverrideControllerValueAction # from xosc import OverrideControllerValueAction, ControllerValue # override_action = OverrideControllerValueAction(entity_ref='ego', value='0.5', type='throttle') # controller_value = ControllerValue(type='brake', value='0.2') ``` -------------------------------- ### More Tests for Roadmark Adjustment Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Additional tests have been incorporated to specifically cover the roadmark adjustment functionality, ensuring its reliability. ```python # More tests for roadmark adjustment. ``` -------------------------------- ### SynchronizeAction Class Changes Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md The `AbosoluteSyncronizeAction` and `RelativeSyncronizeAction` classes have been removed and replaced with `SyncronizeAction` that handles both absolute and relative synchronization. New classes related to `SyncronizeAction` have been added: `AbsoluteSpeed`, `RelativeSpeedToMaster`, `TargetDistanceSteadyState`, and `TargetTimeSteadyState`. ```APIDOC SyncronizeAction - Replaces `AbosoluteSyncronizeAction` and `RelativeSyncronizeAction` to handle both absolute and relative synchronization. AbsoluteSpeed - New class related to `SyncronizeAction`. RelativeSpeedToMaster - New class related to `SyncronizeAction`. TargetDistanceSteadyState - New class related to `SyncronizeAction`. TargetTimeSteadyState - New class related to `SyncronizeAction`. ``` -------------------------------- ### LaneOffset Support Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Notes the addition of support for laneOffset within the Lanes class, enhancing the precision of lane definitions. ```python Added support for laneOffset for Lanes ``` -------------------------------- ### Consolidation of Override Controller Actions Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Describes the restructuring effort where all override controller actions (e.g., OverrideThrottleAction) have been merged into a single class, and the older, separate classes have been removed. ```python All override controller actions (OverrideThrottleAction, OverrideBrakeAction, ...) are merged into one class, and the old ones are removed. ``` -------------------------------- ### OpenDRIVE 1.5 Element Coverage Source: https://github.com/pyoscx/scenariogeneration/blob/main/xodr_coverage.txt This section details the coverage of OpenDRIVE 1.5 elements within the scenariogeneration project. 'YES' signifies that the element is covered, while 'NO' indicates it is not. ```APIDOC OpenDRIVE: - header: YES - geoReference: YES - offset: NO - road: YES - link: YES - predecessor: YES - successor: YES - neighbor: YES - type: YES - speed: YES - planView: YES - geometry: YES - line: YES - spiral: YES - arc: YES - poly3: YES - paramPoly3: YES - elevationProfile: YES - elevation: YES - lateralProfile: YES - superelevation: YES - crossfall: NO - shape: YES - lanes: YES - laneOffset: YES - laneSection: YES - left: YES - lane: YES - link: YES - predecessor: YES - successor: YES - width: YES - border: NO - roadMark: YES - sway: NO - type: YES - line: YES - explicit: YES - line: YES - material: YES - visibility: NO - speed: NO - access: NO - height: YES - rule: NO - center: YES - lane: YES - link: YES - predecessor: YES - successor: YES - roadMark: YES - sway: NO - type: YES - line: YES - explicit: YES - line: YES - right: YES - lane: YES - link: YES - predecessor: YES - successor: YES - width: YES - border: NO - roadMark: YES - sway: NO - type: YES - line: YES - explicit: YES - line: YES - material: NO - visibility: NO - speed: NO - access: NO - height: YES - rule: NO - objects: YES - object: YES - repeat: YES - outlines: YES - outline: YES - cornerRoad: YES - cornerLocal: YES - material: NO - validity: YES - parkingSpace: YES - markings: NO - marking: NO - cornerReference: NO - borders: NO - border: NO - cornerReference: NO - objectReference: NO - validity: NO - tunnel: YES - validity: YES - bridge: NO - validity: NO - signals: YES - signal: YES - validity: YES - dependency: NO - reference: NO - positionRoad: NO - positionInertial: NO - signalReference: YES - validity: YES - surface: NO - CRG: NO - railroad: NO - switch: NO - mainTrack: NO - sideTrack: NO - partner: NO - controller: NO - control: NO - junction: YES - connection: YES - predecessor: YES - successor: YES - laneLink: YES - priority: NO - controller: NO - surface: NO - CRG: NO ``` -------------------------------- ### Automatic Geometry and Lane Linking Source: https://github.com/pyoscx/scenariogeneration/blob/main/docu/Documentation.md Details the `adjust_roads_and_lanes` method in the OpenDRIVE class, which automates the process of patching geometries and creating lane links between roads. This method simplifies the creation of continuous road networks and handles lane connections, even with varying lane counts. ```python # The adjust_roads_and_lanes method patches geometries and creates lane links. # It operates on both RoadNetwork and PlanView levels. # Assumes continuous heading between geometries. # Handles different lane counts in connecting roads, especially in junctions. # Note: No extensive sanity checks are performed; input quality is crucial. ``` -------------------------------- ### General Linting Fixes Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md Various general linting fixes have been applied across the codebase to improve code quality and adhere to style guidelines. ```python # General linting fixes ``` -------------------------------- ### Adjustable Planview Feature Source: https://github.com/pyoscx/scenariogeneration/blob/main/release_notes.md A new 'Adjustable planview' feature has been introduced, allowing the geometry to fit between one predecessor and one successor road. ```python # Adjustable planview: can fit geometry between one predecessor and one successor road. ```