From 1c08f651d4b4c9139acd8a1ed0c043d38f71d5cf Mon Sep 17 00:00:00 2001 From: Daniel Santos-Olivan Date: Tue, 3 Nov 2020 17:00:52 +0100 Subject: [PATCH] Added warnings for substepping parameters. --- LibCarla/source/carla/client/detail/Simulator.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/LibCarla/source/carla/client/detail/Simulator.cpp b/LibCarla/source/carla/client/detail/Simulator.cpp index 758abb88a..04f05cc05 100644 --- a/LibCarla/source/carla/client/detail/Simulator.cpp +++ b/LibCarla/source/carla/client/detail/Simulator.cpp @@ -175,6 +175,21 @@ namespace detail { "synchronous mode enabled with variable delta seconds. It is highly " "recommended to set 'fixed_delta_seconds' when running on synchronous mode."); } + else if (settings.synchronous_mode && settings.substepping) { + if(settings.max_substeps < 1 || settings.max_substeps > 16) { + log_warning( + "synchronous mode and substepping are enabled but the number of substeps is not valid. " + "Please be aware that this value needs to be in the range [1-16]."); + } + float n_substeps = settings.fixed_delta_seconds.get() / settings.max_substep_delta_time; + + if (n_substeps > static_cast(settings.max_substeps)) { + log_warning( + "synchronous mode and substepping are enabled but the values for the simulation are not valid. " + "The values should fulfil fixed_delta_seconds <= max_substep_delta_time * max_substeps. " + "Be very careful about that, the time deltas are not guaranteed."); + } + } const auto frame = _client.SetEpisodeSettings(settings); using namespace std::literals::chrono_literals; SynchronizeFrame(frame, *_episode, 10s);