### Examples for replay_path Action with Absolute Paths in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates how to use the 'replay_path' action with absolute path definitions. Examples cover simple invocations and usage with start and end offset parameters. ```OpenSCENARIO DSL # Using an absolute path my_abs_path: path # Add constraints for fields of my_abs_path # Absolute path -- simple invocation do: my_car.replay_path(absolute: my_abs_path) # Absolute path -- with offset parameters do: my_car.replay_path(absolute: my_abs_path, start_offset: 2.0m, end_offset: 0.5m) ``` -------------------------------- ### Examples for drive() action in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Provides practical examples of the 'drive' action, showcasing how to specify speed targets, acceleration, duration, and path following. These examples demonstrate controlling vehicle speed and trajectory. ```ASAM OpenSCENARIO DSL 1 2 3 4 5 6 7 8 9 10 | # Speed target of 30km/h for the end of the action, with constant acceleration my_car.drive() with: speed(30kph, at: end) acceleration(5kphps) # Drive for 30 seconds at 50km/h along road "my_road" with starting position relative to other_car my_car.drive(duration: 30s) with: speed(50kph) along(my_road) position(distance: 20m, behind: other_car, at: start) ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Examples for keep_space_headway() Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Provides a practical example of invoking the `keep_space_headway` action in ASAM OpenSCENARIO DSL. This demonstrates how to specify the reference object for maintaining the space headway. ```DSL my_car.keep_space_headway(other_car) ``` -------------------------------- ### OpenSCENARIO DSL: Examples for follow_trajectory Action Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical usage scenarios for the 'follow_trajectory' action, demonstrating how to define and use both absolute and relative trajectories. Examples include simple invocations, offset parameter usage, and overriding default reference and transform parameters. ```openscenario # Using an absolute trajectory my_abs_traj: trajectory # Add constraints for fields of my_abs_traj # Absolute trajectory -- simple invocation do: my_car.follow_trajectory(absolute: my_abs_traj) # Absolute trajectory -- with offset parameters do: my_car.follow_trajectory(absolute: my_abs_traj, start_offset: 2.0m, end_offset: 0.5m) # Using a relative trajectory my_rel_traj: relative_trajectory_pose_3d # Add constraints for fields of my_rel_traj # Can also use types relative_trajectory_st, relative_trajectory_odr # Relative trajectory -- simple invocation do: my_car.follow_trajectory(relative: my_rel_traj) # Uses default values for parameters 'reference' and 'transform' # Relative trajectory -- identical semantics to simple invocation do: my_car.follow_trajectory(relative: my_rel_traj, reference: my_car, transform: object_relative) # Relative trajectory -- override default parameters do: my_car.follow_trajectory(relative: my_rel_traj, reference: other_car, transform: world_relative) # Relative trajectory -- with offset options do: my_car.follow_trajectory(relative: my_rel_traj, start_offset: 2.0m, end_offset: 0.5m) # Uses default values for parameters 'reference' and 'transform' ``` -------------------------------- ### Examples for Change Acceleration Action (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates various ways to use the change_acceleration action with different parameter combinations. Examples include reaching a target acceleration, using 'asap' or 'smooth' profiles, specifying jerk, and setting a duration. ```OpenSCENARIO DSL | # Reach target -- only mandatory parameters are specified car2.change_acceleration(1.0mpsps) # Reach target as soon as possible car2.change_acceleration(1.0mpsps, asap) # Reach target with smooth jerk car2.change_acceleration(1.0mpsps, smooth) # Reach target with constant jerk of 2m/s/s/s car2.change_acceleration(-2.0meter_per_sec_sqr, constant, 2.0meter_per_sec_cubed) # Reach target in 2 seconds car2.change_acceleration(3.0mpsps, duration: 2.0sec) # Reach target in 2 seconds, keeping a constant jerk car2.change_acceleration(3.0mpsps, duration: 2.0sec, rate_profile: constant) ``` -------------------------------- ### Examples for follow_path Action in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical usage scenarios for the 'follow_path' action, covering both absolute and relative path invocations. Examples include simple calls, calls with offset parameters, and overriding default reference and transform parameters. ```openscenario | # Using an absolute path my_abs_path: path # Add constraints for fields of my_abs_path # Absolute path -- simple invocation do: my_car.follow_path(absolute: my_abs_path) # Absolute path -- with offset parameters do: my_car.follow_path(absolute: my_abs_path, start_offset: 2.0m, end_offset: 0.5m) # Using a relative path my_rel_path: relative_path_pose_3d # Add constraints for fields of my_rel_path # Can also use types relative_path_st, relative_path_odr # Relative path -- simple invocation do: my_car.follow_path(relative: my_rel_path) # Uses default values for parameters 'reference' and 'transform' # Relative path -- identical semantics to simple invocation do: my_car.follow_path(relative: my_rel_path, reference: my_car, transform: object_relative) # Relative path -- override default parameters do: my_car.follow_path(relative: my_rel_path, reference: other_car, transform: world_relative) # Relative path -- with offset options do: my_car.follow_path(relative: my_rel_path, start_offset: 2.0m, end_offset: 0.5m) # Uses default values for parameters 'reference' and 'transform' ``` -------------------------------- ### Apply Multiple Initial Constraints in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/writing_reusable_scenarios Illustrates how to apply multiple, parallel initial conditions to a vehicle's action in OpenSCENARIO DSL. This allows for more complex starting states by constraining speed and lateral movement simultaneously at the start. ```openscenario | scenario my_other_scenario: do parallel: init: car1.drive() with: # starts at t=0 speed(speed: 40kph, at: start) a1: car1.drive() with: # further initial conditions for car1. This affects the same initial drive lateral(speed: 2kph, at:start) ``` -------------------------------- ### Examples for Keep Acceleration Action (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates a sequence of actions using keep_acceleration. This example shows how to first change acceleration, then maintain it for a duration, and finally reduce it to zero. ```OpenSCENARIO DSL | # Accelerate up to 3 mpsps, keep this acceleration for 2 seconds and then reduce acceleration until it reaches zero do serial: my_car.change_acceleration(3.0mpsps) my_car.keep_acceleration(duration: 2.0sec) my_car.change_acceleration(0.0mpsps) ``` -------------------------------- ### OpenSCENARIO DSL: Examples for change_lane Action Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical examples of using the 'change_lane' action in ASAM OpenSCENARIO DSL. These examples cover basic lane changes to the left, changes with lateral offsets, changing to the same lane as another vehicle, and changing lanes based on a specified number and side relative to a reference vehicle, including options for dynamic profiles. ```openscenario # Changes one (1) lane to the left (using default values) my_car.change_lane(side: left) # Changes one (1) lane to the left with lateral offset in target lane my_car.change_lane(side: left, offset: 0.5m) # Changes to same lane as other car my_car.change_lane(side: same_as, reference: other_car) # Changes to a lane two (2) lanes right of other_car my_car.change_lane(2, right, other_car) my_car.change_lane(num_of_lanes: 2, side: right, reference: other_car) # Changes to a lane two (2) lanes right of other_car, with shape options my_car.change_lane(2, right, other_car, rate_profile: smooth, rate_peak: 0.9mps) ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Examples for keep_time_headway() Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Shows a simple example of invoking the 'keep_time_headway' action in ASAM OpenSCENARIO DSL, specifying only the required reference object. ```openscenario | my_car.keep_time_headway(other_car) ``` -------------------------------- ### Examples for replay_trajectory Action in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical usage of the replay_trajectory action with various configurations. It shows examples for both absolute and relative trajectories, including the use of offset parameters and different reference objects/transforms. ```OpenSCENARIO DSL | # Using an absolute trajectory my_abs_traj: trajectory # Add constraints for fields of my_abs_traj # Absolute trajectory -- simple invocation do: my_car.replay_trajectory(absolute: my_abs_traj) # Absolute trajectory -- with offset parameters do: my_car.replay_trajectory(absolute: my_abs_traj, start_offset: 2.0m, end_offset: 0.5m) # Using a relative trajectory my_rel_traj: relative_trajectory_pose_3d # Add constraints for fields of my_rel_traj # Can also use types relative_trajectory_st, relative_trajectory_odr # Relative trajectory -- simple invocation do: my_car.replay_trajectory(relative: my_rel_traj) # Uses default values for parameters 'reference' and 'transform' # Relative trajectory -- identical semantics to simple invocation do: my_car.replay_trajectory(relative: my_rel_traj, reference: my_car, transform: object_relative) # Relative trajectory -- override default parameters do: my_car.replay_trajectory(relative: my_rel_traj, reference: other_car, transform: world_relative) # Relative trajectory -- with offset options do: my_car.replay_trajectory(relative: my_rel_traj, start_offset: 2.0m, end_offset: 0.5m) # Uses default values for parameters 'reference' and 'transform' ``` -------------------------------- ### Examples for replay_path Action with Relative Paths in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates the usage of the 'replay_path' action with relative path definitions. Examples show simple invocations, overriding default reference and transform parameters, and using offset parameters. ```OpenSCENARIO DSL # Using a relative path my_rel_path: relative_path_pose_3d # Add constraints for fields of my_rel_path # Can also use types relative_path_st, relative_path_odr # Relative path -- simple invocation do: my_car.replay_path(relative: my_rel_path) # Uses default values for parameters 'reference' and 'transform' # Relative path -- identical semantics to simple invocation do: my_car.replay_path(relative: my_rel_path, reference: my_car, transform: object_relative) # Relative path -- override default parameters do: my_car.replay_path(relative: my_rel_path, reference: other_car, transform: world_relative) # Relative path -- with offset options do: my_car.replay_path(relative: my_rel_path, start_offset: 2.0m, end_offset: 0.5m) # Uses default values for parameters 'reference' and 'transform' ``` -------------------------------- ### Anchor Two Vehicle Starting Locations in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/dm_abstract_road_network This example shows how to define two distinct starting locations for vehicles using anchors in ASAM OpenSCENARIO DSL. It involves specifying the map, anchoring lane sections and lanes for each location, allowing vehicles to start from different points on the same map. ```ASAM OpenSCENSCENARIO DSL my_map: map.map_file = ['my_map1.xodr'] anchored_starting_location1: lane_section with: keep('location1_uuid' in it.anchors) anchored_location1_lane: lane with: keep('-1' in it.anchors) anchored_starting_location2: lane_section with: keep('location2_uuid' in it.anchors) anchored_location2_lane: lane with: keep('-3' in it.anchors) ``` -------------------------------- ### Examples for keep_space_gap() in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical usage of the 'keep_space_gap' action with concrete examples. It shows equivalent ways to call the function, both with named parameters and positional arguments, for both longitudinal and lateral directions. ```ASAM OpenSCENARIO DSL # These two invocations are equivalent: my_car.keep_space_gap(other_car, longitudinal) my_car.keep_space_gap(reference: other_car, direction: longitudinal) # These two invocations are equivalent: my_car.keep_space_gap(other_car, lateral) my_car.keep_space_gap(reference: other_car, direction: lateral) ``` -------------------------------- ### Examples for change_speed() in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates various ways to use the 'change_speed' action in ASAM OpenSCENARIO DSL. Examples cover reaching a target speed immediately, as soon as possible, with smooth acceleration, with constant acceleration, within a specific duration, and with a constant acceleration profile over a duration. ```DSL # Reach target -- only mandatory parameters are specified car2.change_speed(35kph) # Reach target as soon as possible car2.change_speed(35kph, asap) # Reach target with smooth acceleration car2.change_speed(35kph, smooth) # Reach target with constant acceleration of 3 m/s/s car2.change_speed(35kph, constant, 3.0meter_per_sec_sqr) # Reach target in 3 seconds car2.change_speed(35kph, duration: 3.0sec) # Reach target in 3 seconds, keeping a constant acceleration car2.change_speed(35kph, duration: 3.0sec, rate_profile: constant) ``` -------------------------------- ### OpenSCENARIO DSL: Examples for change_position Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates practical usage of the 'change_position' action with different coordinate systems. Examples show moving using global x-y-z coordinates, route s-t coordinates, and odr coordinates, specifying interpolation and road network adherence. ```openscenario # Using global x-y-z coordinates # Move in straight line, ignoring road network my_pos: position_3d # Add constraints for fields of my_pos do: my_car.change_position(my_pos, straight_line, False) # Same as: my_car.change_position(target_xyz: my_pos, interpolation: smooth, on_road_network: False) # Using route s-t coordinates # Move along a smooth path, using road network my_st: route_point # Add constraints for fields of my_st do: my_car.change_position(target_st: my_st, interpolation: smooth, on_road_network: True) # Using odr coordinates # Move in straight line, using road network my_car: vehicle my_odr: odr_point # Add constraints for fields of my_odr do: my_car.change_position(target_odr: my_odr, interpolation: smooth, on_road_network: True) ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Air Action Examples Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/environment-actions Provides practical examples of using the 'air' action in ASAM OpenSCENARIO DSL. It shows how to set all three parameters (temperature, pressure, relative humidity), combinations of two, or individual parameters. ```DSL # All three variables environment.air(15.0celsius, 1050.0hPa, 0.65) environment.air(temperature: 15.0celsius, pressure: 1050.0hPa, relative_humidity: 0.65) # Only temperature and relative humidity (presure is not modified) environment.air(15.0celsius, relative_humidity: 0.65) environment.air(temperature: 15.0celsius, relative_humidity: 0.65) # Only temperature environment.air(15.0celsius) environment.air(temperature: 15.0celsius) # Only pressure environment.air(pressure: 1050.0hPa) # Only relative_humidity environment.air(relative_humidity: 0.65) ``` -------------------------------- ### Examples for keep_speed() in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates how to use the 'keep_speed' action in ASAM OpenSCENARIO DSL. This example shows a sequence where a car first changes its speed to 35 kph and then maintains that speed using 'keep_speed()'. ```DSL # First go to 35kph and then keep this speed do serial: my_car.change_speed(35kph) my_car.keep_speed() ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Wind Action Examples Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/environment-actions Offers examples of the 'wind' action in ASAM OpenSCENARIO DSL, demonstrating how to set both speed and direction, or just one of them. It shows direct value assignment and named parameter usage. ```DSL # Both variables environment.wind(3.0mps, 45deg) environment.wind(speed: 3.0mps, direction: 45deg) # Only wind speed environment.wind(3.0mps) environment.wind(speed: 3.0mps) ``` -------------------------------- ### Example ASAM OpenSCENARIO Scenario Definition Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/conceptual-overview/writing_a_scenario This code provides a basic example of an ASAM OpenSCENARIO scenario definition. It illustrates the 'Python style' syntax where line breaks and indentation are significant. The scenario defines a vehicle's movement over two phases with specific speed constraints. ```ASAM OpenSCENARIO DSL | scenario vehicle.two_phases: do serial (duration : [10s..30s]): phase1: actor.drive() with: speed(speed: 0kph, at: start) speed(speed: 10kph, at: end) phase2: actor.drive() with: speed(speed: [10kph..15kph]) ``` -------------------------------- ### Get Route Start Point in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/road_abstractions Retrieves the starting point of a route. The start point is defined as the point with the minimum s-coordinate value on the route. ```openscenario extend route: def start_point() -> route_point ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Example for connect_trailer() Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates a multi-phase scenario in ASAM OpenSCENARIO DSL involving the `connect_trailer` action. It shows how to define vehicle and trailer entities, set up a distance constraint, and execute sequential actions for approaching, connecting, and driving with the trailer. ```DSL my_car: vehicle my_trailer: trailer trailer_distance: length # Distance between vehicle rear axle and trailer rear axle keep(trailer_distance == -my_car.trailer_receiver.position_x + my_trailer.coupler.position_x) do serial: phase1: my_car.drive() with: position(trailer_distance, ahead_of: my_trailer, at: end) speed(0kph, at: end) phase2: my_car.connect_trailer(my_trailer) phase3: my_car.drive() with: speed(50kph, at: end) ``` -------------------------------- ### Connect Crossing with Start and End Lines (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/extending_the_domain_model This example shows how to define a crossing using two lines, each defined by free space points, for both the start and end. It includes specifying the crossing, map, start line, end line, starting s-coordinate, and a custom start angle. ```OpenSCENSCENARIO DSL map: map free_space_line1: list of free_space_point = [point1, point2] free_space_line2: list of free_space_point = [point3, point4] crossing1: crossing with: keep(it.width == 3.5m) map.crossing_connects(crossing1, start_line: free_space_line1, end_line: free_space_line2, start_s_coordinate: 5m, start_angle: 85deg) ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Examples for change_space_headway() Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates two equivalent ways to invoke the `change_space_headway` action in ASAM OpenSCENARIO DSL. It shows both the shorthand and the explicit parameter assignment for clarity and flexibility in defining the maneuver. ```DSL # These two invocations are identical: my_car.change_space_headway(12.5m, ahead, other_car) my_car.change_space_headway(target: 12.5m, direction: ahead, reference: other_car) ``` -------------------------------- ### ASAM OpenSCENARIO: Snake_case Naming Convention Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/coding_style_guide Provides examples of correctly formatted ASAM OpenSCENARIO code adhering to the snake_case naming convention for all elements except keywords. This includes defining actors, structs, and scenarios. ```ASAM OpenSCENARIO # 1: Define an actor actor car_group: average_distance: length number_of_cars: uint # 2: Define a road element struct struct geometric_road: road_element: min_radius: length max_radius: length side: av_side # 3: Define a scenario scenario dut.traverse_junction_at_yield: s: road_with_sign with(sign_type: yield) do dut.car.traverse_junction() with: ... # 4: Define a containing scenario scenario dut.mix_three_dangers: weather_kind: weather_kind keep(weather_kind != clear) do mix: cut_in_and_slow() traverse_junction_at_yield() weather(kind: weather_kind) ``` -------------------------------- ### Example: Vehicle Towing a Trailer (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/entity Demonstrates the setup of a towing truck and a trailer in OpenSCENARIO DSL. It includes defining vehicle and trailer types, specifying hitch receiver details, and linking them. ```OpenSCENARIO DSL | my_towing_truck: vehicle keep(my_towing_truck.vehicle_category == truck) my_receiver: hitch_receiver keep(my_receiver.trailer_category == fifth_wheel) keep(my_receiver.position_x == -1.2) keep(my_receiver.position_z == 0.5) my_trailer: trailer keep(my_trailer.trailer_category == fifth_wheel) my_towing_truck.trailer_receiver = my_receiver my_trailer.coupler = my_receiver my_towing_truck.tow_trailer(my_trailer) ``` -------------------------------- ### Cross Coverage Directive Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/coverage_main Shows how to create a 'cross-coverage' by combining three cover vectors: relative distance, absolute velocity, and relative speed. These are sampled at the start of the 'change_lane' phase, creating a Cartesian product of their values. ```openscenario cover(cross_dist_vel, items: [rel_d_cls, dut_v_cls,rel_v_cls], event: change_lane_start, text: "Cross coverage of relative distance and absolute velocity") ``` -------------------------------- ### Cross Record Directive Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/coverage_main Illustrates the creation of a 'cross-record' by combining two previously defined items: a record item ('ttc_at_end_of_change_lane') and a cover item ('dut_v_cls'). This creates a Cartesian product of their values, sampled at a specified event ('start'). ```openscenario record(ttc_dut_vel, items: [ttc_at_end_of_change_lane, dut_v_cls], event: start, text: "Cross record of TTC and absolute DUT velocity") ``` -------------------------------- ### ASAM OpenSCENARIO: Line Continuation Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/coding_style_guide Demonstrates the use of the backslash ('\') character for line continuation in ASAM OpenSCENARIO. This allows long statements or text lines to be broken across multiple physical lines for improved readability. ```ASAM OpenSCENARIO This is a line of text that is too long for a single \ line, so continue after the backslash in a new line. ``` -------------------------------- ### Examples for follow_lane action in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates various ways to use the 'follow_lane' action, including following the lane centerline, using offsets, specifying duration, and targeting specific lanes. It also shows how to combine these parameters for complex lane following scenarios. ```ASAM OpenSCENARIO DSL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Follow the centerline of the current lane my_car.follow_lane() my_car.follow_lane(0.0m) my_car.follow_lane(offset: 0.0m) # Follow the centerline of the current lane with duration 30 seconds my_car.follow_lane(duration: 30s) # Follow the current lane, with the current lateral offset my_car.follow_lane(offset: my_car.get_t_coord(on_lane)) # Follow the current lane with a fixed lateral offset... # ... and move to the target offset using the shape options my_car.follow_lane(-0.4m, smooth, 0.2mps) my_car.follow_lane(offset: -0.4m, rate_profile: smooth, rate_peak: 0.2mps) # Follow a previously declared instance of lane "my_lane" # If my_car is not in my_lane when the action starts, this should produce an error my_car.follow_lane(target: my_lane) # Follow a previously declared instance of lane "my_lane", with lateral offset my_car.follow_lane(target: my_lane, offset: 0.3m) # Follow lane "my_lane" with lateral offset... # ... and move to offset with constant lateral velocity and duration 1.5 seconds # The peak_rate (peak lateral velocity) is unconstrained and free for the implementation to decide my_car.change_lane(target: my_lane, rate_profile: constant, duration: 1.5s) ``` -------------------------------- ### Example of Parallel Composition Operator in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/Semantics This snippet demonstrates the usage of the 'parallel' operator in the ASAM OpenSCENARIO DSL. It defines two parallel phases, 'phaseA' and 'phaseB', involving vehicle actors v1 and v2, specifying their speed and positional constraints. The 'parallel()' function is used without parameters, defaulting to 'start' overlap. ```OpenSCENARIO DSL scenario parallel_phases: v1, v2: vehicle do parallel(): phaseA: v1.drive() with: speed(speed: 0kph, at: start) speed(speed: 10kph, at: end) phaseB: v2.drive() with: speed(speed: [10kph..15kph]) position(distance: [5m..100m], behind: v1, at: start) ``` -------------------------------- ### ASAM OpenSCENARIO: Whitespace and Operator Usage Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/coding_style_guide Demonstrates the correct application of whitespace around commas, colons, keywords, operators, brackets, braces, and value-unit pairs in ASAM OpenSCENARIO code. This ensures code readability and adherence to the DSL's formatting rules. ```ASAM OpenSCENARIO func(arg[1], arg2) if x == 4: print x, y foo == [x, y, z] func(1) abc[key] = lst[index] i = i + 1 actor bus: car(category: bus): keep(width == 1.8m) keep(length == 4.5m) swerve_story: serial: side_vehicle.drive() with: path(s_side_vehicle) keep_speed() with: until (top.time > 5sec) ``` -------------------------------- ### ASAM OpenSCENARIO DSL Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/coding_style_guide This snippet demonstrates a complex ASAM OpenSCENARIO DSL script. It defines vehicles, road conditions, simulation parameters, and event triggers for a driving scenario. It relies on external Python scripts for specific calculations like TTC and distance. ```ASAM OpenSCENARIO DSL | scenario slower_large_vehicle_in_adjacent_lane ego_vehicle: vehicle with: keep(p_vehicle_model == APTIV_ego_vehicle) v1: vehicle with: keep(vehicle_category == Bus) keep(p_vehicle_model == BlueBird_Vision_2014) keep(p_vehicle_model.Color == Blue) ego_model: ego_vehicle.p_vehicle_model ego_route: ego_vehicle.route v1_model: v1.p_vehicle_model v1_route: v1.route ego_start_speed: speed ego_start_distance: length v1_start_speed: speed v1_start_distance: length simulation_platform_choice: string simulation_time_threshold_reached: time ego_ttc_threshold: time ego_distance_to_bias: length lane_choice: string ego_lane: lane map: file_path keep(map == "/maps/example.xodr") simple_3_lane_road_01: lane_section lane1^: lane lane2^: lane lane3^: lane simple_3_lane_road_01.lanes = [lane1^, lane2^, lane3^] keep(simple_2_lane_road_01 == map.road(id:"1").*lane_section(s:"0")) lane3^ = rightmost_lane(map.*right) keep(lane2^ -[:LEFT_OF]-> lane3^) keep(lane1^ -[:LEFT_OF]-> lane2^) # Logic parameter syntax keep(ego_lane in: { if: lane_choice == "Left" THEN: SET ego_lane = "lane1^", if: lane_choice == "Right" THEN: SET ego_lane = "lane3^"}) keep(ego_model == APTIV_ego_vehicle) keep(ego_route == ego_drive_left) keep(v1_model == BlueBird_Vision_2014) keep(v1_route == v1_drive) keep(ego_start_speed == 80.46719999999999 [kph]) keep(ego_start_distance == 5 [m]) keep(v1_start_speed == 48.28032 [kph]) keep(v1_start_distance == 55.0 [m]) keep(simulation_platform_choice == "CarMaker") keep(simulation_time_threshold_reached == 120 [s]) keep(ego_ttc_threshold == 1 [s]) keep(ego_distance_to_bias == 1 [m]) keep(lane_choice == "Left") # Relationship syntax keep(v1_start_speed -[:SLOWER_THAN]-> ego_start_speed) def distance_between_ego_vehicle_and_v1(vehicle, vehicle) -> length is external "kpi.py" def get_ttc_with_vehicle_to_vehicle(vehicle, vehicle, string) -> time is external "kpi_TTC.py" !ego_speed: speed = ego_vehicle.speed !ego_end_of_road: Position = ego_vehicle.end_of_road !ego_off_road: Position = ego_vehicle.off_road !simulation_time: time = simulation.time !ego_vehicle_lane: lane = ego_vehicle.lane !ego_collision_monitor: integer = sensor.collision.v.fr1.count !ego_ttc_with_v1: time = sample(ego_vehicle.get_ttc_with_vehicle_to_vehicle(ego_vehicle:vehicle, v1:vehicle, [simulation_platform_choice])) !ego_distance_to_v1: length = sample(distance_between_egoVehicle_and_v1(v1:vehicle, ego_vehicle:vehicle, [simulation_platform_choice])) event observation_complete is(one_of(@end_conditions)) event ego_ttc_threshold_reached1 is(!ego_ttc_with_v1 < ego_ttc_threshold) event ego_close_to_v1 is(!ego_distance_to_v1 < ego_distance_to_bias) event end_conditions[1] is(!ego_end_of_road > 0) event end_conditions[2] is(!ego_off_road > 0) event end_conditions[3] is(!simulation_time > [simulation_time_threshold_reached]) event end_conditions[4] is(!ego_collision_monitor > 0) event end_conditions[5] is((ego_vehicle.s_road - v1.s_road) > 40) do parallel(): ego_init_drive_01: ego_vehicle.drive(ego_route) with: position(at_distance: ego_start_distance, beyond_start_of: ego_route) speed(at_speed: ego_start_speed) at(at:start) v1_init_drive_01: v1.drive(v1_route) with: position(at_distance: v1_start_distance, ahead_of: ego_vehicle) speed(at_speed: v1_start_speed) at(at:start) until(@observation_complete) ``` -------------------------------- ### OpenSCENARIO DSL: change_lane() Modifier Examples Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/movement-modifiers Provides examples of the change_lane() modifier in OpenSCENARIO DSL. These examples show how to initiate a lane change to the left or to change multiple lanes to the right. ```openscenario | # Change lane one lane to the left do serial: vehicle1.drive() with: change_lane(side: left) # Change the lane 1, 2 or 3 lanes to the right do serial: vehicle1.drive() with: change_lane([1..3], right) ``` -------------------------------- ### Connect Crossing Between Lanes Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/road_abstractions Connects a crossing to two specified lanes, defining the start and end points. It allows for an optional start angle for the crossing's origin from the start lane, defaulting to perpendicular. ```OpenSCENARIO DSL | my_cross: crossing sidewalk_1, sidewalk_2: lane map.crossing_connects(my_cross, sidewalk_1, sidewalk_2, 5m) ``` ```OpenSCENARIO DSL | my_cross: crossing sidewalk_3, sidewalk_4: lane map.crossing_connects(my_cross, sidewalk_3, sidewalk_4, 5m, 60deg) ``` -------------------------------- ### ASAM OpenSCENARIO DSL: Examples for change_time_headway() Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Illustrates two equivalent ways to invoke the 'change_time_headway' action in ASAM OpenSCENARIO DSL, showing both the shorthand and the explicit parameter assignment. ```openscenario | # These two invocations are identical: my_car.change_time_headway(4.1s, ahead, other_car) my_car.change_time_headway(target: 4.1s, direction: ahead, reference: other_car) ``` -------------------------------- ### Define and Connect a Crossing in ASAM OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/dm_abstract_road_network Demonstrates how to define a crossing with specific width constraints and connect it between two lanes (sidewalks) using start and end lane references, along with specifying start coordinates and angle. It highlights the flexibility of omitting the start angle. ```DSL map: map sidewalk1: lane sidewalk2: lane crossing1: crossing with: keep(it.width == 3.5m) map.crossing_connects(crossing1, start_lane: sidewalk1, end_lane: sidewalk2, start_s_coord: 5m, start_angle: 90deg) # may be used without 'start_angle' parameter ``` -------------------------------- ### Usage of follow_path Action in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates the syntax for invoking the 'follow_path' action with absolute and relative path parameters. It outlines optional parameters like start_offset, end_offset, and inherited action parameters. ```openscenario | movable_object.follow_path(absolute: path [, start_offset: length] [, end_offset: length] [, ]) movable_object.follow_path(relative: relative_path, reference: physical_object, transform: relative_transform, [, start_offset: length] [, end_offset: length] [, ]) ``` -------------------------------- ### ASAM OpenSCENARIO: UN Regulation No. 157 ALKS Example Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/annexes/examples This snippet is a placeholder for an ASAM OpenSCENARIO example inspired by UN Regulation No. 157 concerning Automated Lane Keeping Systems (ALKS). It outlines the context and requirements for testing ALKS performance in lane keeping. ```ASAM OpenSCENARIO # Note: This is a snapshot of a sample scenario file developed as part # of the OpenSCENARIO 2.x project. It is not intended to demonstrate # actual UNECE ALKS scenarios, nor is necessarily up to date with final # OpenSCENARIO 2.0 semantics or domain model usage. # UNECE 157 ALKS P.60 # 4. Test scenarios to assess the performance of the system with regard to the dynamic driving task # 4.1. Lane Keeping # 4.1.1. The test shall demonstrate that the ALKS does not leave its lane and maintains a stable position inside its ego lane across the speed range and # different curvatures within its system boundaries. # 4.1.2. The test shall be executed at least: # (a) With a minimum test duration of 5 minutes; # (b) With a passenger car target as well as a PTW target as the lead vehicle / other vehicle; # (c) With a lead vehicle swerving in the lane; and # (d) With another vehicle driving close beside in the adjacent lane. # # Addendum in previous chapter: ``` -------------------------------- ### Connect Crossing with Start Line and End Lane (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/user-guide/extending_the_domain_model This snippet demonstrates how to connect a crossing using a line defined by free space points as the start and a lane as the end. It specifies the crossing, the map, the free space line, the end lane, and the starting s-coordinate and angle. ```OpenSCENARIO DSL map: map free_space_line1: list of route_point = [point1, point2] sidewalk1: lane crossing1: crossing with: keep(it.width == 3.5m) map.crossing_connects(crossing1, start_line: free_space_line1, end_lane: sidewalk1, start_s_coord: 5m, start_angle: 90deg) ``` -------------------------------- ### Move Actor with Speed and Position (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates how to use the 'move' action to control an actor's movement. It allows specifying speed, position relative to another actor, and lateral placement. The example shows setting initial conditions and then moving the actor to a new position over a specified duration. ```OpenSCENARIO DSL my_box.move() with: position(10m, ahead_of: my_car, at: start) lateral(2m, side: left, side_of: my_car, at: start) speed(10kph) # Move to position in front of my_car and stop, with duration 3 seconds my_box.move(duration: 3s) with: speed(0kph, at: end) position(3m, ahead_of: my_car, at: end) lateral(0.2m, side_of: my_car, at: end) ``` -------------------------------- ### Usage of replay_path Action in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates the basic syntax for using the 'replay_path' action with both absolute and relative path definitions. It outlines the parameters available for each type of path, including optional offset parameters. ```OpenSCENARIO DSL movable_object.replay_path(absolute: path [, start_offset: length] [, end_offset: length] [, ]) movable_object.replay_path(relative: relative_path, reference: physical_object, transform: relative_transform, [, start_offset: length] [, end_offset: length] [, ]) ``` -------------------------------- ### Example Vehicle Group Definition and Usage in OpenSCENARIO Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/entity This example demonstrates how to define and use a 'vehicle_group' in ASAM OpenSCENARIO. It shows the creation of a single-lane vehicle group and applies constraints to the vehicles within the group, such as their category. The example also illustrates how to make the ego vehicle ('dut') drive alongside the group. ```openscenario scenario dut.driving_alongside_group: # Defining a group with a common route and # a single-lane formation g: single_lane_vehicle_group # Using 'for' constraint to control vehicles # parameters for v in g.vehicles: keep(v.category in [bus, truck]) r: route do parallel: g.drive() with: along(r) lane(side_of: dut.vehicle, at: start) dut.vehicle.drive() with: along(r) ``` -------------------------------- ### Change Acceleration Action Usage (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates the basic syntax for the change_acceleration action in the OpenSCENARIO DSL. It specifies the target acceleration and optional parameters for rate profile and peak jerk. ```OpenSCENARIO DSL | movable_object.change_acceleration(target: acceleration [, rate_profile: dynamic_profile [, rate_peak: jerk]] [, ]) ``` -------------------------------- ### Unassociated Modifier Example in OpenSCENARIO DSL Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/types An example of an unassociated modifier declaration in OpenSCENARIO DSL. This modifier, `force_lane`, is global and requires parameters for the `vehicle` and the target `lane`. ```OpenSCENARIO DSL modifier force_lane(): # define a global modifier that forces a vehicle to be in a specific lane vehicle: vehicle # when this modifier is applied, specify the vehicle lane: int # when this modifier is applied specify the lane the vehicle needs to be in ... ``` -------------------------------- ### ASAM OpenSCENARIO DSL: File Import Examples Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/Libraries Demonstrates various ways to import files using string literals (URIs) and identifiers (module references) in ASAM OpenSCENARIO DSL. Supports 'file' URI scheme and implementation-specific module resolution. ```osc # URI-based import statements import "foo/bar.osc" import "file:///c:/Users/someone/src/foo/bar.osc" import "file:/c:/Users/someone/src/foo/bar.osc" import "/c:/Users/someone/src/foo/bar.osc" import "file:///home/someone/src/foo/bar.osc" import "file:/home/someone/src/foo/bar.osc" import "/home/someone/src/foo/bar.osc" # Identifier-based import statements import osc.standard.all # Imports the standard library, see next section. import foo.bar # Imports a module foo.bar in some implementation defined way ``` -------------------------------- ### Direct Scenario Invocation Example (OpenSCENARIO DSL) Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/language-reference/Semantics Demonstrates a direct invocation of the 'drive' action within a scenario. It specifies a target speed and a duration constraint for the 'drive' action. The 'drive' action is invoked with a speed modifier, setting a target speed at the end of its execution. ```OpenSCENARIO DSL scenario vehicle.accelerate: target_speed: speed do drive(duration: [2s..4s]) with: speed(speed: target_speed, at: end) ``` -------------------------------- ### OpenSCENARIO DSL: Usage of follow_trajectory Action Source: https://publications.pages.asam.net/standards/ASAM_OpenSCENARIO/ASAM_OpenSCENARIO_DSL/latest/domain-model/actions Demonstrates the basic syntax for invoking the 'follow_trajectory' action using both absolute and relative trajectory definitions. It outlines the required parameters and optional inherited action parameters. ```openscenario movable_object.follow_trajectory(absolute: trajectory [, start_offset: length] [, end_offset: length] [, ]) movable_object.follow_trajectory(relative: relative_trajectory, reference: physical_object, transform: relative_transform, [, start_offset: length] [, end_offset: length] [, ]) ```