(c, car_agents, bike_agents, pedestrian_agents, destroy_list)
| 940 | |
| 941 | |
| 942 | def do_gamma(c, car_agents, bike_agents, pedestrian_agents, destroy_list): |
| 943 | agents = car_agents + bike_agents + pedestrian_agents |
| 944 | agents_lookup = {} |
| 945 | for agent in agents: |
| 946 | agents_lookup[agent.actor.id] = agent |
| 947 | |
| 948 | next_agents = [] |
| 949 | next_agent_gamma_ids = [] |
| 950 | new_destroy_list = [] |
| 951 | if len(agents) > 0: |
| 952 | gamma = carla.RVOSimulator() |
| 953 | |
| 954 | gamma_id = 0 |
| 955 | |
| 956 | # For external agents not tracked. |
| 957 | for actor in c.world.get_actors(): |
| 958 | if actor.id not in agents_lookup: |
| 959 | if isinstance(actor, carla.Vehicle): |
| 960 | if is_bike(actor): |
| 961 | type_tag = 'Bicycle' |
| 962 | else: |
| 963 | type_tag = 'Car' |
| 964 | bounding_box_corners = get_vehicle_bounding_box_corners(actor) |
| 965 | elif isinstance(actor, carla.Walker): |
| 966 | type_tag = 'People' |
| 967 | bounding_box_corners = get_pedestrian_bounding_box_corners(actor) |
| 968 | else: |
| 969 | continue |
| 970 | |
| 971 | gamma.add_agent(carla.AgentParams.get_default(type_tag), gamma_id) |
| 972 | gamma.set_agent_position(gamma_id, get_position(actor)) |
| 973 | gamma.set_agent_velocity(gamma_id, get_velocity(actor)) |
| 974 | gamma.set_agent_heading(gamma_id, get_forward_direction(actor)) |
| 975 | gamma.set_agent_bounding_box_corners(gamma_id, bounding_box_corners) |
| 976 | gamma.set_agent_pref_velocity(gamma_id, get_velocity(actor)) |
| 977 | gamma_id += 1 |
| 978 | |
| 979 | # For tracked agents. |
| 980 | for agent in agents: |
| 981 | actor = agent.actor |
| 982 | |
| 983 | # Declare variables. |
| 984 | is_valid = True |
| 985 | pref_vel = None |
| 986 | path_forward = None |
| 987 | bounding_box_corners = None |
| 988 | lane_constraints = None |
| 989 | |
| 990 | # Update path, check validity, process variables. |
| 991 | if agent.type_tag == 'Car' or agent.type_tag == 'Bicycle': |
| 992 | position = get_position(actor) |
| 993 | # Lane change if possible. |
| 994 | if c.rng.uniform(0.0, 1.0) <= c.args.lane_change_probability: |
| 995 | new_path_candidates = c.sumo_network.get_next_route_paths( |
| 996 | c.sumo_network.get_nearest_route_point(position), |
| 997 | agent.path.min_points - 1, agent.path.interval) |
| 998 | if len(new_path_candidates) > 0: |
| 999 | new_path = SumoNetworkAgentPath(c.rng.choice(new_path_candidates)[0:agent.path.min_points], |
no test coverage detected