From 0ef9115d35c1f59bad01d4c860311708af06491d Mon Sep 17 00:00:00 2001 From: Fin Heuer Date: Wed, 26 Jul 2023 09:28:41 +0200 Subject: [PATCH] Implement variable frame rate Replaced class variable frame_rate with an argument provided on the CLI. --- scenario_runner.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scenario_runner.py b/scenario_runner.py index 5d2dd6015..da5fcc3ce 100755 --- a/scenario_runner.py +++ b/scenario_runner.py @@ -61,7 +61,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 @@ -327,7 +326,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) @@ -538,6 +537,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') @@ -616,4 +617,4 @@ def main(): if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) \ No newline at end of file