Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.26...4.1.2)
project(im_sample_algorithm VERSION 5.2.0.0) # the nano value is a boolean. 1 == SNAPSHOT, 0 == release
cmake_minimum_required(VERSION 3.26...4.2)
project(im_sample_algorithm VERSION 5.3.0.0) # the nano value is a boolean. 1 == SNAPSHOT, 0 == release

set (CMAKE_CXX_STANDARD 20)

Expand Down Expand Up @@ -32,19 +32,12 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-unused-functi
CPMAddPackage(
NAME fmacm
GITHUB_REPOSITORY mitre/FMACM
GIT_TAG v5.2.0
GIT_TAG v5.3.0
OPTIONS
"BUILD_SHARED_LIBS FALSE"
"BUILD_TESTING ${BUILD_TESTING}"
)

# CPMAddPackage(
# NAME unitslib
# GIT_REPOSITORY https://mustache.mitre.org/scm/aaes/cpp-uom.git # FIXME use external repo when available
# GIT_TAG 07445f7ec0f98b55cdd6e6188083145a293415a7
# DOWNLOAD_ONLY TRUE
# )

CPMAddPackage(
NAME log4cplus
GITHUB_REPOSITORY log4cplus/log4cplus
Expand Down
37 changes: 19 additions & 18 deletions IntervalManagement/AchieveObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,36 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/AchieveObserver.h"

#include <cstdio>
#include <string>

using namespace std;
using namespace interval_management::open_source;

AchieveObserver::AchieveObserver() : m_iteration(-1), m_id(-1) {
m_time = Units::SecondsTime(-99999.0);
m_targ_ttg_to_ach = Units::SecondsTime(-99999.0);
m_own_ttg_to_ach = Units::SecondsTime(-99999.0);
m_curr_dist = Units::MetersLength(-99999.0);
m_ref_dist = Units::MetersLength(-99999.0);
}
AchieveObserver::AchieveObserver()
: m_iteration(-1),
m_id(-1),
m_time(Units::SecondsTime(-99999.0)),
m_targ_ttg_to_ach(Units::SecondsTime(-99999.0)),
m_own_ttg_to_ach(Units::SecondsTime(-99999.0)),
m_curr_dist(Units::MetersLength(-99999.0)),
m_ref_dist(Units::MetersLength(-99999.0)) {}

AchieveObserver::AchieveObserver(const int iter, const int aircraft_id, const double tm, const double target_ttg_to_ach,
const double own_ttg_to_ach, const double curr_distance,
const double reference_distance)
: m_iteration(iter), m_id(aircraft_id), m_time(tm) {
m_targ_ttg_to_ach = Units::SecondsTime(target_ttg_to_ach);
m_own_ttg_to_ach = Units::SecondsTime(own_ttg_to_ach);
m_curr_dist = Units::MetersLength(curr_distance);
m_ref_dist = Units::MetersLength(reference_distance);
}
: m_iteration(iter),
m_id(aircraft_id),
m_time(tm),
m_targ_ttg_to_ach(Units::SecondsTime(target_ttg_to_ach)),
m_own_ttg_to_ach(Units::SecondsTime(own_ttg_to_ach)),
m_curr_dist(Units::MetersLength(curr_distance)),
m_ref_dist(Units::MetersLength(reference_distance)) {}

AchieveObserver::~AchieveObserver() {
// Destructor.
Expand All @@ -59,15 +62,13 @@ string AchieveObserver::ToString() {

string str;

char *txt = new char[301];
char txt[301];

snprintf(txt, 301, "%d,%d,%lf,%lf,%lf,%lf,%lf", m_iteration, m_id, Units::SecondsTime(m_time).value(),
snprintf(txt, sizeof(txt), "%d,%d,%lf,%lf,%lf,%lf,%lf", m_iteration, m_id, Units::SecondsTime(m_time).value(),
Units::SecondsTime(m_targ_ttg_to_ach).value(), Units::SecondsTime(m_own_ttg_to_ach).value(),
Units::MetersLength(m_curr_dist).value(), Units::MetersLength(m_ref_dist).value());

str = txt;

delete[] txt;

return str;
}
21 changes: 8 additions & 13 deletions IntervalManagement/AchievePointCalcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/AchievePointCalcs.h"
#include "utility/CustomUnits.h"
#include "public/CustomMath.h"

#include <string>
#include <iomanip>
#include <memory>
#include <string>
#include <vector>

#include "public/CustomMath.h"
#include "utility/CustomUnits.h"

using namespace std;
using namespace aaesim::open_source;
Expand Down Expand Up @@ -89,7 +92,6 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
}

void AchievePointCalcs::Clear() {

m_waypoint_name = "";
m_waypoint_is_set = false;

Expand All @@ -110,7 +112,6 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
const vector<HorizontalPath> &target_horizontal_path,
Waypoint &traffic_reference_point, Units::Length &waypoint_x,
Units::Length &waypoint_y, size_t &waypoint_index_in_target_intent) {

// Get ABP index from ownship
int ix0 = ownship_intent.GetWaypointIndexByName(ownship_calcs.GetWaypointName());
if (ix0 < 0) {
Expand Down Expand Up @@ -317,7 +318,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
throw logic_error("Failed to calculate circular arc intersection.");
}
} // end if turn
} // end if not first
} // end if not first
x0 = x1;
y0 = y1;
d0 = d1;
Expand Down Expand Up @@ -390,9 +391,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
}

void AchievePointCalcs::ComputePositions(const AircraftIntent &intent) {

if (this->HasWaypoint()) {

int ix = intent.GetWaypointIndexByName(m_waypoint_name);

if (ix > -1) {
Expand All @@ -410,7 +409,6 @@ void AchievePointCalcs::ComputePositions(const AircraftIntent &intent) {
}

void AchievePointCalcs::ComputeAlongPathDistanceFromWaypointToEnd() {

if (this->HasWaypoint()) {
Units::Length distance_from_waypoint_to_end;
m_distance_calculator.CalculateAlongPathDistanceFromPosition(this->m_waypoint_x, this->m_waypoint_y,
Expand All @@ -422,7 +420,6 @@ void AchievePointCalcs::ComputeAlongPathDistanceFromWaypointToEnd() {
}

void AchievePointCalcs::ComputeEndValues(const VerticalPath &vertical_path) {

if (this->HasWaypoint()) {
// compute achieve by distance
ComputeAlongPathDistanceFromWaypointToEnd();
Expand All @@ -433,7 +430,6 @@ void AchievePointCalcs::ComputeEndValues(const VerticalPath &vertical_path) {

m_time_to_go_to_waypoint = Units::ZERO_TIME;
} else {

// compute time to go from achieve point to the end.

// get index at achieve by distance from end of route (beginning of our search).
Expand All @@ -449,7 +445,6 @@ void AchievePointCalcs::ComputeEndValues(const VerticalPath &vertical_path) {
// Compute the time to go from the achieve by point to the end.

if (ix < firsttimeix) {

// ttg:time to go at points 1 and 0.
// dtg:distance to go at points 1 and 0.
const double ttg0 = vertical_path.time_to_go_sec[ix];
Expand Down
9 changes: 4 additions & 5 deletions IntervalManagement/AircraftState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/AircraftState.h"

#include "imalgs/IMUtils.h"
#include "public/CustomMath.h"
#include "utility/CustomUnits.h"
#include "imalgs/IMUtils.h"

log4cplus::Logger interval_management::open_source::AircraftState::m_logger =
log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("AircraftState"));
Expand Down Expand Up @@ -55,7 +56,6 @@ const Units::Speed interval_management::open_source::AircraftState::GetGroundSpe

interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Interpolate(
const AircraftState &a, const AircraftState &b, const Units::SecondsTime time) {

const double dt = Units::SecondsTime(b.GetTimeStamp() - a.GetTimeStamp()).value();
double weight_a, weight_b;
if (a.GetTimeStamp() == b.GetTimeStamp()) {
Expand Down Expand Up @@ -107,7 +107,6 @@ interval_management::open_source::AircraftState &interval_management::open_sourc
const Units::Speed &sensed_wind_north, const Units::Speed &sensed_wind_parallel,
const Units::Speed &sensed_wind_perpendicular, const Units::Temperature &sensed_temperature,
const Units::Angle &psi_enu) {

this->m_id = id;
this->m_time = time;
this->m_x = Units::FeetLength(enu_position.x).value();
Expand All @@ -124,4 +123,4 @@ interval_management::open_source::AircraftState &interval_management::open_sourc
this->m_sensed_temperature = sensed_temperature;
this->m_psi_enu = psi_enu;
return *this;
}
}
5 changes: 2 additions & 3 deletions IntervalManagement/ClosestPointMetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/ClosestPointMetric.h"

#include "public/AircraftCalculations.h"

using namespace interval_management::open_source;

ClosestPointMetric::ClosestPointMetric() = default;

void ClosestPointMetric::update(double imx, double imy, double targx, double targy) {

// Computes the distance between im and target aircraft based on the input
// positions and replaces the minimum distance if the new distance closer.
// Distance is in nmi.
Expand All @@ -42,7 +42,6 @@ void ClosestPointMetric::update(double imx, double imy, double targx, double tar
}

Units::Length ClosestPointMetric::getMinDist() {

// Gets minimum distance.
//
// returns minimum distance.
Expand Down
2 changes: 1 addition & 1 deletion IntervalManagement/CrossTrackObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/CrossTrackObserver.h"
Expand Down
12 changes: 7 additions & 5 deletions IntervalManagement/FIMAlgorithmAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/FIMAlgorithmAdapter.h"

#include <nlohmann/json.hpp>
#include <memory>
#include <string>
#include <vector>

#include "imalgs/IMUtils.h"
#include "imalgs/FIMAlgorithmInitializer.h"
#include "public/SingleTangentPlaneSequence.h"
#include "imalgs/IMUtils.h"
#include "nlohmann/json.hpp"
#include "public/CoreUtils.h"
#include "public/SingleTangentPlaneSequence.h"

using namespace interval_management::open_source;
using json = nlohmann::json;
Expand Down Expand Up @@ -65,7 +68,6 @@ aaesim::open_source::Guidance interval_management::open_source::FIMAlgorithmAdap
const aaesim::open_source::SimulationTime &simtime, const aaesim::open_source::Guidance &current_guidance,
const aaesim::open_source::DynamicsState &dynamics_state,
const aaesim::open_source::AircraftState &own_truth_state) {

aaesim::open_source::Guidance im_algorithm_guidance = current_guidance;
im_algorithm_guidance.SetValid(false);
if (current_guidance.m_active_guidance_phase != aaesim::open_source::GuidanceFlightPhase::CRUISE_DESCENT)
Expand Down
8 changes: 5 additions & 3 deletions IntervalManagement/FIMAlgorithmDataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/FIMAlgorithmDataWriter.h"

#include <memory>
#include <string>

#include "imalgs/FIMAlgorithmAdapter.h"
#include "imalgs/IMKinematicAchieve.h"
#include "public/AircraftSpeed.h"
Expand Down Expand Up @@ -129,9 +132,8 @@ void interval_management::open_source::FIMAlgorithmDataWriter::Finish() {
}

void interval_management::open_source::FIMAlgorithmDataWriter::Gather(
const int iteration_number, const aaesim::open_source::SimulationTime &time, std::string aircraft_id,
const int iteration_number, const aaesim::open_source::SimulationTime &time, const std::string &aircraft_id,
std::shared_ptr<const aaesim::open_source::FlightDeckApplication> application) {

const bool is_fim_application =
CoreUtils::InstanceOf<interval_management::open_source::FIMAlgorithmAdapter>(application.get());
if (!is_fim_application) {
Expand Down
8 changes: 5 additions & 3 deletions IntervalManagement/FIMAlgorithmInitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/FIMAlgorithmInitializer.h"

#include <memory>

using namespace interval_management::open_source;

interval_management::open_source::FIMAlgorithmInitializer::FIMAlgorithmInitializer(
Expand Down Expand Up @@ -94,14 +96,14 @@ const interval_management::open_source::FIMAlgorithmInitializer

interval_management::open_source::FIMAlgorithmInitializer::Builder *
interval_management::open_source::FIMAlgorithmInitializer::Builder::AddOwnshipPerformanceParameters(
aaesim::open_source::OwnshipPerformanceParameters performance_parameters) {
const aaesim::open_source::OwnshipPerformanceParameters &performance_parameters) {
m_performance_parameters = performance_parameters;
return this;
}

interval_management::open_source::FIMAlgorithmInitializer::Builder *
interval_management::open_source::FIMAlgorithmInitializer::Builder::AddOwnshipFmsPredictionParameters(
aaesim::open_source::OwnshipFmsPredictionParameters prediction_parameters) {
const aaesim::open_source::OwnshipFmsPredictionParameters &prediction_parameters) {
m_prediction_parameters = prediction_parameters;
return this;
}
Expand Down
6 changes: 4 additions & 2 deletions IntervalManagement/FIMConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
// For further information, please contact The MITRE Corporation, Contracts Management
// Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
//
// 2023 The MITRE Corporation. All Rights Reserved.
// (c) 2026 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include "imalgs/FIMConfiguration.h"

#include <string>

using namespace interval_management::open_source;

log4cplus::Logger FIMConfiguration::m_logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("FIMConfiguration"));
Expand Down Expand Up @@ -62,4 +64,4 @@ bool FIMConfiguration::load(DecodedStream *input) {
}

return m_loaded;
}
}
Loading
Loading