Module examples.xodr.road_with_speed_signs
scenariogeneration https://github.com/pyoscx/scenariogeneration
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
Copyright (c) 2022 The scenariogeneration Authors.
Example how to create a more customized a junction with different widths of lanes, using generators and LaneDef with different lane widths
Some features used
-
create_road
-
Signal
Classes
class Scenario
-
Expand source code
class Scenario(ScenarioGenerator): def __init__(self): super().__init__() def road(self, **kwargs): # create a road with some strange lane sections road1 = xodr.create_road(xodr.Line(200), 1, 3, 3, lane_width=4) # create 3 poles road1.add_object( xodr.Object( s=100, t=-12, id=1, length=0.05, width=0.05, radius=0.5, height=2.3, ) ) road1.add_object( xodr.Object( s=100, t=0, id=1, length=0.05, width=0.05, radius=0.5, height=2.3, ) ) road1.add_object( xodr.Object( s=100, t=12, id=1, length=0.05, width=0.05, radius=0.5, height=2.3, ) ) # create some signs (signals) road1.add_signal( xodr.Signal( s=100, t=-12, zOffset=2.3, orientation=xodr.Orientation.positive, country="se", Type="c", subtype="31", value=10, name="right_100_sign", id=1, unit="km/h", ) ) road1.add_signal( xodr.Signal( s=100, t=0, zOffset=2.3, orientation=xodr.Orientation.positive, country="se", Type="c", subtype="31", value=10, name="right_100_sign", id=1, unit="km/h", ) ) road1.add_signal( xodr.Signal( s=100, t=0, zOffset=2.3, orientation=xodr.Orientation.negative, country="se", Type="c", subtype="31", value=9, name="right_100_sign", id=1, unit="km/h", ) ) road1.add_signal( xodr.Signal( s=100, t=12, zOffset=2.3, orientation=xodr.Orientation.negative, country="se", Type="c", subtype="31", value=9, name="right_100_sign", id=1, unit="km/h", ) ) # add everything to the OpenDRIVE object odr = xodr.OpenDrive("my adjusted road") odr.add_road(road1) # adjust roads and lanes odr.adjust_roads_and_lanes() # adjust roadmarks (comment out to see difference) odr.adjust_roadmarks() return odr
ScenarioTemplate is a class that should be inherited by a Scenario class in order to generate xodr and xosc files based on the submodules xodr and xosc
Two main uses, in your generation class define self.parameters as either as: - a dict of lists, where the lists are the values you want to sweep over, all permutations of these sets will be generated - a list of dicts, where the dicts are identical and each element in the list is one scenario
Attributes
road_file
:str
- name of the roadfile
parameters
:dict[list], list[dicts]
- parameter sets to be used
naming
:str
- two options "numerical" or "parameter"
generate_all_roads
:bool
- will only generate unique roads
number_of_parallel_writings
:int
- parallelize the writing of the xml files, default: 1
basename
:str
- basename of the scenariofiles, default: name of file
encoding
:str
- encoding of the outputs, default: utf-8
Ancestors
Inherited members