Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 70cfb93ae979
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0033bebb5f46
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on May 26, 2019

  1. Change ComputeSegments to consistently return the status of the first…

    … anomalous integration.
    pleroy committed May 26, 2019
    Copy the full SHA
    a369a4e View commit details
  2. A unit test doesn't hurt.

    pleroy committed May 26, 2019
    Copy the full SHA
    68a5327 View commit details
  3. Merge pull request #2179 from pleroy/RemoveLast

    Make sure that the FlightPlan operations return an error for an anomalous flight plan
    pleroy authored May 26, 2019
    Copy the full SHA
    0033beb View commit details
Showing with 24 additions and 1 deletion.
  1. +7 −1 ksp_plugin/flight_plan.cpp
  2. +3 −0 ksp_plugin/flight_plan.hpp
  3. +14 −0 ksp_plugin_test/flight_plan_test.cpp
8 changes: 7 additions & 1 deletion ksp_plugin/flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -399,7 +399,10 @@ Status FlightPlan::ComputeSegments(
std::vector<NavigationManœuvre>::iterator const begin,
std::vector<NavigationManœuvre>::iterator const end) {
CHECK(!segments_.empty());
Status overall_status;
if (anomalous_segments_ == 0) {
anomalous_status_ = Status::OK;
}
Status overall_status = anomalous_status_;
for (auto it = begin; it != end; ++it) {
auto& manœuvre = *it;
auto& coast = segments_.back();
@@ -410,6 +413,7 @@ Status FlightPlan::ComputeSegments(
if (!status.ok()) {
overall_status.Update(status);
anomalous_segments_ = 1;
anomalous_status_ = status;
}
}

@@ -421,6 +425,7 @@ Status FlightPlan::ComputeSegments(
if (!status.ok()) {
overall_status.Update(status);
anomalous_segments_ = 1;
anomalous_status_ = status;
}
}

@@ -431,6 +436,7 @@ Status FlightPlan::ComputeSegments(
if (!status.ok()) {
overall_status.Update(status);
anomalous_segments_ = 1;
anomalous_status_ = status;
}
}
return overall_status;
3 changes: 3 additions & 0 deletions ksp_plugin/flight_plan.hpp
Original file line number Diff line number Diff line change
@@ -207,6 +207,9 @@ class FlightPlan {
// either end prematurely or follow an anomalous trajectory; in the latter
// case they are empty.
int anomalous_segments_ = 0;
// The status of the first anomalous segment. Set and used exclusively by
// |ComputeSegments|.
Status anomalous_status_;

std::vector<NavigationManœuvre> manœuvres_;
not_null<Ephemeris<Barycentric>*> ephemeris_;
14 changes: 14 additions & 0 deletions ksp_plugin_test/flight_plan_test.cpp
Original file line number Diff line number Diff line change
@@ -230,6 +230,20 @@ TEST_F(FlightPlanTest, Singular) {
/*Δv=*/1 * Metre / Second)),
StatusIs(integrators::termination_condition::VanishingStepSize));
EXPECT_EQ(1, flight_plan_->number_of_anomalous_manœuvres());

// Add another manœuvre and check the status.
EXPECT_THAT(
flight_plan_->Append(
MakeTangentBurn(/*thrust=*/1 * Newton,
/*specific_impulse=*/1 * Newton * Second / Kilogram,
/*initial_time=*/singularity + 10 * Second,
/*Δv=*/1 * Metre / Second)),
StatusIs(integrators::termination_condition::VanishingStepSize));
EXPECT_EQ(2, flight_plan_->number_of_anomalous_manœuvres());

// Check that RemoveLast returns the proper statuses.
EXPECT_THAT(flight_plan_->RemoveLast(),
StatusIs(integrators::termination_condition::VanishingStepSize));
flight_plan_->RemoveLast();

// The singularity occurs during the burn: we're boosting towards the