From a762135328f2c69f50fd184e208c14a821acd251 Mon Sep 17 00:00:00 2001 From: heuerfin <117280185+heuerfin@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:33:59 +0200 Subject: [PATCH] Implement variable frame rate (#1005) Replaced class variable frame_rate with an argument provided on the CLI. Co-authored-by: glopezdiest <58212725+glopezdiest@users.noreply.github.com> --- scenario_runner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scenario_runner.py b/scenario_runner.py index 07e635e19..b31c53d09 100755 --- a/scenario_runner.py +++ b/scenario_runner.py @@ -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 @@ -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) @@ -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') @@ -646,4 +647,4 @@ def main(): if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) \ No newline at end of file