From 69a407c7e2582db25a8357e89aaff6dec845fc91 Mon Sep 17 00:00:00 2001 From: David Heejong Park Date: Wed, 22 Feb 2023 12:18:21 +0100 Subject: [PATCH] Quarter Car update --- src/cosim/algorithm/ecco_algorithm.cpp | 2 +- .../ecco/quarter_truck/OspSystemStructure.xml | 12 +++++ tests/ecco_algorithm_multi_bond_test.cpp | 48 ++++++++++--------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/cosim/algorithm/ecco_algorithm.cpp b/src/cosim/algorithm/ecco_algorithm.cpp index 5eecfd74..76b03133 100644 --- a/src/cosim/algorithm/ecco_algorithm.cpp +++ b/src/cosim/algorithm/ecco_algorithm.cpp @@ -332,7 +332,7 @@ class ecco_algorithm::impl prev_error_estimate_ = error_estimate; const auto new_step_size = to_duration(new_step_size_gain * to_double_duration(stepSize, currentTime)); const auto actual_new_step_size = std::clamp(new_step_size, params.min_step_size, params.max_step_size); - // std::cout << "dP=" << sum_power_residual << " dE=" << energy_residual << " eps=" << error_estimate << " "; + // std::cout << to_double_time_point(currentTime) << " "<< max_power_residual << " " << error_estimate << " " << std::endl; // std::cout << "new step size: " << to_double_duration(actual_new_step_size, {}) << std::endl; return actual_new_step_size; } diff --git a/tests/data/ecco/quarter_truck/OspSystemStructure.xml b/tests/data/ecco/quarter_truck/OspSystemStructure.xml index 93fcacac..4eeef9f1 100644 --- a/tests/data/ecco/quarter_truck/OspSystemStructure.xml +++ b/tests/data/ecco/quarter_truck/OspSystemStructure.xml @@ -8,6 +8,12 @@ + + + + + + @@ -15,6 +21,12 @@ + + + + + + diff --git a/tests/ecco_algorithm_multi_bond_test.cpp b/tests/ecco_algorithm_multi_bond_test.cpp index c455020f..507430f0 100644 --- a/tests/ecco_algorithm_multi_bond_test.cpp +++ b/tests/ecco_algorithm_multi_bond_test.cpp @@ -24,7 +24,7 @@ int main() cosim::log::set_global_output_level(cosim::log::info); constexpr cosim::time_point startTime = cosim::to_time_point(0.0);; - constexpr cosim::time_point midTime = cosim::to_time_point(15.0); + constexpr cosim::time_point midTime = cosim::to_time_point(4.0); auto ecco_params = cosim::ecco_parameters{ 0.8, @@ -91,21 +91,24 @@ int main() auto file_obs = std::make_unique("./logDir", logXmlPath); execution.add_observer(std::move(file_obs)); - auto simResult = execution.simulate_until(midTime); - REQUIRE(simResult); + // auto simResult = execution.simulate_until(midTime); + // REQUIRE(simResult); + - /** // Add an observer that watches the last slave auto t_observer = std::make_shared(50000); execution.add_observer(t_observer); t_observer->start_observing(chassisVel); t_observer->start_observing(wheelCVel); - t_observer->start_observing(wheelGVel); - t_observer->start_observing(groundVel); + // t_observer->start_observing(wheelGVel); + // t_observer->start_observing(groundVel); t_observer->start_observing(chassisForce); t_observer->start_observing(wheelCForce); - t_observer->start_observing(wheelGForce); - t_observer->start_observing(groundForce); + // t_observer->start_observing(wheelGForce); + // t_observer->start_observing(groundForce); + + auto csv_observer = std::make_shared("."); + execution.add_observer(csv_observer); // Run simulation auto simResult = execution.simulate_until(midTime); @@ -136,20 +139,20 @@ int main() gsl::make_span(wheelCVels), gsl::make_span(steps), gsl::make_span(timeValues)); - t_observer->get_real_samples( - wheelGVel.simulator, - wheelGVel.reference, - 0, - gsl::make_span(wheelGVels), - gsl::make_span(steps), - gsl::make_span(timeValues)); - t_observer->get_real_samples( - groundVel.simulator, - groundVel.reference, - 0, - gsl::make_span(groundVels), - gsl::make_span(steps), - gsl::make_span(timeValues)); + // t_observer->get_real_samples( + // wheelGVel.simulator, + // wheelGVel.reference, + // 0, + // gsl::make_span(wheelGVels), + // gsl::make_span(steps), + // gsl::make_span(timeValues)); + // t_observer->get_real_samples( + // groundVel.simulator, + // groundVel.reference, + // 0, + // gsl::make_span(groundVels), + // gsl::make_span(steps), + // gsl::make_span(timeValues)); std::cout << "time,step #,stepsize,chassisVel,wheelCVel,wheelGVel,groundVel" << std::endl; @@ -163,7 +166,6 @@ int main() << "," << groundVels[i] << std::endl; } - **/ } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; return 1;