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: 09426af22b31
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ca3e674b466e
Choose a head ref

Commits on May 21, 2019

  1. Copy the full SHA
    16da601 View commit details

Commits on May 22, 2019

  1. Status convenience functions.

    pleroy committed May 22, 2019
    Copy the full SHA
    4ce6967 View commit details
  2. FlightPlanReplace.

    pleroy committed May 22, 2019
    Copy the full SHA
    1308f16 View commit details
  3. Copy the full SHA
    1776109 View commit details
  4. Copy the full SHA
    93272d6 View commit details
  5. Copy the full SHA
    292afae View commit details

Commits on May 23, 2019

  1. Status update.

    pleroy committed May 23, 2019
    Copy the full SHA
    4ffc499 View commit details

Commits on May 25, 2019

  1. Error reporting.

    pleroy committed May 25, 2019
    Copy the full SHA
    11d265f View commit details
  2. Better error reporting.

    pleroy committed May 25, 2019
    Copy the full SHA
    1371dca View commit details
  3. Preserve integration status in the flight plan and avoid asking for t…

    …he Frenet frame of an anomalous manœuvre.
    pleroy committed May 25, 2019
    Copy the full SHA
    7b1a104 View commit details

Commits on May 26, 2019

  1. Copy the full SHA
    c9b9f15 View commit details
  2. Move out some changes.

    pleroy committed May 26, 2019
    Copy the full SHA
    4bd6bf5 View commit details
  3. Copy the full SHA
    da41f80 View commit details
  4. Copy the full SHA
    278280f View commit details
  5. Copy the full SHA
    10299b1 View commit details
  6. Copy the full SHA
    7fcff27 View commit details
  7. Fix tests.

    pleroy committed May 26, 2019
    Copy the full SHA
    2cccaee View commit details

Commits on May 30, 2019

  1. Merge.

    pleroy committed May 30, 2019
    Copy the full SHA
    a3a14fa View commit details
  2. Copy the full SHA
    51259be View commit details
  3. Copy the full SHA
    a97dd36 View commit details

Commits on Jun 2, 2019

  1. Merge.

    pleroy committed Jun 2, 2019
    Copy the full SHA
    6ee3867 View commit details

Commits on Jun 5, 2019

  1. Copy the full SHA
    f853fff View commit details
  2. Merge pull request #2187 from pleroy/NewFlightPlan

    Use the new flight plan API in the C# code
    pleroy authored Jun 5, 2019
    Copy the full SHA
    ca3e674 View commit details
9 changes: 6 additions & 3 deletions ksp_plugin/flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -318,11 +318,14 @@ std::unique_ptr<FlightPlan> FlightPlan::ReadFromMessage(
NavigationManœuvre::ReadFromMessage(manoeuvre, ephemeris));
}
// We need to forcefully prolong, otherwise we might exceed the ephemeris
// step limit while recomputing the segments and fail the check.
// step limit while recomputing the segments and make the flight plan
// anomalous for no good reason.
flight_plan->ephemeris_->Prolong(flight_plan->desired_final_time_);
Status const status = flight_plan->RecomputeAllSegments();
CHECK_GE(2, flight_plan->anomalous_segments_)
<< message.DebugString() << " " << status;
LOG_IF(INFO, flight_plan->anomalous_segments_ > 0)
<< "Loading a flight plan with " << flight_plan->anomalous_segments_
<< " anomalous segments and status " << status << "\n"
<< message.DebugString();

return flight_plan;
}
3 changes: 3 additions & 0 deletions ksp_plugin/interface.hpp
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
#include "base/macros.hpp"
#include "base/pull_serializer.hpp"
#include "base/push_deserializer.hpp"
#include "base/status.hpp"
#include "geometry/grassmann.hpp"
#include "geometry/named_quantities.hpp"
#include "geometry/quaternion.hpp"
@@ -136,6 +137,8 @@ KeplerianElements ToKeplerianElements(
QP ToQP(DegreesOfFreedom<World> const& dof);
QP ToQP(RelativeDegreesOfFreedom<AliceSun> const& relative_dof);

Status ToStatus(base::Status const& status);

WXYZ ToWXYZ(geometry::Quaternion const& quaternion);

XY ToXY(geometry::RP2Point<Length, Camera> const& rp2_point);
7 changes: 7 additions & 0 deletions ksp_plugin/interface_body.hpp
Original file line number Diff line number Diff line change
@@ -335,6 +335,13 @@ inline QP ToQP(RelativeDegreesOfFreedom<AliceSun> const& relative_dof) {
return QPConverter<RelativeDegreesOfFreedom<AliceSun>>::ToQP(relative_dof);
}

inline Status ToStatus(base::Status const& status) {
if (!status.ok()) {
LOG(ERROR) << status.message();
}
return {static_cast<int>(status.error())};
}

inline WXYZ ToWXYZ(geometry::Quaternion const& quaternion) {
return {quaternion.real_part(),
quaternion.imaginary_part().x,
13 changes: 2 additions & 11 deletions ksp_plugin/interface_external.cpp
Original file line number Diff line number Diff line change
@@ -30,23 +30,14 @@ using physics::RigidTransformation;

namespace {

Status MakeStatus(base::Status const status) {
Status result;
if (!status.ok()) {
LOG(ERROR) << status.message();
}
result.error = static_cast<int>(status.error());
return result;
}

// A wrapper for |MakeStatus(base::Status(error, message))|, since we often
// construct the status in the interface itself.
Status MakeStatus(Error const error, std::string const& message) {
return MakeStatus(base::Status(error, message));
return ToStatus(base::Status(error, message));
}

Status OK() {
return MakeStatus(base::Status::OK);
return ToStatus(base::Status::OK);
}

} // namespace
116 changes: 48 additions & 68 deletions ksp_plugin/interface_flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -169,25 +169,13 @@ NavigationManoeuvre ToInterfaceNavigationManoeuvre(

} // namespace

bool principia__FlightPlanAppend(Plugin const* const plugin,
char const* const vessel_guid,
Burn const burn) {
Status principia__FlightPlanAppend(Plugin const* const plugin,
char const* const vessel_guid,
Burn const burn) {
journal::Method<journal::FlightPlanAppend> m({plugin, vessel_guid, burn});
CHECK_NOTNULL(plugin);

// NOTE(phl): Preserving the previous semantics of FlightPlan.
auto& flight_plan = GetFlightPlan(*plugin, vessel_guid);
base::Status const status =
flight_plan.Append(FromInterfaceBurn(*plugin, burn));
if (status.error() == FlightPlan::singular ||
status.error() == FlightPlan::does_not_fit) {
return m.Return(false);
} else if (status.ok() || flight_plan.number_of_anomalous_manœuvres() == 0) {
return m.Return(true);
} else {
flight_plan.RemoveLast();
return m.Return(false);
}
return m.Return(ToStatus(GetFlightPlan(*plugin, vessel_guid).
Append(FromInterfaceBurn(*plugin, burn))));
}

void principia__FlightPlanCreate(Plugin const* const plugin,
@@ -320,6 +308,17 @@ principia__FlightPlanGetManoeuvreFrenetTrihedron(Plugin const* const plugin,
return m.Return(result);
}

int principia__FlightPlanNumberOfAnomalousManoeuvres(
Plugin const* const plugin,
char const* const vessel_guid) {
journal::Method<journal::FlightPlanNumberOfAnomalousManoeuvres> m(
{plugin,
vessel_guid});
CHECK_NOTNULL(plugin);
return m.Return(GetFlightPlan(*plugin, vessel_guid).
number_of_anomalous_manœuvres());
}

int principia__FlightPlanNumberOfManoeuvres(Plugin const* const plugin,
char const* const vessel_guid) {
journal::Method<journal::FlightPlanNumberOfManoeuvres> m({plugin,
@@ -335,12 +334,11 @@ int principia__FlightPlanNumberOfSegments(Plugin const* const plugin,
return m.Return(GetFlightPlan(*plugin, vessel_guid).number_of_segments());
}

void principia__FlightPlanRemoveLast(Plugin const* const plugin,
char const* const vessel_guid) {
Status principia__FlightPlanRemoveLast(Plugin const* const plugin,
char const* const vessel_guid) {
journal::Method<journal::FlightPlanRemoveLast> m({plugin, vessel_guid});
CHECK_NOTNULL(plugin);
GetFlightPlan(*plugin, vessel_guid).RemoveLast();
return m.Return();
return m.Return(ToStatus(GetFlightPlan(*plugin, vessel_guid).RemoveLast()));
}

void principia__FlightPlanRenderedApsides(Plugin const* const plugin,
@@ -456,34 +454,34 @@ Iterator* principia__FlightPlanRenderedSegment(
plugin));
}

bool principia__FlightPlanReplaceLast(Plugin const* const plugin,
char const* const vessel_guid,
Burn const burn) {
Status principia__FlightPlanReplace(Plugin const* const plugin,
char const* const vessel_guid,
Burn const burn,
int const index) {
journal::Method<journal::FlightPlanReplace> m({plugin,
vessel_guid,
burn,
index});
CHECK_NOTNULL(plugin);
auto& flight_plan = GetFlightPlan(*plugin, vessel_guid);
return m.Return(ToStatus(GetFlightPlan(*plugin, vessel_guid).
Replace(FromInterfaceBurn(*plugin, burn),
index)));
}

Status principia__FlightPlanReplaceLast(Plugin const* const plugin,
char const* const vessel_guid,
Burn const burn) {
journal::Method<journal::FlightPlanReplaceLast> m({plugin,
vessel_guid,
burn});
CHECK_NOTNULL(plugin);

// NOTE(phl): Preserving the previous semantics of FlightPlan.
auto& flight_plan = GetFlightPlan(*plugin, vessel_guid);
auto const manœuvre =
flight_plan.GetManœuvre(flight_plan.number_of_manœuvres() - 1);
base::Status const status =
flight_plan.ReplaceLast(FromInterfaceBurn(*plugin, burn));
if (status.error() == FlightPlan::singular ||
status.error() == FlightPlan::does_not_fit) {
return m.Return(false);
} else if (status.ok() || flight_plan.number_of_anomalous_manœuvres() == 0) {
return m.Return(true);
} else {
// The last manœuvre is broken. Roll it back.
flight_plan.RemoveLast();
flight_plan.Append(manœuvre.burn());
return m.Return(false);
}
return m.Return(ToStatus(GetFlightPlan(*plugin, vessel_guid).
ReplaceLast(FromInterfaceBurn(*plugin, burn))));
}

bool principia__FlightPlanSetAdaptiveStepParameters(
Status principia__FlightPlanSetAdaptiveStepParameters(
Plugin const* const plugin,
char const* const vessel_guid,
FlightPlanAdaptiveStepParameters const
@@ -493,38 +491,20 @@ bool principia__FlightPlanSetAdaptiveStepParameters(
CHECK_NOTNULL(plugin);
auto const parameters = FromFlightPlanAdaptiveStepParameters(
flight_plan_adaptive_step_parameters);

// NOTE(phl): Preserving the previous semantics of FlightPlan.
auto& flight_plan = GetFlightPlan(*plugin, vessel_guid);
auto const adaptive_step_parameters =
flight_plan.adaptive_step_parameters();
auto const generalized_adaptive_step_parameters =
flight_plan.generalized_adaptive_step_parameters();
base::Status const status =
flight_plan.SetAdaptiveStepParameters(parameters.first,
parameters.second);
if (status.ok()) {
return m.Return(true);
} else {
flight_plan.SetAdaptiveStepParameters(adaptive_step_parameters,
generalized_adaptive_step_parameters);
return m.Return(false);
}
return m.Return(
ToStatus(GetFlightPlan(*plugin, vessel_guid).
SetAdaptiveStepParameters(parameters.first, parameters.second)));
}

bool principia__FlightPlanSetDesiredFinalTime(Plugin const* const plugin,
char const* const vessel_guid,
double const final_time) {
Status principia__FlightPlanSetDesiredFinalTime(Plugin const* const plugin,
char const* const vessel_guid,
double const final_time) {
journal::Method<journal::FlightPlanSetDesiredFinalTime> m({plugin,
vessel_guid,
final_time});
CHECK_NOTNULL(plugin);

// NOTE(phl): Preserving the previous semantics of FlightPlan.
auto& flight_plan = GetFlightPlan(*plugin, vessel_guid);
base::Status const status =
flight_plan.SetDesiredFinalTime(FromGameTime(*plugin, final_time));
return m.Return(status.error() != FlightPlan::bad_desired_final_time);
return m.Return(ToStatus(GetFlightPlan(*plugin, vessel_guid).
SetDesiredFinalTime(FromGameTime(*plugin, final_time))));
}

} // namespace interface
Loading