Skip to content

Movement scenarios

Scenarios that describe a continuous segment of movement by a single actor are called movement scenarios. vehicle.drive() moves a vehicle with optional modifiers such as along() and speed(). For example:

OSC2 code: vehicle.drive() example 1
    do serial:
        car1.drive() with:
            along(h)
            speed([30..70]kph)

See complete example.

vehicle.drive()

Purpose

Describe a continuous segment of movement by a vehicle actor.

Category

Movement scenario (vehicle actor)

Syntax

drive( [duration: <time>])[<with-block>]

Parameters

<time>
Is a single time value or a range with a time unit, such as [100..120]s.
<with-block>
Is a list of one or more keep() constraints or scenario modifiers, where the members are listed on separate lines as a block or on the same line as with: and separated by semi-colons. For example, the following two examples are equivalent:
OSC2 code: drive() with block
car1.drive() with:
    speed(30kph)
    acceleration(5kphps)
car1.drive() with: speed(30kph); acceleration(5kphps)

Example

OSC2 code: vehicle.drive() example 2
    do parallel(overlap:equal):
        sut.car.drive() with:
            along(hwy1)
        car1.drive() with:
            speed(speed: [30..200]kph)
            position(distance: [5..100]meter, behind: sut.car, at: start)
            along(hwy1)

See complete example.

random_traffic_car_group.group_drive

Purpose

Moves vehicles around an origin vehicle (usually the SUT)

Category

Movement scenario (random_traffic_car_group actor)

Syntax

group_drive([duration: <time>]) [<with-block>]
light_highway_traffic([duration: <time>]) [<with-block>]
heavy_highway_traffic([duration: <time>]) [<with-block>]

Parameters

<time>
Is a single time value or a range with a time unit, such as [100..120]s.
<with-block>
Is a list of one or more keep() constraints or scenario modifiers, where the members are listed on separate lines as a block or on the same line as with: and separated by semi-colons.

Description

This scenario creates and moves the generated cars when called in a scenario. The generation_radius parameter defines the maximum distance from the origin vehicle (usually the SUT) where the cars can be generated. The distance must be greater than 0 meters and less than 1000 meters. The default is 50 meters.

There are two additional movement scenarios that inherit from random_traffic_car_group.group_drive():

  • random_traffic_car_group.light_highway_traffic() generates the cars within a radius of 500m from the referenced vehicle and constrains the longitudinal distance between the cars to [80..120]m.
  • random_traffic_car_group.heavy_highway_traffic() generates the cars within a radius of 500m from the referenced vehicle and constrains the longitudinal distance between the cars to [20..50]m.

Note

You must instantiate the random_traffic_car_group actor in a scenario in order to access the group_drive() scenario.

Example

For more information on how to configure random traffic see Configuring NPCs.

For more information on the random_traffic_car_group actor, see car_group actor.

OSC2 code: random_traffic.light_highway_traffic()
import "$FTX/config/sim/sumo_default.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 map = "$FTX_PACKAGES/maps/straight_long_road.xodr"

extend top.main:
    random_traffic: random_traffic_car_group with(origin_actor: sut.car)

    dm: sumo_idm_normal_driver
    for car in random_traffic.cars:
        keep(car.initial_bm == dm)

    do parallel(overlap:equal):
        dut_drive: sut.car.drive(duration: 10second) with:
            speed(20kph)
        random_traffic.light_highway_traffic()

common_route_car_group.group_drive()

Purpose

Moves a group of cars following a reference vehicle .

Category

Movement scenario (random_traffic actor)

Syntax

common_route_car_group.group_drive( [duration: <time>])[<with-block>]

Parameters

<time>
Is a single time value or a range with a time unit, such as [100..120]s.
<with-block>
Is a list of one or more keep() constraints or scenario modifiers, where the members are listed on separate lines as a block or on the same line as with: and separated by semi-colons.

Description

This scenario moves a group of cars in a single lane or all lanes of a highway following the movement of a leading vehicle .

Note

You must instantiate the common_route_car_group, the single_lane_car_group or the all_lanes_car_group actor in a scenario in order to access the group_drive() scenario.

Example

For more information on this example and how to configure random traffic see Configuring NPCs.

For more information on the random_traffic_car_group actor, see car_group actor.

OSC2 code: common_route_car_group.group_drive()
import "$FTX/config/sim/sumo_default.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 map = "$FTX_PACKAGES/maps/highway.xodr"

extend top.main:
    lead_vehicle: vehicle
    sut_cruise_speed: speed with:
      keep(default it == 90kph)
    hwy: highway
    car_group: single_lane_car_group with(reference_car: lead_vehicle):
        keep(it.cars.size() == 6)

    dm: sumo_idm_aggressive_driver
    for car in car_group.cars:
        keep(car.initial_bm == dm)

    do parallel(overlap:equal):
            lead_vehicle.drive() with:
                lane(side_of: sut.car)
                position(time: [2s..4.5s], ahead_of: sut.car, at: start)
                speed(speed: [-sut_cruise_speed+10kph..-sut_cruise_speed+20kph], 
                            faster_than: sut.car, track: projected, at: end)
                along(hwy)
            sut.car.drive() with:
                speed(speed: sut_cruise_speed)
                along(hwy)
            car_group_start: car_group.group_drive()
    with:
        duration([10..10]second)

person.move()

Purpose

Move a person from one position to another.

Category

Movement scenario of person

Syntax

move(end_position: <msp_position>,
    duration: <time> [,
    start_position: <msp_position> ])

Parameters

end_position: <msp_position>
The end location of the object for this move(). This parameter is required.
duration: <time>
Specifies the duration of the movement. This parameter is required.
start_position: <msp_position>
The starting position of the object. This parameter is required if this move() is not preceded by a previous move() or exists_at(). The default is null.

Description

This scenario moves a person to the specified location. If the current location is not known, because there is no previous move() or exists_at() of this object, the start_position parameter is required.

Example

Move a person across a vehicle's drive()