2 Parameters
In ASAM OpenSCENARIO 1.2.0, scenario parameters are an important language feature. ASAM OpenSCENARIO parameter declaration states that the particular value is expected to be set from outside of the scenario.
Parameter assignment binds the scenario object field to the parameter defined above. Parameter declaration provides the default value for the parameter in case that the parameter variation mechanism is not used.
ASAM OpenSCENARIO 1.2.0 expands on this concept and provides a mechanism to define distributions to further describe how the parameter or the parameter set is to be varied.
In ASAM OpenSCENARIO 2.0.0, all of the scenario and object fields are by default considered to be varied. Variation is subject to constraints (defined within the scenario), and limits that are implied by the simulation environment. In this section, a technique to mimic the more explicit ASAM OpenSCENARIO 1.2.0 parameter mechanism is presented. Scenario parameters are mapped to the fields of the top-level scenario.
2.1 Parameter conversion mechanism
Local parameters can be declared within the definition of these elements:
-
entity
-
maneuver
-
controller
-
environment
-
trajectory
-
route
They are usually declared in the catalog. This local declaration then allows to set of the concrete parameter’s values in a place where a concrete entity is created from the catalog reference.
In this case, a very similar mechanism as with scenario parameters is used.
Both scenario level parameters and local parameters are mapped with these steps:
-
A field is added to the conversion of the catalog object definition for each local parameter. This is the conversion of the parameter declaration.
-
A concrete object field is constrained to the field representing the parameter declaration. This is the conversion of the parameter reference.
This example creates two objects from a catalog object called car_template_1
.
Each object has a different value of car_width
.
Note that car_width
is just a declared parameter that is assigned a value when the catalog is referenced in a scenario file.
<Catalog name="VehicleCatalog">
<Vehicle name="car_template_1" vehicleCategory="car">
<ParameterDeclarations>
<ParameterDeclaration name="car_width" parameterType="double" value="2.0">
</ParameterDeclarations>
<BoundingBox>
<Center x="1.4" y="0.0" z="0.9" />
<Dimensions width="$car_width" length="4.75" height="1.8" />
</BoundingBox>
...
</Vehicle>
</Catalog>
<Entities>
<ScenarioObject name="Ego">
<CatalogReference entryName="car_template_1" catalogName="VehicleCatalog">
<ParameterAssignments>
<ParameterAssignment parameterRef="car_width" value="1.8">
</ParameterAssignments>
</CatalogReference>
<ObjectController/>
</ScenarioObject>
<ScenarioObject name="Car 1">
<CatalogReference entryName="car_template_1" catalogName="VehicleCatalog">
<ParameterAssignments>
<ParameterAssignment parameterRef="car_width" value="2.2">
</ParameterAssignments>
</CatalogReference>
<ObjectController/>
</ScenarioObject>
car_template_1: vehicle
keep (car_template_1.vehicle_category == car)
keep (default car_template_1.bounding_box.width == 2.0m)
keep (default car_template_1.bounding_box.length == 4.75m)
keep (default car_template_1.bounding_box.height == 1.8m)
scenario scenario_1:
ego: car_template_1:
keep(ego.bounding_box.width == 1.8m)
car_1: car_template_1:
keep(ego.bounding_box.width == 2.2m)
In ASAM OpenSCENARIO 1.2.0, top-level parameter assignment happens outside of the scenario file. In ASAM OpenSCENARIO 2.0.0, all fields are subject to variation within the limits of the constraints.
In case of the need to replicate behavior of assigning fixed values for some fields from outside of the file of ASAM OpenSCENARIO 2.0.0, you may define your scenario with parameters as fields, and then fix the values of the field in another (top-level) file.
scenario Scenario_1_2_3:
Ego_InitPosition_LaneId: int
Ego_InitSpeed_Ve0: speed
LeadVehicle_InitDistance: length
ego: vehicle
lead_vehicle: vehicle
do parallel:
ego.drive() with:
speed(Ego_InitSpeed_Ve0, at: start)
lane(Ego_InitPosition_LaneId)
lead_vehicle.drive() with:
position(LeadVehicle_InitDistance, ahead_of: ego)
lane(same_as: ego)
import Scenario_1_2_3.osc
scenario top_level:
do: Scenario_1_2_3(Ego_InitPosition_LaneId: -4, Ego_InitSpeed_Ve0: 16.666667mps, LeadVehicle_InitDistance: 33.33333333m)