From 982b5a2c937e3a49c5ded2f97ed8dc0c41293e1f Mon Sep 17 00:00:00 2001 From: Henning Classen Date: Thu, 4 Feb 2021 13:33:01 +0100 Subject: [PATCH] fixup! vtd: Enable VTD dynamics models --- plugins/vtd/src/vtd_binding.cpp | 22 ++++++++++++++++++---- plugins/vtd/src/vtd_conf.hpp | 5 +---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/vtd/src/vtd_binding.cpp b/plugins/vtd/src/vtd_binding.cpp index a97d9453b..bb6f19325 100644 --- a/plugins/vtd/src/vtd_binding.cpp +++ b/plugins/vtd/src/vtd_binding.cpp @@ -203,13 +203,15 @@ class VtdBinding : public cloe::Simulator { // Wait for creation of TaskControl client logger()->info("Wait for task control..."); - scp_try_read_until([this]() { return static_cast(task_control_); }); + // Expect task_control_ to be initialized in VtdBinding::apply_scp_rdb + scp_try_read_until([this]() { return task_control_ != nullptr; }); // Wait for selection of scenario (by GUI if not configured) if (!config_.scenario.size()) { logger()->info("Wait for scenario..."); - scp_try_read_until([this]() { return config_.scenario.size(); }); - // Stop to neutralize GUI's Init command sendt along with LoadScenario + // Expect the scenario to be initialized in VtdBinding::apply_scenario_filename() + scp_try_read_until([this]() { return config_.scenario != ""; }); + // Stop to neutralize GUI's Init command sent along with LoadScenario scp_client_->send(scp::Stop); } @@ -217,6 +219,8 @@ class VtdBinding : public cloe::Simulator { scp::QueryScenario query; query.scenario = config_.scenario; scp_client_->send(query); + // Expect the agents_expected_ array to be initialized in + // VtdBinding::apply_scp_scenario_response() scp_try_read_until([this]() { return !agents_expected_.empty(); }); // Load the scenario @@ -241,6 +245,7 @@ class VtdBinding : public cloe::Simulator { scp_client_->send(scp::InitOperation); // Wait for all agents' initialization + // Expect vehicles_ to be initialized in VtdBinding::apply_scp_set() scp_try_read_until([this]() { return agents_expected_.size() == vehicles_.size(); }); // Start the simulation @@ -250,7 +255,9 @@ class VtdBinding : public cloe::Simulator { scp_client_->send(scp::AckInit); // Continue reading until VTD is running + // Expect init_done_ to be set to true in VtdBinding::apply_scp_init_done() scp_try_read_until([this]() { return init_done_; }); + // Expect the operational_ flag to be set to true in VtdBinding::apply_scp_run() scp_try_read_until([this]() { return is_operational(); }); logger()->info("VTD Started."); @@ -461,7 +468,7 @@ class VtdBinding : public cloe::Simulator { * Waiting is limited to a number of retries until timeout. */ void scp_try_read_until(std::function pred) { - int tries_left = VTD_INIT_WAIT_RETRIES; + int tries_left = config_.connection.retry_attempts; while (!pred()) { this->readall_scp(); std::this_thread::sleep_for(cloe::Milliseconds{VTD_INIT_WAIT_SLEEP_MS}); @@ -620,6 +627,13 @@ class VtdBinding : public cloe::Simulator { } fs::path r; for (auto it = ++s; it != p.end(); ++it) r /= *it; + if (std::find(s, p.end(), "Scenarios") != p.end()) { + logger()->warn( + "Cannot determine the scenario directory unambiguously because" + "the chosen scenario path contains multiple 'Scenario/' elements:" + "{}", + p.native()); + } return r; } return p; diff --git a/plugins/vtd/src/vtd_conf.hpp b/plugins/vtd/src/vtd_conf.hpp index ec94ffa1e..a7a3a8f76 100644 --- a/plugins/vtd/src/vtd_conf.hpp +++ b/plugins/vtd/src/vtd_conf.hpp @@ -30,14 +30,11 @@ #include // for TcpTransceiverConfiguration, ... #include "osi_omni_sensor.hpp" // for SensorMockLevel -// Connection +// Connection / Initialization #define VTD_DEFAULT_SCP_PORT 48179 #define VTD_PARAMSERVER_PORT 54345 #define VTD_INIT_SYNC_SLEEP_MS 3000 - -// Scenario Loading #define VTD_INIT_WAIT_SLEEP_MS 200 -#define VTD_INIT_WAIT_RETRIES 300 namespace vtd {