-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
265 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "GlideslopeDriftEstimator.h" | ||
#include "euroscope/EuroScopeCRadarTargetInterface.h" | ||
#include "runway/Runway.h" | ||
|
||
namespace UKControllerPlugin::Approach { | ||
|
||
auto GlideslopeDriftEstimator::CalculateGlideslopeDrift( | ||
const Euroscope::EuroScopeCRadarTargetInterface& radarTarget, const Runway::Runway& runway) -> int | ||
{ | ||
// Calculate the slope of each line | ||
const auto runwaySlope = runway.RunwayHeadingLineSlope(); | ||
const auto runwayPerpendicularSlope = runway.RunwayPerpendicularHeadingLineSlope(); | ||
|
||
// Calculate the distance between the intersection and the threshold | ||
EuroScopePlugIn::CPosition intersection; | ||
intersection.m_Latitude = (runwaySlope * runway.Threshold().m_Latitude - | ||
runwayPerpendicularSlope * radarTarget.GetPosition().m_Latitude + | ||
radarTarget.GetPosition().m_Longitude - runway.Threshold().m_Longitude) / | ||
(runwaySlope - runwayPerpendicularSlope); | ||
intersection.m_Longitude = | ||
runwaySlope * (intersection.m_Latitude - runway.Threshold().m_Latitude) + runway.Threshold().m_Longitude; | ||
const auto distance = runway.Threshold().DistanceTo(intersection); | ||
|
||
// Calculate the difference between the glideslope altitude and the aircraft altitude | ||
return runway.GlideslopeAltitudeAtDistance(distance) - radarTarget.GetAltitude(); | ||
} | ||
} // namespace UKControllerPlugin::Approach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin { | ||
namespace Euroscope { | ||
class EuroScopeCRadarTargetInterface; | ||
} // namespace Euroscope | ||
namespace Runway { | ||
class Runway; | ||
} // namespace Runway | ||
} // namespace UKControllerPlugin | ||
|
||
namespace UKControllerPlugin::Approach { | ||
|
||
class GlideslopeDriftEstimator | ||
{ | ||
public: | ||
[nodiscard] auto CalculateGlideslopeDrift( | ||
const Euroscope::EuroScopeCRadarTargetInterface& radarTarget, const Runway::Runway& runway) -> int; | ||
}; | ||
} // namespace UKControllerPlugin::Approach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "Angle.h" | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
|
||
const double pi = 3.14159265358979323846; | ||
|
||
auto DegreesToRadians(const double degrees) -> double | ||
{ | ||
return degrees * pi / 180; | ||
} | ||
|
||
auto RadiansToDegrees(const double radians) -> double | ||
{ | ||
return radians * 180 / pi; | ||
} | ||
|
||
auto Slope(const double radians) -> double | ||
{ | ||
return std::tan(radians); | ||
} | ||
} // namespace UKControllerPlugin::Geometry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin::Geometry { | ||
[[nodiscard]] auto DegreesToRadians(const double degrees) -> double; | ||
[[nodiscard]] auto RadiansToDegrees(const double radians) -> double; | ||
[[nodiscard]] auto Slope(const double radians) -> double; | ||
|
||
} // namespace UKControllerPlugin::Geometry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "approach/GlideslopeDriftEstimator.h" | ||
#include "runway/Runway.h" | ||
|
||
namespace UKControllerPluginTest::Approach { | ||
class GlideslopeDriftEstimatorTest : public ::testing::Test | ||
{ | ||
public: | ||
GlideslopeDriftEstimatorTest() : runway(1, 1, "26L", 257, RunwayPosition()) | ||
{ | ||
} | ||
|
||
[[nodiscard]] auto RunwayPosition() -> EuroScopePlugIn::CPosition | ||
{ | ||
EuroScopePlugIn::CPosition pos; | ||
pos.m_Latitude = 51.150675; | ||
pos.m_Longitude = -0.171925; | ||
return pos; | ||
} | ||
|
||
UKControllerPlugin::Runway::Runway runway; | ||
testing::NiceMock<Euroscope::MockEuroScopeCRadarTargetInterface> radarTarget; | ||
UKControllerPlugin::Approach::GlideslopeDriftEstimator glideslopeDriftEstimator; | ||
}; | ||
|
||
TEST_F(GlideslopeDriftEstimatorTest, CalculateGlideslopeDrift) | ||
{ | ||
EuroScopePlugIn::CPosition aircraftPosition; | ||
// Approx 8DME | ||
aircraftPosition.m_Latitude = 51.17575; | ||
aircraftPosition.m_Longitude = 0.00829; | ||
ON_CALL(radarTarget, GetPosition()).WillByDefault(testing::Return(aircraftPosition)); | ||
ON_CALL(radarTarget, GetAltitude()).WillByDefault(testing::Return(2000)); | ||
|
||
const auto result = glideslopeDriftEstimator.CalculateGlideslopeDrift(radarTarget, runway); | ||
ASSERT_DOUBLE_EQ(result, 448); | ||
} | ||
} // namespace UKControllerPluginTest::Approach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "geometry/Angle.h" | ||
|
||
namespace UKControllerPluginTest::Geometry { | ||
class AngleTest : public ::testing::Test | ||
{ | ||
public: | ||
const double pi = 3.14159265358979323846; | ||
}; | ||
|
||
TEST_F(AngleTest, DegreesToRadians) | ||
{ | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::DegreesToRadians(0), 0); | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::DegreesToRadians(90), pi / 2); | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::DegreesToRadians(180), pi); | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::DegreesToRadians(270), pi * 1.5); | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::DegreesToRadians(360), pi * 2); | ||
} | ||
|
||
TEST_F(AngleTest, RadiansToDegrees) | ||
{ | ||
EXPECT_EQ(UKControllerPlugin::Geometry::RadiansToDegrees(0), 0); | ||
EXPECT_EQ(UKControllerPlugin::Geometry::RadiansToDegrees(pi / 2), 90); | ||
EXPECT_EQ(UKControllerPlugin::Geometry::RadiansToDegrees(pi), 180); | ||
EXPECT_EQ(UKControllerPlugin::Geometry::RadiansToDegrees(pi * 1.5), 270); | ||
EXPECT_EQ(UKControllerPlugin::Geometry::RadiansToDegrees(pi * 2), 360); | ||
} | ||
|
||
TEST_F(AngleTest, Slope) | ||
{ | ||
EXPECT_DOUBLE_EQ(UKControllerPlugin::Geometry::Slope(pi / 2), 1.633123935319537e+16); | ||
} | ||
} // namespace UKControllerPluginTest::Geometry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters