def empty_scenarios(): with temp_scenario(name="straight", map="maps/straight.net.xml") as scenario_root: missions = [ t.Mission( t.Route(begin=("west", 1, 10), end=("east", 1, "max")), entry_tactic=t.TrapEntryTactic( wait_to_hijack_limit_s=3, zone=t.MapZone(start=("west", 0, 1), length=100, n_lanes=3), ), ) ] scenario = t.Scenario( traffic={}, ego_missions=missions, ) gen_scenario(scenario, output_dir=scenario_root) yield Scenario.variations_for_all_scenario_roots([str(scenario_root)], [AGENT_ID])
def scenarios(bubble): with temp_scenario(name="straight", map="maps/straight.net.xml") as scenario_root: 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) ] ) gen_scenario( t.Scenario(traffic={"all": traffic}, bubbles=[bubble]), output_dir=scenario_root, ) yield Scenario.variations_for_all_scenario_roots([str(scenario_root)], [])
def scenarios(bubbles, num_vehicles): with temp_scenario(name="6lane", map="maps/6lane.net.xml") as scenario_root: traffic = t.Traffic(flows=[ t.Flow( route=t.Route( begin=("edge-west-WE", lane, 0), end=("edge-east-WE", lane, "max"), ), rate=10, actors={t.TrafficActor(name="car"): 1}, ) for lane in range(num_vehicles) ]) gen_scenario( t.Scenario(traffic={"all": traffic}, bubbles=bubbles), output_dir=scenario_root, ) yield Scenario.variations_for_all_scenario_roots([str(scenario_root)], [])
def scenarios(): with temp_scenario(name="straight", map="maps/straight.net.xml") as scenario_root: ego_missions = [ # missions of laner and buddha t.Mission(t.Route( begin=("west", 0, 30), end=("east", 0, "max"), )), t.Mission(t.Route( begin=("west", 0, 40), end=("east", 0, "max"), )), ] gen_scenario( t.Scenario(ego_missions=ego_missions), output_dir=scenario_root, ) yield Scenario.variations_for_all_scenario_roots([str(scenario_root)], [AGENT_1, AGENT_2])
def scenario_root(): # TODO: We may want to consider referencing to concrete scenarios in our tests # rather than generating them. The benefit of generting however is that # we can change the test criteria and scenario code in unison. with temp_scenario(name="cycles", map="maps/6lane.net.xml") as scenario_root: actors = [ SocialAgentActor( name=f"non-interactive-agent-{speed}-v0", agent_locator="zoo.policies:non-interactive-agent-v0", policy_kwargs={"speed": speed}, ) for speed in [10, 30, 80] ] for name, (edge_start, edge_end) in [ ("group-1", ("edge-north-NS", "edge-south-NS")), ("group-2", ("edge-west-WE", "edge-east-WE")), ("group-3", ("edge-east-EW", "edge-west-EW")), ("group-4", ("edge-south-SN", "edge-north-SN")), ]: route = Route(begin=("edge-north-NS", 1, 0), end=("edge-south-NS", 1, "max")) missions = [Mission(route=route)] * 2 # double up gen_social_agent_missions( scenario_root, social_agent_actor=actors, name=name, missions=missions, ) gen_missions( scenario_root, missions=[ Mission( Route(begin=("edge-west-WE", 0, 0), end=("edge-east-WE", 0, "max"))) ], ) yield scenario_root
def scenarios(bubble): with temp_scenario(name="straight", map="maps/straight.net.xml") as scenario_root: gen_scenario( t.Scenario(traffic={}, bubbles=[bubble]), output_dir=scenario_root, ) yield Scenario.variations_for_all_scenario_roots([str(scenario_root)], [])