Other predefined actors examples
Example: extend top.main to execute a scenario
OSC2 code: extend top.main to execute a scenario
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
scenario top.sut_free_drive_and_rain:
do parallel(start_to_start: 0s, overlap: any):
sut.car.drive(duration: 5s)
environment.weather(kind:rain)
extend top.main:
do c: sut_free_drive_and_rain()
Example: set a config field
OSC2 code: set a config field
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
extend sim_config:
set speed_factor = 1
Example: environment actor's scenarios
OSC2 code: environment actor's scenarios
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
scenario sut.time_check:
my_time: time
cars: list of vehicle
do parallel(overlap:any):
environment.weather(kind: rain, temperature: 12.5c)
environment.timing(time_of_day: evening)
Example: using environment scenarios
OSC2 code: using environment scenarios
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
scenario top.cut_in:
i:int
extend test_config:
set map = "$FTX_PACKAGES/maps/hooder.xodr"
extend top.main:
do sut.car.drive(duration: 5s)
scenario sut.cut_in_and_rain:
do parallel(overlap:any):
top.cut_in()
environment.weather(rain)
environment.timing(afternoon)
Example: truck_with_mounted_attenuator
OSC2 code: truck_with_mounted_attenuator
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_sumo_config.osc"
extend test_config:
set implicits_kind = none
set map = "$FTX_QA/odr_maps/highway.xodr"
scenario sut.truck_with_mounted_attenuator_ahead:
other_truck: truck_with_mounted_attenuator
road: one_way_road with:
keep(it.min_lanes >= 2)
truck_side: av_road_side with:
# Decide on which side of the road the truck will be placed,
# depending on the sign of the arrow attenuator:
# - when arrow is pointing left, it means that truck must be on
# the rightmost lane (1 from curb)
# - when arrow is pointing right, it means that the truck must
# be on the leftmost lane (1 from center)
keep(other_truck.attenuator_kind == left_arrow_board => it == curb)
keep(other_truck.attenuator_kind == right_arrow_board => it == center)
do parallel(overlap: equal):
sut_drive: sut.car.drive() with:
along(road, at: start)
speed([30..]kph, at: start)
truck_drive: other_truck.drive() with:
along(road, at: start)
position(time: [5..10]s, ahead_of: sut.car, at: start)
lane(1, from: truck_side)
speed(0kph)
on @start:
call logger.log_info("Started $(self). Truck arrow direction: $(other_truck.attenuator_kind)")
extend top.main:
do a: sut.truck_with_mounted_attenuator_ahead()
Example: min_initial_time_headway
OSC2 code: min_initial_time_headway
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
import "$FTX_BASIC/exe_platforms/sumo_ssp/config/sumo_config.osc"
import "$FTX/env/basic/behavioral_models/sumo/builtin/sumo_builtin_bme.osc"
import "$FTX/env/basic/behavioral_models/sumo/common/sumo_demo_profiles.osc"
extend test_config:
set test_drain_time = 0second
set implicits_kind = none
set map = "$FTX/qa/odr_maps/M75_FTX_highway_long_single_road.xodr"
extend top.main:
p: one_way_road
car_group: all_lanes_car_group with(reference_car: sut.car):
keep(it.cars.size() == 10)
dm: sumo_idm_normal_driver
for car in car_group.cars:
keep(car.initial_bm == dm)
for params in car_group.members_params:
keep(params.min_initial_time_headway in [0.5..1.5]second)
do parallel(duration:[5..30]second, overlap:equal):
sut.car.drive() with:
speed(40kph, at:start)
along(p, run_mode: best_effort)
car_group_start: car_group.group_drive()
Example: ftx_group_driver_model
OSC2 code: ftx_group_driver_model
import "$FTX/env/basic/behavioral_models/ftx/ftx_group_driver_model.osc"
import "$FTX/config/sim/sumo_default.osc"
extend test_config:
set map = "$FTX_QA/odr_maps/straight_long_road.xodr"
extend top.main:
ref_car: vehicle
p: one_way_road
car_group: all_lanes_car_group with(reference_car: ref_car):
keep(it.cars.size() in [8..12])
dm: ftx_group_driver_model with:
# Prevent cars from switching lanes
keep(it.change_lane_eagerness == 0)
for car in car_group.cars:
keep(car.initial_bm == dm)
do parallel(duration:[5..30]second, overlap:equal):
ref_car.drive() with:
speed(40kph, at:start)
along(p, run_mode: best_effort)
sut.car.drive() with:
along(p, run_mode: best_effort)
car_group_start: car_group.group_drive()
Example: static road object
OSC2 code: static road object
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_sumo_config.osc"
extend test_config:
set min_test_time = 0sec # This silences the "Scenario completed too early" error
set map = "$FTX_PACKAGES/maps/Town04.xodr"
set implicits_kind = none
set test_drain_time = 0s
extend top.main:
# lane section with more than two lanes and length greater than seven meters
lane_section: lane_section with:
keep(it.lanes > 2 and it.length > 7m)
# generate polygon vertices positions along the lane_section
pg1: msp_position
position_along_road(pg1, road: lane_section, lon_offset: 0m, lane_index: 1)
pg2: msp_position
position_along_road(pg2, road: lane_section, lon_offset: 5m, lane_index: 2)
pg3: msp_position
position_along_road(pg3, road: lane_section, lon_offset: 7m, lane_index: 1)
# define a non-passable construction_zone static road object with the polygon vertices
cz: construction_zone with:
keep(it.physical.passable == false)
cz.place(anchors: [pg1, pg2, pg3])
# drive through the lanes_section with the construction_zone
do serial(duration: [2..6]s):
before_cz: sut.car.drive(duration: [1..2]s)
along_cz: sut.car.drive() with:
along(lane_section, start_offset: 0m, at: start)
along(lane_section, start_offset: 7m, at: end)
after_cz: sut.car.drive(duration: [1..2]s)
Example: background_traffic config
OSC2 code: using background_traffic actor
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_dummy_config.osc"
import "$FTX/env/basic/msp/open_drive.osc"
extend test_config:
set implicits_kind = none
set map = "$FTX_PACKAGES/maps/M499_FTX_suburban.xodr"
set min_test_time = 1s
scenario sut.drive_with_parked_vehicles:
# Instantiate the background_traffic actor and configure the parked vehicles
bt: background_traffic with:
keep(it.config.enable_parked_vehicles == true)
keep(it.config.parked_vehicles_density == 5.0)
keep(it.config.parked_vehicles_min_cluster_size == 4)
keep(it.config.parked_vehicles_max_cluster_size == 6)
keep(it.config.parked_vehicles_cluster_gap_mean == 50cm)
keep(it.config.parked_vehicles_cluster_gap_standard_deviation == 5cm)
do parallel(overlap: any, start_to_start: 0second):
sut_drive: sut.car.drive()
# Call the exists() scenario of the background_traffic actor
bt.exists()
with:
duration([1..2]second)
r: one_way_road
in sut_drive with:
distance([5..]meter, run_mode: best_effort)
along(r, at: start)
keep_lane(run_mode: best_effort)
extend top.main:
do sut.drive_with_parked_vehicles()
Example: background_traffic vehicle category
OSC2 code: configuring vehicle category of parked vehicles
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_dummy_config.osc"
import "$FTX/env/basic/msp/open_drive.osc"
extend test_config:
set implicits_kind = none
set map = "$FTX_PACKAGES/maps/M499_FTX_suburban.xodr"
set min_test_time = 1s
scenario sut.drive_with_parked_vehicles:
bt: background_traffic with:
keep(it.config.enable_parked_vehicles == true)
keep(it.config.parked_vehicles_density == 7.0)
keep(it.config.max_nof_parked_vehicles == 20)
# Constrain parked vehicles to be either vans or sedans with equal distribution
for v in bt.parked_vehicles:
keep(soft v.vehicle_category == weighted(
10: sedan,
10: van))
r: one_way_road
do parallel(overlap: any, start_to_start: 0second):
sut_drive: sut.car.drive() with:
distance([5..]meter, run_mode: best_effort)
along(r, at: start)
keep_lane(run_mode: best_effort)
bt.exists()
with:
duration([1..2]second)
extend top.main:
do sut.drive_with_parked_vehicles()