Skip to content

Commit

Permalink
Implement variable frame rate (#1005)
Browse files Browse the repository at this point in the history
Replaced class variable frame_rate with an argument provided on the CLI.

Co-authored-by: glopezdiest <[email protected]>
  • Loading branch information
heuerfin and glopezdiest committed Apr 26, 2024
1 parent 459eead commit a762135
Showing 1 changed file with 4 additions and 3 deletions.
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())

0 comments on commit a762135

Please sign in to comment.