Skip to content

Commit

Permalink
Removed perform_carla_tick from CarlaDataProvider
Browse files Browse the repository at this point in the history
* Removed perform_carla_tick from CarlaDataProvider, which was a workaround for missing timeout of CARLA tick() function
  • Loading branch information
glopezdiest authored Apr 29, 2020
1 parent e2c27b1 commit 3b1cb51
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 28 deletions.
1 change: 1 addition & 0 deletions Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added new criteria, ActorSpeedAboveThresholdTest, useful to check if the ego vehicle has been standing still for long periods of time.
* Setting up actors in batch now also randomizes their colors
* 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.
* Removed perform_carla_tick() function at CarlaDataProvider, which was a workaround for world.tick()
* **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:
- The path to the autoagents has changed from .../challenge/autoagents to .../autoagents
- The path to the route and scenario descriptions has changed from .../challenge to .../data
Expand Down
11 changes: 6 additions & 5 deletions scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _prepare_ego_vehicles(self, ego_vehicles):
self.ego_vehicles[i].set_transform(ego_vehicles[i].transform)

# sync state
CarlaDataProvider.perform_carla_tick()
CarlaDataProvider.get_world().tick()

def _analyze_scenario(self, config):
"""
Expand Down Expand Up @@ -285,19 +285,20 @@ def _load_and_wait_for_world(self, town, ego_vehicles=None):
break

self.world = self.client.get_world()
CarlaActorPool.set_client(self.client)
CarlaActorPool.set_world(self.world)
CarlaDataProvider.set_world(self.world)

if self._args.agent:
settings = self.world.get_settings()
settings.synchronous_mode = True
settings.fixed_delta_seconds = 1.0 / self.frame_rate
self.world.apply_settings(settings)

CarlaActorPool.set_client(self.client)
CarlaActorPool.set_world(self.world)
CarlaDataProvider.set_world(self.world)

# Wait for the world to be ready
if self.world.get_settings().synchronous_mode:
CarlaDataProvider.perform_carla_tick()
self.world.tick()
else:
self.world.wait_for_tick()

Expand Down
2 changes: 1 addition & 1 deletion srunner/autoagents/agent_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setup_sensors(self, vehicle, debug_mode=False):
while not self._agent.all_sensors_ready():
if debug_mode:
print(" waiting for one data reading from sensors...")
CarlaDataProvider.perform_carla_tick()
CarlaDataProvider.get_world().tick()

def cleanup(self):
"""
Expand Down
21 changes: 2 additions & 19 deletions srunner/scenariomanager/carla_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import math
import random
import re
from threading import Thread
from six import iteritems

import carla
Expand Down Expand Up @@ -89,22 +88,6 @@ def register_actors(actors):
for actor in actors:
CarlaDataProvider.register_actor(actor)

@staticmethod
def perform_carla_tick(timeout=5.0):
"""
Send tick() command to CARLA and wait for at
most timeout seconds to let tick() return
Note: This is a workaround as CARLA tick() has no
timeout functionality
"""
t = Thread(target=CarlaDataProvider._world.tick)
t.daemon = True
t.start()
t.join(float(timeout))
if t.is_alive():
raise RuntimeError("Timeout of CARLA tick command")

@staticmethod
def on_carla_tick():
"""
Expand Down Expand Up @@ -545,7 +528,7 @@ def handle_actor_batch(batch):

# wait for the actors to be spawned properly before we do anything
if sync_mode:
CarlaDataProvider.perform_carla_tick()
CarlaActorPool._world.tick()
else:
CarlaActorPool._world.wait_for_tick()

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

Expand Down
2 changes: 1 addition & 1 deletion srunner/scenariomanager/scenario_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _tick_scenario(self, timestamp):
self.ego_vehicles[0].apply_control(ego_action)

if self._agent and self._running and self._watchdog.get_status():
CarlaDataProvider.perform_carla_tick(self._timeout)
CarlaDataProvider.get_world().tick()

def get_running_status(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion srunner/scenarios/basic_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, name, ego_vehicles, config, world,
# Initializing adversarial actors
self._initialize_actors(config)
if world.get_settings().synchronous_mode:
CarlaDataProvider.perform_carla_tick()
world.tick()
else:
world.wait_for_tick()

Expand Down
2 changes: 1 addition & 1 deletion srunner/scenarios/route_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _build_scenario_instances(self, world, ego_vehicle, scenario_definitions, to
if scenario_number % scenarios_per_tick == 0:
sync_mode = world.get_settings().synchronous_mode
if sync_mode:
CarlaDataProvider.perform_carla_tick()
world.tick()
else:
world.wait_for_tick()

Expand Down

0 comments on commit 3b1cb51

Please sign in to comment.