From e1e5afef63420b6c1d59137456fed002e5add9cf Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 12:57:51 +0100 Subject: [PATCH 1/8] Remove unused initial_direction from C#. --- ksp_plugin/interface_body.hpp | 3 +-- ksp_plugin/interface_flight_plan.cpp | 6 ------ ksp_plugin_test/interface_flight_plan_test.cpp | 3 --- serialization/journal.proto | 1 - 4 files changed, 1 insertion(+), 12 deletions(-) diff --git a/ksp_plugin/interface_body.hpp b/ksp_plugin/interface_body.hpp index 1b092a5110..90c3fcdbac 100644 --- a/ksp_plugin/interface_body.hpp +++ b/ksp_plugin/interface_body.hpp @@ -144,8 +144,7 @@ inline bool operator==(NavigationManoeuvre const& left, NaNIndependentEq(left.time_of_half_delta_v, right.time_of_half_delta_v) && NaNIndependentEq(left.time_to_half_delta_v, - right.time_to_half_delta_v) && - left.inertial_direction == right.inertial_direction; + right.time_to_half_delta_v); } inline bool operator==(NavigationManoeuvreFrenetTrihedron const& left, diff --git a/ksp_plugin/interface_flight_plan.cpp b/ksp_plugin/interface_flight_plan.cpp index 6ca7b29fb6..69d2751f90 100644 --- a/ksp_plugin/interface_flight_plan.cpp +++ b/ksp_plugin/interface_flight_plan.cpp @@ -165,12 +165,6 @@ NavigationManoeuvre ToInterfaceNavigationManoeuvre( result.final_time = ToGameTime(plugin, manÅ“uvre.final_time()); result.time_of_half_delta_v = ToGameTime(plugin, manÅ“uvre.time_of_half_Δv()); result.time_to_half_delta_v = manÅ“uvre.time_to_half_Δv() / Second; - Vector const barycentric_inertial_direction = - manÅ“uvre.InertialDirection(); - Vector const world_inertial_direction = - plugin.renderer().BarycentricToWorld(plugin.PlanetariumRotation())( - barycentric_inertial_direction); - result.inertial_direction = ToXYZ(world_inertial_direction); return result; } diff --git a/ksp_plugin_test/interface_flight_plan_test.cpp b/ksp_plugin_test/interface_flight_plan_test.cpp index 5ca9a85eee..4ef52e42e4 100644 --- a/ksp_plugin_test/interface_flight_plan_test.cpp +++ b/ksp_plugin_test/interface_flight_plan_test.cpp @@ -263,9 +263,6 @@ TEST_F(InterfaceFlightPlanTest, FlightPlan) { EXPECT_EQ(20, navigation_manoeuvre.initial_mass_in_tonnes); EXPECT_THAT(navigation_manoeuvre.burn.specific_impulse_in_seconds_g0, AlmostEquals(30, 1)); - EXPECT_EQ(40, navigation_manoeuvre.inertial_direction.x); - EXPECT_EQ(50, navigation_manoeuvre.inertial_direction.y); - EXPECT_EQ(60, navigation_manoeuvre.inertial_direction.z); EXPECT_CALL(flight_plan, GetManÅ“uvre(3)) .WillOnce(ReturnRef(navigation_manÅ“uvre)); diff --git a/serialization/journal.proto b/serialization/journal.proto index 25b4d4b4e5..42f5192820 100644 --- a/serialization/journal.proto +++ b/serialization/journal.proto @@ -102,7 +102,6 @@ message NavigationManoeuvre { required double final_time = 6; required double time_of_half_delta_v = 7; required double time_to_half_delta_v = 8; - required XYZ inertial_direction = 9; } // Frenet trihedron at the beginning of the manœuvre. From 768890fedc71b072c13a9436ef3c19fe8d635855 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 14:36:13 +0100 Subject: [PATCH 2/8] Propagate flight plan adaptive step parameters all the way to the C# and back. --- journal/profiles.hpp | 1 + ksp_plugin/flight_plan.cpp | 18 +++++-- ksp_plugin/flight_plan.hpp | 6 ++- ksp_plugin/interface.hpp | 11 +++++ ksp_plugin/interface_body.hpp | 73 ++++++++++++++++++++++++++++ ksp_plugin/interface_flight_plan.cpp | 21 +++++--- ksp_plugin_adapter/flight_planner.cs | 2 +- serialization/journal.proto | 14 +++++- serialization/ksp_plugin.proto | 4 +- 9 files changed, 133 insertions(+), 17 deletions(-) diff --git a/journal/profiles.hpp b/journal/profiles.hpp index 1cfd21c3a8..4e17195a16 100644 --- a/journal/profiles.hpp +++ b/journal/profiles.hpp @@ -22,6 +22,7 @@ using interface::Burn; using interface::ConfigurationAccuracyParameters; using interface::ConfigurationAdaptiveStepParameters; using interface::ConfigurationFixedStepParameters; +using interface::FlightPlanAdaptiveStepParameters; using interface::KeplerianElements; using interface::Iterator; using interface::NavigationFrameParameters; diff --git a/ksp_plugin/flight_plan.cpp b/ksp_plugin/flight_plan.cpp index 9540685fa9..8e4118d0fc 100644 --- a/ksp_plugin/flight_plan.cpp +++ b/ksp_plugin/flight_plan.cpp @@ -181,16 +181,28 @@ FlightPlan::adaptive_step_parameters() const { return adaptive_step_parameters_; } +Ephemeris::GeneralizedAdaptiveStepParameters const& +FlightPlan::generalized_adaptive_step_parameters() const { + return generalized_adaptive_step_parameters_; +} + bool FlightPlan::SetAdaptiveStepParameters( Ephemeris::AdaptiveStepParameters const& - adaptive_step_parameters) { + adaptive_step_parameters, + Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters) { auto const original_adaptive_step_parameters = adaptive_step_parameters_; + auto const original_generalized_adaptive_step_parameters = + generalized_adaptive_step_parameters_; adaptive_step_parameters_ = adaptive_step_parameters; + generalized_adaptive_step_parameters_ = generalized_adaptive_step_parameters; if (RecomputeSegments()) { return true; } else { // If the recomputation fails, leave this place as clean as we found it. adaptive_step_parameters_ = original_adaptive_step_parameters; + generalized_adaptive_step_parameters_ = + original_generalized_adaptive_step_parameters; CHECK(RecomputeSegments()); return false; } @@ -245,11 +257,11 @@ std::unique_ptr FlightPlan::ReadFromMessage( Ephemeris::AdaptiveStepParameters::ReadFromMessage( message.adaptive_step_parameters())); - bool const is_pre_εὔδοξος = + bool const is_pre_erdÅ‘s = !message.has_generalized_adaptive_step_parameters(); std::unique_ptr::GeneralizedAdaptiveStepParameters> generalized_adaptive_step_parameters; - if (is_pre_εὔδοξος) { + if (is_pre_erdÅ‘s) { generalized_adaptive_step_parameters = std::make_unique< Ephemeris::GeneralizedAdaptiveStepParameters>( EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator< diff --git a/ksp_plugin/flight_plan.hpp b/ksp_plugin/flight_plan.hpp index 09a7dc982f..816c46ebf0 100644 --- a/ksp_plugin/flight_plan.hpp +++ b/ksp_plugin/flight_plan.hpp @@ -82,13 +82,17 @@ class FlightPlan { virtual Ephemeris::AdaptiveStepParameters const& adaptive_step_parameters() const; + virtual Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters() const; // Sets the parameters used to compute the trajectories. The trajectories are // recomputed. Returns false (and doesn't change this object) if the // parameters would make it impossible to recompute the trajectories. virtual bool SetAdaptiveStepParameters( Ephemeris::AdaptiveStepParameters const& - adaptive_step_parameters); + adaptive_step_parameters, + Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters); // Returns the number of trajectory segments in this object. virtual int number_of_segments() const; diff --git a/ksp_plugin/interface.hpp b/ksp_plugin/interface.hpp index 248e2276b7..e5084a3403 100644 --- a/ksp_plugin/interface.hpp +++ b/ksp_plugin/interface.hpp @@ -74,6 +74,8 @@ void CDECL principia__InitGoogleLogging(); bool operator==(AdaptiveStepParameters const& left, AdaptiveStepParameters const& right); bool operator==(Burn const& left, Burn const& right); +bool operator==(FlightPlanAdaptiveStepParameters const& left, + FlightPlanAdaptiveStepParameters const& right); bool operator==(NavigationFrameParameters const& left, NavigationFrameParameters const& right); bool operator==(NavigationManoeuvre const& left, @@ -90,6 +92,10 @@ bool operator==(XYZ const& left, XYZ const& right); physics::Ephemeris::AdaptiveStepParameters FromAdaptiveStepParameters( AdaptiveStepParameters const& adaptive_step_parameters); +std::pair::AdaptiveStepParameters, + physics::Ephemeris::GeneralizedAdaptiveStepParameters> +FromFlightPlanAdaptiveStepParameters(FlightPlanAdaptiveStepParameters const& + flight_plan_adaptive_step_parameters); template T FromQP(QP const& qp); @@ -114,6 +120,11 @@ FromXYZ>>(XYZ const& xyz); AdaptiveStepParameters ToAdaptiveStepParameters( physics::Ephemeris::AdaptiveStepParameters const& adaptive_step_parameters); +FlightPlanAdaptiveStepParameters ToFlightPlanAdaptiveStepParameters( + physics::Ephemeris::AdaptiveStepParameters const& + adaptive_step_parameters, + physics::Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters); KeplerianElements ToKeplerianElements( physics::KeplerianElements const& keplerian_elements); diff --git a/ksp_plugin/interface_body.hpp b/ksp_plugin/interface_body.hpp index 90c3fcdbac..61c41773d0 100644 --- a/ksp_plugin/interface_body.hpp +++ b/ksp_plugin/interface_body.hpp @@ -123,6 +123,18 @@ inline bool operator==(Burn const& left, Burn const& right) { left.delta_v == right.delta_v; } +inline bool operator==(FlightPlanAdaptiveStepParameters const& left, + FlightPlanAdaptiveStepParameters const& right) { + return left.integrator_kind == right.integrator_kind && + left.generalized_integrator_kind == + right.generalized_integrator_kind && + left.max_steps == right.max_steps && + NaNIndependentEq(left.length_integration_tolerance, + right.length_integration_tolerance) && + NaNIndependentEq(left.speed_integration_tolerance, + right.speed_integration_tolerance); +} + inline bool operator==(NavigationFrameParameters const& left, NavigationFrameParameters const& right) { return left.extension == right.extension && @@ -196,6 +208,49 @@ FromAdaptiveStepParameters( adaptive_step_parameters.speed_integration_tolerance * (Metre / Second)); } +inline std::pair< + physics::Ephemeris::AdaptiveStepParameters, + physics::Ephemeris::GeneralizedAdaptiveStepParameters> +FromFlightPlanAdaptiveStepParameters(FlightPlanAdaptiveStepParameters const& + flight_plan_adaptive_step_parameters) { + serialization::AdaptiveStepSizeIntegrator message1; + CHECK(serialization::AdaptiveStepSizeIntegrator::Kind_IsValid( + flight_plan_adaptive_step_parameters.integrator_kind)); + message1.set_kind( + static_cast( + flight_plan_adaptive_step_parameters.integrator_kind)); + + serialization::AdaptiveStepSizeIntegrator message2; + CHECK(serialization::AdaptiveStepSizeIntegrator::Kind_IsValid( + flight_plan_adaptive_step_parameters.generalized_integrator_kind)); + message1.set_kind( + static_cast( + flight_plan_adaptive_step_parameters.generalized_integrator_kind)); + + auto const max_steps = flight_plan_adaptive_step_parameters.max_steps; + auto const length_integration_tolerance = + flight_plan_adaptive_step_parameters.length_integration_tolerance * Metre; + auto const speed_integration_tolerance = + flight_plan_adaptive_step_parameters.speed_integration_tolerance * + (Metre / Second); + + auto const adaptive_step_parameters = + Ephemeris::AdaptiveStepParameters( + AdaptiveStepSizeIntegrator:: + NewtonianMotionEquation>::ReadFromMessage(message1), + max_steps, + length_integration_tolerance, + speed_integration_tolerance); + auto const generalized_adaptive_step_parameters = + Ephemeris::GeneralizedAdaptiveStepParameters( + AdaptiveStepSizeIntegrator:: + GeneralizedNewtonianMotionEquation>::ReadFromMessage(message2), + max_steps, + length_integration_tolerance, + speed_integration_tolerance); + return {adaptive_step_parameters, generalized_adaptive_step_parameters}; +} + template<> inline DegreesOfFreedom FromQP(QP const& qp) { return QPConverter>::FromQP(qp); @@ -238,6 +293,24 @@ inline AdaptiveStepParameters ToAdaptiveStepParameters( (Metre / Second)}; } +inline FlightPlanAdaptiveStepParameters ToFlightPlanAdaptiveStepParameters( + physics::Ephemeris::AdaptiveStepParameters const& + adaptive_step_parameters, + physics::Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters) { + serialization::AdaptiveStepSizeIntegrator message1; + adaptive_step_parameters.integrator().WriteToMessage(&message1); + serialization::AdaptiveStepSizeIntegrator message2; + generalized_adaptive_step_parameters.integrator().WriteToMessage(&message2); + // TODO(phl): Should we CHECK that the fields are consistent? + return {message1.kind(), + message2.kind(), + adaptive_step_parameters.max_steps(), + adaptive_step_parameters.length_integration_tolerance() / Metre, + adaptive_step_parameters.speed_integration_tolerance() / + (Metre / Second)}; +} + inline KeplerianElements ToKeplerianElements( physics::KeplerianElements const& keplerian_elements) { return {*keplerian_elements.eccentricity, diff --git a/ksp_plugin/interface_flight_plan.cpp b/ksp_plugin/interface_flight_plan.cpp index 69d2751f90..09c41d503e 100644 --- a/ksp_plugin/interface_flight_plan.cpp +++ b/ksp_plugin/interface_flight_plan.cpp @@ -210,14 +210,17 @@ bool principia__FlightPlanExists( return m.Return(plugin->GetVessel(vessel_guid)->has_flight_plan()); } -AdaptiveStepParameters principia__FlightPlanGetAdaptiveStepParameters( +FlightPlanAdaptiveStepParameters +principia__FlightPlanGetAdaptiveStepParameters( Plugin const* const plugin, char const* const vessel_guid) { journal::Method m( {plugin, vessel_guid}); CHECK_NOTNULL(plugin); - return m.Return(ToAdaptiveStepParameters( - GetFlightPlan(*plugin, vessel_guid).adaptive_step_parameters())); + auto const& flight_plan = GetFlightPlan(*plugin, vessel_guid); + return m.Return(ToFlightPlanAdaptiveStepParameters( + flight_plan.adaptive_step_parameters(), + flight_plan.generalized_adaptive_step_parameters())); } double principia__FlightPlanGetActualFinalTime(Plugin const* const plugin, @@ -456,14 +459,16 @@ bool principia__FlightPlanReplaceLast(Plugin const* const plugin, bool principia__FlightPlanSetAdaptiveStepParameters( Plugin const* const plugin, char const* const vessel_guid, - AdaptiveStepParameters const adaptive_step_parameters) { + FlightPlanAdaptiveStepParameters const + flight_plan_adaptive_step_parameters) { journal::Method m( - {plugin, vessel_guid, adaptive_step_parameters}); + {plugin, vessel_guid, flight_plan_adaptive_step_parameters}); CHECK_NOTNULL(plugin); + auto const parameters = FromFlightPlanAdaptiveStepParameters( + flight_plan_adaptive_step_parameters); return m.Return( - GetFlightPlan(*plugin, vessel_guid). - SetAdaptiveStepParameters( - FromAdaptiveStepParameters(adaptive_step_parameters))); + GetFlightPlan(*plugin, vessel_guid). + SetAdaptiveStepParameters(parameters.first, parameters.second)); } bool principia__FlightPlanSetDesiredFinalTime(Plugin const* const plugin, diff --git a/ksp_plugin_adapter/flight_planner.cs b/ksp_plugin_adapter/flight_planner.cs index 12c6dd2822..a602a7d539 100644 --- a/ksp_plugin_adapter/flight_planner.cs +++ b/ksp_plugin_adapter/flight_planner.cs @@ -121,7 +121,7 @@ private void RenderPlanner(int window_id) { actual_final_time - plugin_.FlightPlanGetInitialTime(vessel_guid)))); - AdaptiveStepParameters parameters = + FlightPlanAdaptiveStepParameters parameters = plugin_.FlightPlanGetAdaptiveStepParameters(vessel_guid); using (new HorizontalLayout()) { diff --git a/serialization/journal.proto b/serialization/journal.proto index 42f5192820..c7d4b9bd00 100644 --- a/serialization/journal.proto +++ b/serialization/journal.proto @@ -83,6 +83,15 @@ message ConfigurationAdaptiveStepParameters { required string speed_integration_tolerance = 3; } +message FlightPlanAdaptiveStepParameters { + // Corresponds to AdaptiveStepSizeIntegrator.Kind. + required int64 integrator_kind = 4; + required int64 generalized_integrator_kind = 5; + required int64 max_steps = 1; + required double length_integration_tolerance = 2; + required double speed_integration_tolerance = 3; +} + message KeplerianElements { required double eccentricity = 1; required double semimajor_axis = 2 [default = nan]; // Optional. @@ -510,7 +519,7 @@ message FlightPlanGetAdaptiveStepParameters { required string vessel_guid = 2; } message Return { - required AdaptiveStepParameters result = 1; + required FlightPlanAdaptiveStepParameters result = 1; } optional In in = 1; optional Return return = 3; @@ -769,7 +778,8 @@ message FlightPlanSetAdaptiveStepParameters { required fixed64 plugin = 1 [(pointer_to) = "Plugin const", (is_subject) = true]; required string vessel_guid = 2; - required AdaptiveStepParameters adaptive_step_parameters = 3; + required FlightPlanAdaptiveStepParameters + flight_plan_adaptive_step_parameters = 3; } message Return { required bool result = 1; diff --git a/serialization/ksp_plugin.proto b/serialization/ksp_plugin.proto index 9c7b1de589..233b22adb1 100644 --- a/serialization/ksp_plugin.proto +++ b/serialization/ksp_plugin.proto @@ -22,8 +22,8 @@ message FlightPlan { required Point desired_final_time = 3; repeated Manoeuvre manoeuvre = 8; required Ephemeris.AdaptiveStepParameters adaptive_step_parameters = 11; - required Ephemeris.AdaptiveStepParameters - generalized_adaptive_step_parameters = 13; + optional Ephemeris.AdaptiveStepParameters + generalized_adaptive_step_parameters = 13; // Added in ErdÅ‘s. // Pre-Cardano. reserved 4, 5, 6, 7; From 81449f93ce9f93f6555aa1e54f395bc3ba6baa3a Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 14:40:19 +0100 Subject: [PATCH 3/8] Compatibility value. --- ksp_plugin/flight_plan.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ksp_plugin/flight_plan.cpp b/ksp_plugin/flight_plan.cpp index 8e4118d0fc..279e44f456 100644 --- a/ksp_plugin/flight_plan.cpp +++ b/ksp_plugin/flight_plan.cpp @@ -7,6 +7,7 @@ #include "integrators/embedded_explicit_generalized_runge_kutta_nyström_integrator.hpp" #include "integrators/embedded_explicit_runge_kutta_nyström_integrator.hpp" #include "integrators/methods.hpp" +#include "ksp_plugin/integrators.hpp" #include "testing_utilities/make_not_null.hpp" namespace principia { @@ -264,12 +265,7 @@ std::unique_ptr FlightPlan::ReadFromMessage( if (is_pre_erdÅ‘s) { generalized_adaptive_step_parameters = std::make_unique< Ephemeris::GeneralizedAdaptiveStepParameters>( - EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator< - Fine1987RKNG34, - Position>(), - /*max_steps=*/1, - /*length_integration_tolerance=*/1 * Metre, - /*speed_integration_tolerance=*/1 * Metre / Second); + DefaultBurnParameters()); } else { generalized_adaptive_step_parameters = std::make_unique< Ephemeris::GeneralizedAdaptiveStepParameters>( From 55f7b0c140b3c46086c598f28c194bf5dda970ca Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 14:51:50 +0100 Subject: [PATCH 4/8] Remove the prediction parameters --- ksp_plugin/plugin.cpp | 38 +++++++++------------------------- ksp_plugin/plugin.hpp | 9 +------- serialization/ksp_plugin.proto | 4 +++- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/ksp_plugin/plugin.cpp b/ksp_plugin/plugin.cpp index 8d409bd38b..142863475f 100644 --- a/ksp_plugin/plugin.cpp +++ b/ksp_plugin/plugin.cpp @@ -108,7 +108,6 @@ Plugin::Plugin(std::string const& game_epoch, Angle const& planetarium_rotation) : history_parameters_(DefaultHistoryParameters()), psychohistory_parameters_(DefaultPsychohistoryParameters()), - prediction_parameters_(DefaultPredictionParameters()), vessel_thread_pool_( /*pool_size=*/2 * std::thread::hardware_concurrency()), planetarium_rotation_(planetarium_rotation), @@ -374,12 +373,13 @@ void Plugin::InsertOrKeepVessel(GUID const& vessel_guid, auto it = vessels_.find(vessel_guid); if (it == vessels_.end()) { std::tie(it, inserted) = - vessels_.emplace(vessel_guid, - make_not_null_unique(vessel_guid, - vessel_name, - parent, - ephemeris_.get(), - prediction_parameters_)); + vessels_.emplace( + vessel_guid, + make_not_null_unique(vessel_guid, + vessel_name, + parent, + ephemeris_.get(), + DefaultPredictionParameters())); } else { inserted = false; } @@ -855,7 +855,7 @@ void Plugin::CreateFlightPlan(GUID const& vessel_guid, FindOrDie(vessels_, vessel_guid)->CreateFlightPlan( final_time, initial_mass, - prediction_parameters_, + DefaultPredictionParameters(), DefaultBurnParameters()); } @@ -940,16 +940,6 @@ void Plugin::ComputeAndRenderNodes( PlanetariumRotation()); } -void Plugin::SetPredictionAdaptiveStepParameters( - Ephemeris::AdaptiveStepParameters const& - prediction_adaptive_step_parameters) { - prediction_parameters_ = prediction_adaptive_step_parameters; - for (auto const& pair : vessels_) { - not_null> const& vessel = pair.second; - vessel->set_prediction_adaptive_step_parameters(prediction_parameters_); - } -} - bool Plugin::HasCelestial(Index const index) const { return Contains(celestials_, index); } @@ -1252,8 +1242,6 @@ void Plugin::WriteToMessage( history_parameters_.WriteToMessage(message->mutable_history_parameters()); psychohistory_parameters_.WriteToMessage( message->mutable_psychohistory_parameters()); - prediction_parameters_.WriteToMessage( - message->mutable_prediction_parameters()); planetarium_rotation_.WriteToMessage(message->mutable_planetarium_rotation()); game_epoch_.WriteToMessage(message->mutable_game_epoch()); @@ -1277,13 +1265,9 @@ not_null> Plugin::ReadFromMessage( auto const psychohistory_parameters = Ephemeris::AdaptiveStepParameters::ReadFromMessage( message.psychohistory_parameters()); - auto const prediction_parameters = - Ephemeris::AdaptiveStepParameters::ReadFromMessage( - message.prediction_parameters()); not_null> plugin = std::unique_ptr(new Plugin(history_parameters, - psychohistory_parameters, - prediction_parameters)); + psychohistory_parameters)); plugin->ephemeris_ = Ephemeris::ReadFromMessage(message.ephemeris()); @@ -1396,11 +1380,9 @@ not_null> Plugin::ReadFromMessage( Plugin::Plugin( Ephemeris::FixedStepParameters const& history_parameters, Ephemeris::AdaptiveStepParameters const& - psychohistory_parameters, - Ephemeris::AdaptiveStepParameters const& prediction_parameters) + psychohistory_parameters) : history_parameters_(history_parameters), psychohistory_parameters_(psychohistory_parameters), - prediction_parameters_(prediction_parameters), vessel_thread_pool_( /*pool_size=*/2 * std::thread::hardware_concurrency()) {} diff --git a/ksp_plugin/plugin.hpp b/ksp_plugin/plugin.hpp index cbe060993d..9ec53cf29f 100644 --- a/ksp_plugin/plugin.hpp +++ b/ksp_plugin/plugin.hpp @@ -353,10 +353,6 @@ class Plugin { std::unique_ptr>& ascending, std::unique_ptr>& descending) const; - virtual void SetPredictionAdaptiveStepParameters( - Ephemeris::AdaptiveStepParameters const& - prediction_adaptive_step_parameters); - virtual bool HasCelestial(Index index) const; virtual Celestial const& GetCelestial(Index index) const; @@ -435,9 +431,7 @@ class Plugin { // This constructor should only be used during deserialization. Plugin(Ephemeris::FixedStepParameters const& history_parameters, Ephemeris::AdaptiveStepParameters const& - psychohistory_parameters, - Ephemeris::AdaptiveStepParameters const& - prediction_parameters); + psychohistory_parameters); void InitializeIndices( std::string const& name, @@ -500,7 +494,6 @@ class Plugin { // The parameters for computing the various trajectories. Ephemeris::FixedStepParameters history_parameters_; Ephemeris::AdaptiveStepParameters psychohistory_parameters_; - Ephemeris::AdaptiveStepParameters prediction_parameters_; // The thread pool for advancing vessels. ThreadPool vessel_thread_pool_; diff --git a/serialization/ksp_plugin.proto b/serialization/ksp_plugin.proto index 233b22adb1..11176b288c 100644 --- a/serialization/ksp_plugin.proto +++ b/serialization/ksp_plugin.proto @@ -103,7 +103,6 @@ message Plugin { required Ephemeris ephemeris = 7; required Ephemeris.FixedStepParameters history_parameters = 12; required Ephemeris.AdaptiveStepParameters psychohistory_parameters = 13; - required Ephemeris.AdaptiveStepParameters prediction_parameters = 14; required Quantity planetarium_rotation = 4; required Point game_epoch = 15; required Point current_time = 5; @@ -121,6 +120,9 @@ message Plugin { // Pre-Bourbaki. reserved 2; reserved "/*celestial*/"; + // Pre-Erdos. + reserved 14; + reserved "prediction_parameters"; } // Added in Cauchy. From acadab593d83caf0ca1a356cc1e0da2fa2bd414f Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 15:03:04 +0100 Subject: [PATCH 5/8] Fix the tests. --- ksp_plugin_test/flight_plan_test.cpp | 14 ++++++++++++++ ksp_plugin_test/interface_flight_plan_test.cpp | 3 ++- ksp_plugin_test/plugin_integration_test.cpp | 8 -------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ksp_plugin_test/flight_plan_test.cpp b/ksp_plugin_test/flight_plan_test.cpp index c39dee1963..d6e39e52d7 100644 --- a/ksp_plugin_test/flight_plan_test.cpp +++ b/ksp_plugin_test/flight_plan_test.cpp @@ -424,6 +424,13 @@ TEST_F(FlightPlanTest, SetAdaptiveStepParameter) { Position>(), /*max_steps=*/1, /*length_integration_tolerance=*/1 * Milli(Metre), + /*speed_integration_tolerance=*/1 * Milli(Metre) / Second), + Ephemeris::GeneralizedAdaptiveStepParameters( + EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator< + Fine1987RKNG34, + Position>(), + /*max_steps=*/1, + /*length_integration_tolerance=*/1 * Milli(Metre), /*speed_integration_tolerance=*/1 * Milli(Metre) / Second))); EXPECT_EQ(5, flight_plan_->number_of_segments()); @@ -439,6 +446,13 @@ TEST_F(FlightPlanTest, SetAdaptiveStepParameter) { Position>(), /*max_steps=*/10000, /*length_integration_tolerance=*/1 * Milli(Metre), + /*speed_integration_tolerance=*/1 * Milli(Metre) / Second), + Ephemeris::GeneralizedAdaptiveStepParameters( + EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator< + Fine1987RKNG34, + Position>(), + /*max_steps=*/1, + /*length_integration_tolerance=*/1 * Milli(Metre), /*speed_integration_tolerance=*/1 * Milli(Metre) / Second))); EXPECT_EQ(5, flight_plan_->number_of_segments()); diff --git a/ksp_plugin_test/interface_flight_plan_test.cpp b/ksp_plugin_test/interface_flight_plan_test.cpp index 4ef52e42e4..68efda4940 100644 --- a/ksp_plugin_test/interface_flight_plan_test.cpp +++ b/ksp_plugin_test/interface_flight_plan_test.cpp @@ -176,8 +176,9 @@ TEST_F(InterfaceFlightPlanTest, FlightPlan) { /*speed_integration_tolerance=*/333 * Metre / Second); EXPECT_CALL(flight_plan, adaptive_step_parameters()) .WillOnce(ReturnRef(adaptive_step_parameters)); - AdaptiveStepParameters expected_adaptive_step_parameters = { + FlightPlanAdaptiveStepParameters expected_adaptive_step_parameters = { /*integrator_kind=*/1, + /*generalized_integrator_kind=*/2, /*max_step=*/111, /*length_integration_tolerance=*/222, /*speed_integration_tolerance=*/333}; diff --git a/ksp_plugin_test/plugin_integration_test.cpp b/ksp_plugin_test/plugin_integration_test.cpp index ba644b1669..061d277f2c 100644 --- a/ksp_plugin_test/plugin_integration_test.cpp +++ b/ksp_plugin_test/plugin_integration_test.cpp @@ -700,14 +700,6 @@ TEST_F(PluginIntegrationTest, Prediction) { plugin.renderer().SetPlottingFrame( plugin.NewBodyCentredNonRotatingNavigationFrame(celestial)); - Ephemeris::AdaptiveStepParameters adaptive_step_parameters( - EmbeddedExplicitRungeKuttaNyströmIntegrator< - DormandالمكاوىPrince1986RKN434FM, - Position>(), - /*max_steps=*/14, - /*length_integration_tolerance=*/1 * Milli(Metre), - /*speed_integration_tolerance=*/1 * Milli(Metre) / Second); - plugin.SetPredictionAdaptiveStepParameters(adaptive_step_parameters); plugin.AdvanceTime(Instant() + 1e-10 * Second, 0 * Radian); plugin.UpdatePrediction(vessel_guid); auto const& prediction = From 5fdbfe8d2a450ad98b8dbb2f7138d02daf2d4b73 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 15:20:23 +0100 Subject: [PATCH 6/8] Fix 2 failures. --- ksp_plugin/interface_body.hpp | 2 +- .../interface_flight_plan_test.cpp | 1 + ksp_plugin_test/plugin_integration_test.cpp | 9 + ksp_plugin_test/simple_plugin.proto.bin | Bin 21844 -> 21807 bytes ksp_plugin_test/simple_plugin.proto.hex | 203 +++++++++--------- 5 files changed, 112 insertions(+), 103 deletions(-) diff --git a/ksp_plugin/interface_body.hpp b/ksp_plugin/interface_body.hpp index 61c41773d0..1011fe04a9 100644 --- a/ksp_plugin/interface_body.hpp +++ b/ksp_plugin/interface_body.hpp @@ -223,7 +223,7 @@ FromFlightPlanAdaptiveStepParameters(FlightPlanAdaptiveStepParameters const& serialization::AdaptiveStepSizeIntegrator message2; CHECK(serialization::AdaptiveStepSizeIntegrator::Kind_IsValid( flight_plan_adaptive_step_parameters.generalized_integrator_kind)); - message1.set_kind( + message2.set_kind( static_cast( flight_plan_adaptive_step_parameters.generalized_integrator_kind)); diff --git a/ksp_plugin_test/interface_flight_plan_test.cpp b/ksp_plugin_test/interface_flight_plan_test.cpp index 68efda4940..a091383041 100644 --- a/ksp_plugin_test/interface_flight_plan_test.cpp +++ b/ksp_plugin_test/interface_flight_plan_test.cpp @@ -163,6 +163,7 @@ TEST_F(InterfaceFlightPlanTest, FlightPlan) { plugin_.get(), vessel_guid, {/*integrator_kind=*/1, + /*generalized_integrator_kind=*/2, /*max_step=*/11, /*length_integration_tolerance=*/22, /*speed_integration_tolerance=*/33})); diff --git a/ksp_plugin_test/plugin_integration_test.cpp b/ksp_plugin_test/plugin_integration_test.cpp index 061d277f2c..19a022b7bc 100644 --- a/ksp_plugin_test/plugin_integration_test.cpp +++ b/ksp_plugin_test/plugin_integration_test.cpp @@ -700,6 +700,15 @@ TEST_F(PluginIntegrationTest, Prediction) { plugin.renderer().SetPlottingFrame( plugin.NewBodyCentredNonRotatingNavigationFrame(celestial)); + Ephemeris::AdaptiveStepParameters adaptive_step_parameters( + EmbeddedExplicitRungeKuttaNyströmIntegrator< + DormandالمكاوىPrince1986RKN434FM, + Position>(), + /*max_steps=*/14, + /*length_integration_tolerance=*/1 * Milli(Metre), + /*speed_integration_tolerance=*/1 * Milli(Metre) / Second); + plugin.SetPredictionAdaptiveStepParameters(vessel_guid, + adaptive_step_parameters); plugin.AdvanceTime(Instant() + 1e-10 * Second, 0 * Radian); plugin.UpdatePrediction(vessel_guid); auto const& prediction = diff --git a/ksp_plugin_test/simple_plugin.proto.bin b/ksp_plugin_test/simple_plugin.proto.bin index 1d5ec26c94c8aa99f978e626861a81bf6faa1d74..6bd0678ab7bef23aed562b3593a43c55315f59b0 100644 GIT binary patch delta 1401 zcmb7EZA?>F81A{9wA1l%FJGnQ_O?i8+pXFLh61I<){su(3Su`S+t|nuaESP|;ZOo* zejuAnUo)oDxlNauvPJPGiwZ4dPWe*F7mm<$0$)pCjz^0+d4G+;rVlNo;>G0 z@B2Q_dpfP?v=x1{8Wn;XBT+oOgh`{vLX)N2a*L9QK*FD2?nd}A%{$k&ecPKX^aB2l z+WO7ti7x?QOHct^VP5Ki0Zhu}3`{}*m%?&&^djydfAleE^rYYM@iukb5g5TDL2JSV z%@9+bGI`_S>sxjQ=pB`p;SG75tfy{Q*!#+*2Ew11$49vOO4qI8aFIdC9w*wzQpVoq z!H7zPO_ah(T*50^=q?%j@G?wAiol8Eg6;aly@Qtw4Qy>Lgx_1;=eVd=gH$L2C4q-f zKisa^8})~cCEP~%Xu1Q;ghr4t)#40Zsb%p#gp+el6{h9HY9WXShtotz#NvHJ+{q31 zF0hO)gmZr0@aa?U_FVu86-m1Z{nO|R$X_nShSDK3vH@8@L>kd5$RedYt|i*)++~BQ zFcFp?2Pa7hub=bRZ-PQAXrux^CYY|R5dI`7t|7_@^TZU_=`?_f*?(={0cJ6!aIanX zNmb_l1Xjgngg1m=FW7`tdeUKl8dK;`H!l{0MkL@hB7EZLEB)}DSj?Y$s)s!PVs89& zA^dX)zuABE#~K(HlXK+q;*MaNq`LV?1R5jhm!oLf`}NKlsTRv|!XhahyJPQuC>0mh z$hBw@RLe=;CZ*1*&S1qDO@S`C1e3=3L3W=Qeka=Qwye2tI~Xohyd0m$dv1NBmSr=FNG$pgzD{38maOr1=6%6Ho*%*U2*3XJlR!M{Ld2Z07MbhmlrHFWZ z{vgY=V7|(uiktEE^fJBW84)kQkpWsEhGW4m&<{)n$mezXgXIyJ;Bl*LTsC|-x(Qq+ zO2*;5n#Ahj4VIdh#CFI7l$qAiXaygWy?3^L7PG9S!84Lx<}cOt@MbDWr*Wk>`^H2WQUCoI5pT7=rR}KFQq@U1b delta 1407 zcmb7Ee^8TU9N+WqVpBr)zDyV!?|vxcwt}`Kf^E3DCAUBrGStKl(#um0$|+Z183898 z24V2kbY66JLFKNF^u4+eHYf@P+4LYhX52}7p$5o0>p)TIm3Nzw*B`$BJokL=^L~GQ zKHsO!fqrqI_g_Rspu$LGfGkWFdv~2dwr{7+K!g)v+{#&mf2@APv+v7MgD?P84V~&N zL67_s0G5mj;gXd^m*K8e#y&5Y2U)HJb8D%m*@wf>5m4*Nkk+}MR7uBS8jAs)85i`y z>dLfx-Ur!BYL@9Q)b+y4@}xL#M|I=@VMuc(^t~xvNds&poC}ghe^D}8PMI4xp z7h$~p(1J@j>l0?*ns~1l=3_)Kj^l!KlYMmJM`IV$n-AeVFO6O3QK>*C6oHb!`ID30 zgS9KJIvK(>gl``AfQ3*CvfQaxBXV>MK8A2|E@jh(9f>;N5mC@a@S~s1zv;bX`}+*T z7(uwSQT$Gm_VO8!N@A#4LcavHKw-KJdprlW#&n@gARsKM@pUeGHf%BoUN^XuQ=b22^9 zvo9SUD{L&_xq@Oy-Ti;{=iPQTMF|y~@vmAFUhUQ~Y+8{-we7@I>Z#74L<1#5w>UG0 z09T9Td)9|8|8B=dEyJbfAcB7T~_(?$cgW(B*wco?QMs_2!?IqRZ-_4@0j-6fD^v*I)QT=Z;( zkgeSq-Ol@vy(x<4^yD^M#~^ohJvo@$X0g=q3SWilI5;S?Z3t7zNEv)u%^ef``4b=lLmnY#;c{k~o%O zODZFbKUf8^E0q~h09aZ`p-e6oS9-d05tB90<=@EwbM$B@Y|9|23`;(Wvn{bMuDhb9 rU~yyv|A~dVC$rCCEEYI7c+lQPek|1Gv_JZb_qjFce_lK==1% Date: Sat, 8 Dec 2018 15:33:20 +0100 Subject: [PATCH 7/8] All the tests pass. --- .../interface_flight_plan_test.cpp | 34 ++++++++++++------- ksp_plugin_test/mock_flight_plan.hpp | 9 +++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ksp_plugin_test/interface_flight_plan_test.cpp b/ksp_plugin_test/interface_flight_plan_test.cpp index a091383041..da6a238fd2 100644 --- a/ksp_plugin_test/interface_flight_plan_test.cpp +++ b/ksp_plugin_test/interface_flight_plan_test.cpp @@ -149,15 +149,27 @@ TEST_F(InterfaceFlightPlanTest, FlightPlan) { EXPECT_CALL( flight_plan, - SetAdaptiveStepParameters(AllOf( - Property(&Ephemeris::AdaptiveStepParameters::max_steps, - 11), - Property(&Ephemeris::AdaptiveStepParameters:: - length_integration_tolerance, - 22 * Metre), - Property(&Ephemeris::AdaptiveStepParameters:: - speed_integration_tolerance, - 33 * Metre / Second)))) + SetAdaptiveStepParameters( + AllOf(Property( + &Ephemeris::AdaptiveStepParameters::max_steps, + 11), + Property(&Ephemeris::AdaptiveStepParameters:: + length_integration_tolerance, + 22 * Metre), + Property(&Ephemeris::AdaptiveStepParameters:: + speed_integration_tolerance, + 33 * Metre / Second)), + AllOf(Property(&Ephemeris:: + GeneralizedAdaptiveStepParameters::max_steps, + 11), + Property( + &Ephemeris::GeneralizedAdaptiveStepParameters:: + length_integration_tolerance, + 22 * Metre), + Property( + &Ephemeris::GeneralizedAdaptiveStepParameters:: + speed_integration_tolerance, + 33 * Metre / Second)))) .WillOnce(Return(true)); EXPECT_TRUE(principia__FlightPlanSetAdaptiveStepParameters( plugin_.get(), @@ -248,12 +260,8 @@ TEST_F(InterfaceFlightPlanTest, FlightPlan) { .WillRepeatedly(ReturnRef(identity)); EXPECT_CALL(flight_plan, GetManÅ“uvre(3)) .WillOnce(ReturnRef(navigation_manÅ“uvre)); - EXPECT_CALL(navigation_manÅ“uvre, InertialDirection()) - .WillOnce(Return(Vector({40, 50, 60}))); EXPECT_CALL(*plugin_, CelestialIndexOfBody(Ref(centre))) .WillOnce(Return(celestial_index)); - EXPECT_CALL(renderer, BarycentricToWorldSun(_)) - .WillOnce(Return(OrthogonalMap::Identity())); auto const navigation_manoeuvre = principia__FlightPlanGetManoeuvre(plugin_.get(), vessel_guid, diff --git a/ksp_plugin_test/mock_flight_plan.hpp b/ksp_plugin_test/mock_flight_plan.hpp index 4e1a9d85ce..30a0f6a907 100644 --- a/ksp_plugin_test/mock_flight_plan.hpp +++ b/ksp_plugin_test/mock_flight_plan.hpp @@ -30,9 +30,12 @@ class MockFlightPlan : public FlightPlan { MOCK_CONST_METHOD0(adaptive_step_parameters, Ephemeris::AdaptiveStepParameters const&()); - MOCK_METHOD1(SetAdaptiveStepParameters, - bool(Ephemeris::AdaptiveStepParameters const& - adaptive_step_parameters)); + MOCK_METHOD2( + SetAdaptiveStepParameters, + bool(Ephemeris::AdaptiveStepParameters const& + adaptive_step_parameters, + Ephemeris::GeneralizedAdaptiveStepParameters const& + generalized_adaptive_step_parameters)); MOCK_METHOD2(SetTolerances, void(Length const& length_integration_tolerance, From 643a3bf58a9b31f74f2f0aa34d9d11dedf89e522 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 8 Dec 2018 16:00:29 +0100 Subject: [PATCH 8/8] After egg's review. --- ksp_plugin/interface.hpp | 1 + ksp_plugin/interface_body.hpp | 1 + serialization/ksp_plugin.proto | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ksp_plugin/interface.hpp b/ksp_plugin/interface.hpp index e5084a3403..25baae5b50 100644 --- a/ksp_plugin/interface.hpp +++ b/ksp_plugin/interface.hpp @@ -3,6 +3,7 @@ #include #include +#include #include "base/not_null.hpp" #include "base/macros.hpp" diff --git a/ksp_plugin/interface_body.hpp b/ksp_plugin/interface_body.hpp index 1011fe04a9..127f8eacd4 100644 --- a/ksp_plugin/interface_body.hpp +++ b/ksp_plugin/interface_body.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace principia { namespace interface { diff --git a/serialization/ksp_plugin.proto b/serialization/ksp_plugin.proto index 11176b288c..7bfec3fa08 100644 --- a/serialization/ksp_plugin.proto +++ b/serialization/ksp_plugin.proto @@ -120,7 +120,7 @@ message Plugin { // Pre-Bourbaki. reserved 2; reserved "/*celestial*/"; - // Pre-Erdos. + // Pre-ErdÅ‘s. reserved 14; reserved "prediction_parameters"; }