示例#1
0
def bubble():
    return t.Bubble(
        zone=t.PositionalZone(pos=(100, 0), size=(20, 20)),
        margin=10,
        actor=t.BoidAgentActor(
            # TODO: Provide a more self-contained way to build agent locators for tests
            name="hive-mind",
            agent_locator="scenarios.straight.agent_prefabs:pose-boid-agent-v0",
        ),
    )
示例#2
0
from pathlib import Path

from smarts.sstudio import types as t
from smarts.sstudio import gen_scenario

trajectory_boid_agent = t.BoidAgentActor(
    name="trajectory-boid",
    agent_locator="scenarios.straight.agent_prefabs:trajectory-boid-agent-v0",
)

pose_boid_agent = t.BoidAgentActor(
    name="pose-boid",
    agent_locator="scenarios.straight.agent_prefabs:pose-boid-agent-v0",
)

traffic = t.Traffic(flows=[
    t.Flow(
        route=t.Route(
            begin=("west", lane_idx, 0),
            end=("east", lane_idx, "max"),
        ),
        rate=50,
        actors={t.TrafficActor("car"): 1},
    ) for lane_idx in range(3)
])

scenario = t.Scenario(
    traffic={"all": traffic},
    bubbles=[
        t.Bubble(
            zone=t.PositionalZone(pos=(50, 0), size=(40, 20)),
示例#3
0
def main(args):
    all_args = get_args(args)
    num_agents = all_args.num_agents
    num_lanes = all_args.num_lanes
    born_lane_id = all_args.born_lane_id
    born_position_offset = all_args.born_position_offset
    target_lane_id = all_args.target_lane_id
    target_position_offset = all_args.target_position_offset

    trajectory_boid_agent = t.BoidAgentActor(
        name="trajectory-boid",
        agent_locator="scenarios.straight.agent_prefabs:trajectory-boid-agent-v0",
    )

    pose_boid_agent = t.BoidAgentActor(
        name="pose-boid",
        agent_locator="scenarios.straight.agent_prefabs:pose-boid-agent-v0",
    )

    traffic = t.Traffic(
        flows=[
            t.Flow(
                route=t.Route(begin=("west", lane_idx, 0), end=("east", lane_idx, "max"),),
                rate=50,
                actors={t.TrafficActor("car"): 1},
            )
            for lane_idx in range(num_lanes)
        ]
    )

    assert len(target_position_offset) == len(born_position_offset) == num_agents, ("different number")
    assert num_lanes <= 3, ("number of lanes can not exceed 3")
    for _i in range(num_agents):
        assert (born_lane_id[_i]<=2), ("the born_land_id can not exceed 2.")
        assert (target_lane_id[_i]<=2), ("the target_land_id can not exceed 2.")
        if not born_position_offset[_i] in ["max", "random"]:
            assert int(born_position_offset[_i])<=100, ("the born_position_offset should use value 0~100 or max or random.")
        if not target_position_offset[_i] in ["max", "random"]:
            assert int(target_position_offset[_i])<=100, ("the target_position_offset should use value 0~100 or max or random.")
    print("pass the assertion")
    missions = [t.Mission(t.Route(begin=("west", born_lane_id[agent_idx], born_position_offset[agent_idx]), end=("east", target_lane_id[agent_idx], target_position_offset[agent_idx]))) for agent_idx in range(num_agents)]

    scenario = t.Scenario(
        traffic={"all": traffic},
        ego_missions=missions,
        bubbles=[
            t.Bubble(
                zone=t.PositionalZone(pos=(50, 0), size=(40, 20)),
                margin=5,
                actor=trajectory_boid_agent,
            ),
            t.Bubble(
                zone=t.PositionalZone(pos=(150, 0), size=(50, 20)),
                margin=5,
                actor=pose_boid_agent,
                keep_alive=True,
            ),
        ],
    )

    gen_scenario(scenario, output_dir=str(Path(__file__).parent))
示例#4
0
from pathlib import Path

from smarts.sstudio import types as t
from smarts.sstudio import gen_scenario

boid_agent = t.BoidAgentActor(
    name="hive-mind",
    agent_locator="scenarios.straight.agent_prefabs:boid-agent-v0",
)

traffic = t.Traffic(flows=[
    t.Flow(
        route=t.Route(
            begin=("west", lane_idx, 0),
            end=("east", lane_idx, "max"),
        ),
        rate=50,
        actors={
            t.TrafficActor("car"): 1,
        },
    ) for lane_idx in range(3)
])

scenario = t.Scenario(
    traffic={"all": traffic},
    bubbles=[
        t.Bubble(
            zone=t.PositionalZone(pos=(100, 0), size=(30, 20)),
            margin=5,
            actor=boid_agent,
        ),