def bubbles(): actor = t.SocialAgentActor( name="keep-lane-agent", agent_locator="zoo.policies:keep-lane-agent-v0", ) return [ t.Bubble( zone=t.PositionalZone(pos=(150, -60), size=(30, 30)), margin=10, actor=actor, ), t.Bubble( zone=t.PositionalZone(pos=(60, -60), size=(30, 30)), margin=10, actor=actor, ), ]
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", ), )
def bubble(request): """ |(93) |(95) (100) (105)| (107)| """ return t.Bubble( zone=t.PositionalZone(pos=(100, 0), size=(10, 10)), margin=2, limit=getattr(request, "param", t.BubbleLimits(10, 11)), actor=t.SocialAgentActor( name="zoo-car", agent_locator="zoo.policies:keep-lane-agent-v0"), )
"coach", "truck", "trailer", ] ]) laner_actor = t.SocialAgentActor( name="keep-lane-agent", agent_locator="zoo.policies:keep-lane-agent-v0", ) gen_scenario( t.Scenario( traffic={"basic": traffic}, social_agent_missions={ "all": ([laner_actor], [t.Mission(route=t.RandomRoute())]) }, bubbles=[ t.Bubble( zone=t.PositionalZone(pos=(50, 0), size=(10, 15)), margin=5, actor=laner_actor, follow_actor_id=t.Bubble.to_actor_id(laner_actor, mission_group="all"), follow_offset=(-7, 10), ), ], ), output_dir=Path(__file__).parent, )
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))
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)), 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))
actors={t.TrafficActor("car"): 1}, ), ]) agent_prefabs = "scenarios.intersections.4lane_t.agent_prefabs" bubbles = [ t.Bubble( zone=t.MapZone(start=("edge-west-WE", 0, 50), length=10, n_lanes=1), margin=2, actor=t.SocialAgentActor( name="zoo-agent", agent_locator=f"{agent_prefabs}:zoo-agent-v0", ), ), t.Bubble( zone=t.PositionalZone(pos=(100, 100), size=(20, 20)), margin=2, actor=t.SocialAgentActor( name="motion-planner-agent", agent_locator=f"{agent_prefabs}:motion-planner-agent-v0", ), ), ] ego_missions = [t.EndlessMission(begin=("edge-south-SN", 1, 20), )] social_agent_missions = { "all": ( [ t.SocialAgentActor(name="open-agent", agent_locator="open_agent:open_agent-v0"),
k=1, )[0], ): 1 }, ) for _ in range(NUM_TRAFFIC_FLOWS) ]) laner_actor = t.SocialAgentActor( name="keep-lane-agent", agent_locator="zoo.policies:keep-lane-agent-v0", ) travelling_bubbles = [ t.Bubble( zone=t.PositionalZone(pos=(50, 0), size=(10, 50)), margin=5, actor=laner_actor, follow_actor_id=t.Bubble.to_actor_id(laner_actor, mission_group="all"), follow_offset=(-7, 10), ) ] static_bubbles = [ t.Bubble( zone=t.MapZone((id_, 0, 10), 200, 1), margin=5, actor=laner_actor, ) for id_ in ["21675239", "126742590#1", "-77720372", "-263506114#6", "-33002812#1"] ] + [
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, ), ], ) gen_scenario(scenario, output_dir=str(Path(__file__).parent))