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: f84c96953af9
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9e6326d7db64
Choose a head ref
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on May 2, 2021

  1. A friendlier version check.

    pleroy committed May 2, 2021
    Copy the full SHA
    230e364 View commit details
  2. Journal.

    pleroy committed May 2, 2021
    Copy the full SHA
    e7392dd View commit details
  3. Copy the full SHA
    a54b9b3 View commit details
  4. Copy the full SHA
    d04b818 View commit details
  5. Merge pull request #2971 from pleroy/2931b

    Only append the barycentre of the parts if it is after the end of the trajectory
    pleroy authored May 2, 2021
    Copy the full SHA
    9e6326d View commit details
Showing with 19 additions and 14 deletions.
  1. +4 −2 journal/player.cpp
  2. +2 −2 journal/player_test.cpp
  3. +1 −1 journal/profiles.cpp
  4. +12 −9 ksp_plugin/vessel.cpp
6 changes: 4 additions & 2 deletions journal/player.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
#include <filesystem>
#include <string>

#include "absl/strings/match.h"
#include "base/array.hpp"
#include "base/get_line.hpp"
#include "base/hexadecimal.hpp"
@@ -44,13 +45,14 @@ bool Player::Play(int const index) {

// Check that the version of the journal matches that of the binary. Remember
// that a GetVersion message is logged in Recorder::Activate, so it's always
// present.
// present. The |StartsWith| test below allows the "-dirty" suffix, which is
// typically present when debugging.
if (method_in->HasExtension(serialization::GetVersion::extension)) {
auto const& get_version_out =
method_out_return->GetExtension(serialization::GetVersion::extension)
.out();
LOG_IF(FATAL,
get_version_out.version() != Version &&
!absl::StartsWith(Version, get_version_out.version()) &&
(PRINCIPIA_PLAYER_ALLOW_VERSION_MISMATCH == 0))
<< "Journal version is " << get_version_out.version()
<< ", running with a binary built at version " << Version
4 changes: 2 additions & 2 deletions journal/player_test.cpp
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ TEST_F(PlayerTest, DISABLED_SECULAR_Debug) {
// An example of how journaling may be used for debugging. You must set
// |path| and fill the |method_in| and |method_out_return| protocol buffers.
std::string path =
R"(P:\Public Mockingbird\Principia\Crashes\2957\JOURNAL.20210423-105847)"; // NOLINT
R"(P:\Public Mockingbird\Principia\Crashes\2931\JOURNAL.20210330-124441)"; // NOLINT
Player player(path);
int count = 0;
while (player.Play(count)) {
@@ -109,7 +109,7 @@ TEST_F(PlayerTest, DISABLED_SECULAR_Debug) {
auto* extension = method_in.MutableExtension(
serialization::CatchUpLaggingVessels::extension);
auto* in = extension->mutable_in();
in->set_plugin(1851148864528);
in->set_plugin(2109308527968);
}
serialization::Method method_out_return;
{
2 changes: 1 addition & 1 deletion journal/profiles.cpp
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ void Insert(std::uint64_t const address,
const_cast<typename std::remove_cv<T>::type*>(pointer));
auto const [it, inserted] = pointer_map.emplace(address, inserted_pointer);
if (!inserted) {
CHECK_EQ(it->second, inserted_pointer);
CHECK_EQ(it->second, inserted_pointer) << address;
}
}

21 changes: 12 additions & 9 deletions ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ namespace ksp_plugin {
namespace internal_vessel {

using astronomy::InfiniteFuture;
using astronomy::InfinitePast;
using base::Contains;
using base::Error;
using base::FindOrDie;
@@ -224,6 +225,10 @@ void Vessel::AdvanceTime() {
// prognostication.
auto prediction = prediction_->DetachFork();

// Read the wall of text below and realize that this can happen for the
// history as well as the psychohistory, if the history of the part was
// obtained using an adaptive step integrator, which is the case during a
// burn. See #2931.
history_->DeleteFork(psychohistory_);
AppendToVesselTrajectory(&Part::history_begin,
&Part::history_end,
@@ -242,7 +247,7 @@ void Vessel::AdvanceTime() {
// multiple points, say one at t₀ + 21 s and one at t₀ + 24 s. In this case
// trying to insert the point at t₀ + 21 s would put us before the last point
// of the history of B and would fail a check. Therefore, we just ignore that
// point. See #2507.
// point. See #2507 and the |last_time| in AppendToVesselTrajectory.
AppendToVesselTrajectory(&Part::psychohistory_begin,
&Part::psychohistory_end,
*psychohistory_);
@@ -634,20 +639,18 @@ void Vessel::AppendToVesselTrajectory(
ends.push_back((*part.*part_trajectory_end)());
}

Instant fork_time;
if (!trajectory.is_root()) {
fork_time = trajectory.Fork()->time;
}
// We cannot append a point before this time, see the comments in AdvanceTime.
Instant const last_time =
trajectory.Empty() ? InfinitePast : trajectory.back().time;

// Loop over the times of the trajectory.
for (;;) {
auto const& it0 = its[0];
bool const at_end_of_part_trajectory = it0 == ends[0];
Instant const first_time = at_end_of_part_trajectory ? Instant()
: it0->time;
bool const after_fork_time = !at_end_of_part_trajectory &&
(trajectory.is_root() ||
first_time > fork_time);
bool const can_be_appended = !at_end_of_part_trajectory &&
first_time > last_time;

// Loop over the parts at a given time.
BarycentreCalculator<DegreesOfFreedom<Barycentric>, Mass> calculator;
@@ -668,7 +671,7 @@ void Vessel::AppendToVesselTrajectory(
}

// Append the parts' barycentre to the trajectory.
if (after_fork_time) {
if (can_be_appended) {
DegreesOfFreedom<Barycentric> const vessel_degrees_of_freedom =
calculator.Get();
trajectory.Append(first_time, vessel_degrees_of_freedom);