Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALC fix #2

Merged
merged 3 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, *, client: carla.Client, cmd_for_changing_lane=ChauffeurComma
self._env_vehicle_column_ahead_range_m = (5, 30)

route_length_m = max(MAX_MANEUVER_LENGTH_M + BIRD_VIEW_HEIGHT_M,
max_env_vehicles_number * (MAX_VEHICLE_RANDOM_SPACE_M + VEHICLE_SLOT_LENGTH_M)) * 2
max_env_vehicles_number * (MAX_VEHICLE_RANDOM_SPACE_M + VEHICLE_SLOT_LENGTH_M)) * 3
self._topology = Topology(self._world_map)
self._routes: List[List[carla.Transform]] = self._obtain_routes(self._target_lane_waypoint, route_length_m)

Expand Down Expand Up @@ -115,13 +115,22 @@ def _spawn_env_vehicles(self, n: int):
blueprints = self._world.get_blueprint_library().filter('vehicle.*')
blueprints = [b for b in blueprints if int(b.get_attribute('number_of_wheels')) == 4]
spawn_points = self._world_map.get_spawn_points()
max_ticks = 4

def _get_env_vehicles():
return [
v for v in self._world.get_actors().filter('vehicle.*')
if v.attributes.get('role_name') != 'hero' and v.is_alive
]

def _wait_for_env_vehicles(total_number, max_ticks):
env_vehicles = _get_env_vehicles()
while len(env_vehicles) < total_number and max_ticks > 0:
self._world.tick()
max_ticks -= 1
env_vehicles = _get_env_vehicles()
return env_vehicles

env_vehicles = _get_env_vehicles()
missing_vehicles = n - len(env_vehicles)
while missing_vehicles:
Expand All @@ -131,7 +140,7 @@ def _get_env_vehicles():
random.sample(spawn_points, k=missing_vehicles))
]
self._client.apply_batch_sync(cmds, do_tick=True)
env_vehicles = _get_env_vehicles()
env_vehicles = _wait_for_env_vehicles(n, max_ticks)
missing_vehicles = n - len(env_vehicles)
return env_vehicles

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='carla_real_traffic_scenarios',
version='0.2.0',
version='0.2.1',
long_description=readme,
author='TODO',
author_email='TODO',
Expand Down