Skip to content

Commit

Permalink
Merge branch 'master' into spawn_actor-analogue
Browse files Browse the repository at this point in the history
  • Loading branch information
glopezdiest authored Apr 30, 2024
2 parents fa0e565 + 9d54467 commit 656728c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static_code_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand All @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Code Analysis
name: Unit Tests

on:
push:
Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down
7 changes: 4 additions & 3 deletions scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class ScenarioRunner(object):
# Tunable parameters
client_timeout = 10.0 # in seconds
wait_for_world = 20.0 # in seconds
frame_rate = 20.0 # in Hz

# CARLA world and scenario handlers
world = None
Expand Down Expand Up @@ -336,7 +335,7 @@ def _load_and_wait_for_world(self, town, ego_vehicles=None):
if self._args.sync:
settings = self.world.get_settings()
settings.synchronous_mode = True
settings.fixed_delta_seconds = 1.0 / self.frame_rate
settings.fixed_delta_seconds = 1.0 / self._args.frameRate
self.world.apply_settings(settings)

CarlaDataProvider.set_client(self.client)
Expand Down Expand Up @@ -566,6 +565,8 @@ def main():
parser.add_argument('--sync', action='store_true',
help='Forces the simulation to run synchronously')
parser.add_argument('--list', action="store_true", help='List all supported scenarios and exit')
parser.add_argument('--frameRate', default='20', type=float,
help='Frame rate (Hz) to use in \'sync\' mode (default: 20)')

parser.add_argument(
'--scenario', help='Name of the scenario to be executed. Use the preposition \'group:\' to run all scenarios of one class, e.g. ControlLoss or FollowLeadingVehicle')
Expand Down Expand Up @@ -646,4 +647,4 @@ def main():


if __name__ == "__main__":
sys.exit(main())
sys.exit(main())
4 changes: 2 additions & 2 deletions srunner/metrics/tools/metrics_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def parse_wheels_control(info):
max_brake_torque=float(info[11]),
max_handbrake_torque=float(info[13]),
position=carla.Vector3D(
x=float(info[17][1:-1]) / 100,
y=float(info[17][:-1]) / 100,
x=float(info[15][1:-1]) / 100,
y=float(info[16][:-1]) / 100,
z=float(info[17][:-1]) / 100)
)
return wheels_control
Expand Down
8 changes: 5 additions & 3 deletions srunner/scenariomanager/carla_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ def find_weather_presets():
"""
Get weather presets from CARLA
"""
def name(string):
return ' '.join(m.group(0) for m in rgx.finditer(string))

rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
name = lambda x: ' '.join(m.group(0) for m in rgx.finditer(x))
presets = [x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)]
return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets]

Expand Down Expand Up @@ -913,11 +915,11 @@ def request_new_batch_actors(model, amount, spawn_points, autopilot=False,
SetAutopilot(FutureActor, autopilot, CarlaDataProvider._traffic_manager_port)))

actors = CarlaDataProvider.handle_actor_batch(batch, tick)
for actor in actors:
for actor, command in zip(actors, batch):
if actor is None:
continue
CarlaDataProvider._carla_actor_pool[actor.id] = actor
CarlaDataProvider.register_actor(actor, spawn_point)
CarlaDataProvider.register_actor(actor, command.transform)

return actors

Expand Down
10 changes: 5 additions & 5 deletions srunner/scenariomanager/scenarioatomics/atomic_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ def initialise(self):
# At the moment everything besides "shortest" will use the CARLA GlobalPlanner
grp = CarlaDataProvider.get_global_route_planner()
route = []
for i, _ in enumerate(carla_route_elements):
if carla_route_elements[i][1] == "shortest":
route.append(carla_route_elements[i][0])
for i, element in enumerate(carla_route_elements):
if element[1] == "shortest":
route.append(element[0])
else:
if i == 0:
mmap = CarlaDataProvider.get_map()
Expand All @@ -812,12 +812,12 @@ def initialise(self):
waypoint = ego_next_wp.transform.location
else:
waypoint = carla_route_elements[i - 1][0].location
waypoint_next = carla_route_elements[i][0].location
waypoint_next = element[0].location
try:
interpolated_trace = grp.trace_route(waypoint, waypoint_next)
except networkx.NetworkXNoPath:
print("WARNING: No route from {} to {} - Using direct path instead".format(waypoint, waypoint_next))
route.append(carla_route_elements[i][0])
route.append(element[0])
continue
for wp_tuple in interpolated_trace:
# The router sometimes produces points that go backward, or are almost identical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def update(self):

velocity = CarlaDataProvider.get_velocity(self._actor)

if velocity > EPSILON:
if velocity > 0.1:
self._start_time = GameTime.get_time()

if GameTime.get_time() - self._start_time > self._duration:
Expand Down
6 changes: 3 additions & 3 deletions srunner/scenarios/open_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ def _create_behavior(self):
for actor in sequence.iter("Actors"):
for entity in actor.iter("EntityRef"):
entity_name = entity.attrib.get('entityRef', None)
for k, _ in enumerate(joint_actor_list):
if (joint_actor_list[k] and
entity_name == joint_actor_list[k].attributes['role_name']):
for k, actor in enumerate(joint_actor_list):
if (actor and
entity_name == actor.attributes['role_name']):
actor_ids.append(k)
break

Expand Down

0 comments on commit 656728c

Please sign in to comment.