Skip to content

Vehicle actors examples

Example: vehicle.get_lane_position()

OSC2 code: vehicle.get_lane_position()
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_sumo_config.osc"

extend test_config:
    set implicits_kind = none
    set test_drain_time = 0s
    set min_test_time = 0.1s
    set map = "$FTX_PACKAGES/maps/Town04.xodr"

extend top.main:
    road_1lane: lane_section with: keep(it.lanes == 1)

    do sut.car.drive() with:
        along(road_1lane, start_offset: 10meter, at: start)
        duration(0.2s)



    cover(sut_lane, expression: sut.car.get_lane_position(),
        text: "Relative SUT lane within road (innermost/middle/outermost)")
OSC2 code: example of events related to the lane_shifts counter
import "$FTX/env/basic/exe_platforms/model_ssp/config/model_sumo_config.osc"

extend test_config:
    set map = "$FTX_PACKAGES/maps/M77_FTX_highway_straight_long_road.xodr"

extend top.main:
    keep(sut.car.switch_lane_start_threshold == 20cm)
    keep(sut.car.switch_lane_end_threshold == 20cm)

    do sut.car.drive(duration: [5..10]s) with:
        lane(1, at: start)
        lane(2, at: end)

    on @sut.car.switch_lane_start as start_dat:
        logger.log_info("sut.car starts switching lanes from lane $(start_dat.data.from_lane_pos.lane.map_id)")
    on @sut.car.switch_lane_end as end_dat:
        logger.log_info("sut.car ends switching lanes to lane $(end_dat.data.to_lane_pos.lane.map_id)")