Skip to content

Commit 3b1cb51

Browse files
authored
Removed perform_carla_tick from CarlaDataProvider
* Removed perform_carla_tick from CarlaDataProvider, which was a workaround for missing timeout of CARLA tick() function
1 parent e2c27b1 commit 3b1cb51

File tree

7 files changed

+13
-28
lines changed

7 files changed

+13
-28
lines changed

Docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Added new criteria, ActorSpeedAboveThresholdTest, useful to check if the ego vehicle has been standing still for long periods of time.
2424
* Setting up actors in batch now also randomizes their colors
2525
* When running routes, the weather parameters of each route can now be changed at will. Check the first route at srunner/data/routes_training.xml to see the correct format to do so. By default the weather is now a sunny midday.
26+
* Removed perform_carla_tick() function at CarlaDataProvider, which was a workaround for world.tick()
2627
* **Important** All challenge related content has been removed. This functionality has been improved and is now part of the [Leaderboard](https://github.com/carla-simulator/leaderboard). As a consequence:
2728
- The path to the autoagents has changed from .../challenge/autoagents to .../autoagents
2829
- The path to the route and scenario descriptions has changed from .../challenge to .../data

scenario_runner.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def _prepare_ego_vehicles(self, ego_vehicles):
235235
self.ego_vehicles[i].set_transform(ego_vehicles[i].transform)
236236

237237
# sync state
238-
CarlaDataProvider.perform_carla_tick()
238+
CarlaDataProvider.get_world().tick()
239239

240240
def _analyze_scenario(self, config):
241241
"""
@@ -285,19 +285,20 @@ def _load_and_wait_for_world(self, town, ego_vehicles=None):
285285
break
286286

287287
self.world = self.client.get_world()
288-
CarlaActorPool.set_client(self.client)
289-
CarlaActorPool.set_world(self.world)
290-
CarlaDataProvider.set_world(self.world)
291288

292289
if self._args.agent:
293290
settings = self.world.get_settings()
294291
settings.synchronous_mode = True
295292
settings.fixed_delta_seconds = 1.0 / self.frame_rate
296293
self.world.apply_settings(settings)
297294

295+
CarlaActorPool.set_client(self.client)
296+
CarlaActorPool.set_world(self.world)
297+
CarlaDataProvider.set_world(self.world)
298+
298299
# Wait for the world to be ready
299300
if self.world.get_settings().synchronous_mode:
300-
CarlaDataProvider.perform_carla_tick()
301+
self.world.tick()
301302
else:
302303
self.world.wait_for_tick()
303304

srunner/autoagents/agent_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def setup_sensors(self, vehicle, debug_mode=False):
8484
while not self._agent.all_sensors_ready():
8585
if debug_mode:
8686
print(" waiting for one data reading from sensors...")
87-
CarlaDataProvider.perform_carla_tick()
87+
CarlaDataProvider.get_world().tick()
8888

8989
def cleanup(self):
9090
"""

srunner/scenariomanager/carla_data_provider.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import math
1616
import random
1717
import re
18-
from threading import Thread
1918
from six import iteritems
2019

2120
import carla
@@ -89,22 +88,6 @@ def register_actors(actors):
8988
for actor in actors:
9089
CarlaDataProvider.register_actor(actor)
9190

92-
@staticmethod
93-
def perform_carla_tick(timeout=5.0):
94-
"""
95-
Send tick() command to CARLA and wait for at
96-
most timeout seconds to let tick() return
97-
98-
Note: This is a workaround as CARLA tick() has no
99-
timeout functionality
100-
"""
101-
t = Thread(target=CarlaDataProvider._world.tick)
102-
t.daemon = True
103-
t.start()
104-
t.join(float(timeout))
105-
if t.is_alive():
106-
raise RuntimeError("Timeout of CARLA tick command")
107-
10891
@staticmethod
10992
def on_carla_tick():
11093
"""
@@ -545,7 +528,7 @@ def handle_actor_batch(batch):
545528

546529
# wait for the actors to be spawned properly before we do anything
547530
if sync_mode:
548-
CarlaDataProvider.perform_carla_tick()
531+
CarlaActorPool._world.tick()
549532
else:
550533
CarlaActorPool._world.wait_for_tick()
551534

@@ -597,7 +580,7 @@ def setup_actor(model, spawn_point, rolename='scenario', hero=False, autopilot=F
597580
pass
598581
# wait for the actor to be spawned properly before we do anything
599582
if CarlaActorPool._world.get_settings().synchronous_mode:
600-
CarlaDataProvider.perform_carla_tick()
583+
CarlaActorPool._world.tick()
601584
else:
602585
CarlaActorPool._world.wait_for_tick()
603586

srunner/scenariomanager/scenario_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def _tick_scenario(self, timestamp):
271271
self.ego_vehicles[0].apply_control(ego_action)
272272

273273
if self._agent and self._running and self._watchdog.get_status():
274-
CarlaDataProvider.perform_carla_tick(self._timeout)
274+
CarlaDataProvider.get_world().tick()
275275

276276
def get_running_status(self):
277277
"""

srunner/scenarios/basic_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, name, ego_vehicles, config, world,
4848
# Initializing adversarial actors
4949
self._initialize_actors(config)
5050
if world.get_settings().synchronous_mode:
51-
CarlaDataProvider.perform_carla_tick()
51+
world.tick()
5252
else:
5353
world.wait_for_tick()
5454

srunner/scenarios/route_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def _build_scenario_instances(self, world, ego_vehicle, scenario_definitions, to
447447
if scenario_number % scenarios_per_tick == 0:
448448
sync_mode = world.get_settings().synchronous_mode
449449
if sync_mode:
450-
CarlaDataProvider.perform_carla_tick()
450+
world.tick()
451451
else:
452452
world.wait_for_tick()
453453

0 commit comments

Comments
 (0)