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

Commits on Nov 6, 2021

  1. Integration test.

    pleroy committed Nov 6, 2021
    Copy the full SHA
    11ba736 View commit details
  2. Copy the full SHA
    636b97f View commit details
  3. Copy the full SHA
    9915281 View commit details
  4. Merge pull request #3194 from pleroy/IntegrationTest

    Convert the plugin integration test to DiscreteTraject0ry
    pleroy authored Nov 6, 2021
    Copy the full SHA
    6cfa80c View commit details
Showing with 27 additions and 22 deletions.
  1. +27 −22 ksp_plugin_test/plugin_integration_test.cpp
49 changes: 27 additions & 22 deletions ksp_plugin_test/plugin_integration_test.cpp
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ using testing_utilities::IsNear;
using testing_utilities::RelativeError;
using testing_utilities::SolarSystemFactory;
using testing_utilities::operator""_⑴;
using ::testing::AllOf;
using ::testing::Eq;
using ::testing::Ge;
using ::testing::Gt;
@@ -241,19 +242,21 @@ TEST_F(PluginIntegrationTest, BodyCentredNonrotatingNavigationIntegration) {
{ 0.1 * AstronomicalUnit / Hour,
-1.0 * AstronomicalUnit / Hour,
0.0 * AstronomicalUnit / Hour}) * (t - initial_time);
auto const& psychohistory =
plugin_->GetVessel(vessel_guid)->psychohistory();
auto const& vessel = *plugin_->GetVessel(vessel_guid);
auto const history =vessel.history();
auto const psychohistory =vessel.psychohistory();
auto const rendered_trajectory =
plugin_->renderer().RenderBarycentricTrajectoryInWorld(
plugin_->CurrentTime(),
psychohistory.begin(),
psychohistory.end(),
history->begin(),
psychohistory->end(),
sun_world_position,
plugin_->PlanetariumRotation());
EXPECT_THAT(rendered_trajectory.size(), AllOf(Ge(61), Le(4261)));
Position<World> const earth_world_position =
sun_world_position + alice_sun_to_world(plugin_->CelestialFromParent(
SolarSystemFactory::Earth).displacement());
for (auto const& [time, degrees_of_freedom] : *rendered_trajectory) {
for (auto const& [time, degrees_of_freedom] : rendered_trajectory) {
Length const distance =
(degrees_of_freedom.position() - earth_world_position).Norm();
perigee = std::min(perigee, distance);
@@ -349,15 +352,17 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingNavigationIntegration) {
{ 0.1 * AstronomicalUnit / Hour,
-1.0 * AstronomicalUnit / Hour,
0.0 * AstronomicalUnit / Hour}) * (t - initial_time);
auto const& psychohistory =
plugin_->GetVessel(vessel_guid)->psychohistory();
auto const& vessel = *plugin_->GetVessel(vessel_guid);
auto const history =vessel.history();
auto const psychohistory =vessel.psychohistory();
auto const rendered_trajectory =
plugin_->renderer().RenderBarycentricTrajectoryInWorld(
plugin_->CurrentTime(),
psychohistory.begin(),
psychohistory.end(),
history->begin(),
psychohistory->end(),
sun_world_position,
plugin_->PlanetariumRotation());
EXPECT_EQ(4321, rendered_trajectory.size());
Position<World> const earth_world_position =
sun_world_position +
alice_sun_to_world(
@@ -370,7 +375,7 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingNavigationIntegration) {
.displacement());
Length const earth_moon =
(moon_world_position - earth_world_position).Norm();
for (auto const& [time, degrees_of_freedom] : *rendered_trajectory) {
for (auto const& [time, degrees_of_freedom] : rendered_trajectory) {
Position<World> const position = degrees_of_freedom.position();
Length const satellite_earth = (position - earth_world_position).Norm();
Length const satellite_moon = (position - moon_world_position).Norm();
@@ -381,14 +386,14 @@ TEST_F(PluginIntegrationTest, BarycentricRotatingNavigationIntegration) {
// Check that there are no spikes in the rendered trajectory, i.e., that three
// consecutive points form a sufficiently flat triangle. This tests issue
// #256.
auto it0 = rendered_trajectory->begin();
CHECK(it0 != rendered_trajectory->end());
auto it0 = rendered_trajectory.begin();
CHECK(it0 != rendered_trajectory.end());
auto it1 = it0;
++it1;
CHECK(it1 != rendered_trajectory->end());
CHECK(it1 != rendered_trajectory.end());
auto it2 = it1;
++it2;
while (it2 != rendered_trajectory->end()) {
while (it2 != rendered_trajectory.end()) {
EXPECT_THAT((it0->degrees_of_freedom.position() -
it2->degrees_of_freedom.position())
.Norm(),
@@ -712,20 +717,20 @@ TEST_F(PluginIntegrationTest, Prediction) {
plugin.UpdatePrediction({vessel_guid});
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
} while (plugin.GetVessel(vessel_guid)->prediction().Size() != 15);
} while (plugin.GetVessel(vessel_guid)->prediction()->size() != 15);

auto const& prediction = plugin.GetVessel(vessel_guid)->prediction();
auto const prediction = plugin.GetVessel(vessel_guid)->prediction();
auto const rendered_prediction =
plugin.renderer().RenderBarycentricTrajectoryInWorld(
plugin.CurrentTime(),
prediction.Fork(),
prediction.end(),
prediction->begin(),
prediction->end(),
World::origin,
plugin.PlanetariumRotation());
EXPECT_EQ(15, rendered_prediction->Size());
EXPECT_EQ(15, rendered_prediction.size());
int index = 0;
for (auto it = rendered_prediction->begin();
it != rendered_prediction->end();
for (auto it = rendered_prediction.begin();
it != rendered_prediction.end();
++it, ++index) {
auto const& position = it->degrees_of_freedom.position();
EXPECT_THAT(AbsoluteError((position - World::origin).Norm(), 1 * Metre),
@@ -736,7 +741,7 @@ TEST_F(PluginIntegrationTest, Prediction) {
}
}
EXPECT_THAT(AbsoluteError(
rendered_prediction->back().degrees_of_freedom.position(),
rendered_prediction.back().degrees_of_freedom.position(),
Displacement<World>({1 * Metre, 0 * Metre, 0 * Metre}) +
World::origin),
IsNear(29_⑴ * Milli(Metre)));