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
24 changes: 24 additions & 0 deletions .cmake/get_cpm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.8)
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
build:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
matrix:
include:
- os: macos-latest
container: ''
install: |
brew update
brew upgrade
- os: ubuntu-latest
container: rockylinux:9
install: |
dnf -y install gcc gcc-c++ make cmake git
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: ${{ matrix.install }}

- name: Configure and Build
run: |
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --target imalgs -j


run_all_tests:
runs-on: ubuntu-latest
container:
image: rockylinux:9
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
dnf -y install gcc gcc-c++ make cmake git

- name: Build project
run: |
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON

- name: Run tests
run: |
cmake --build build --target run_imalgs_test -j

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: public-test-results
path: unittest/*results.xml

# - name: Publish JUnit test results
# uses: dorny/test-reporter@v2
# if: always()
# with:
# name: Public Library Tests
# path: unittest/*results.xml
# reporter: jest-junit
# fail-on-error: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
75 changes: 75 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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

set (CMAKE_CXX_STANDARD 20)

if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE "Release")
endif()
message (STATUS "${PROJECT_NAME}: Build type is ${CMAKE_BUILD_TYPE}")

option(BUILD_TESTING "Enable building ${PROJECT_NAME} tests" ON)
if(NOT ${BUILD_TESTING})
message(STATUS "${PROJECT_NAME}: skipping test targets")
endif()


include(${PROJECT_SOURCE_DIR}/.cmake/get_cpm.cmake)

if (${PROJECT_VERSION_TWEAK})
# Append -SNAPSHOT to the version name if this is a pre-release version
set(msg_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-SNAPSHOT)
else()
set(msg_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
endif()
message(STATUS "${PROJECT_NAME}: Generating build version ${msg_VERSION}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-unused-function -Wno-sign-compare -O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-unused-function -Wno-sign-compare -O3 -g3")

# Begin project dependencies ------------------------------------------------------
CPMAddPackage(
NAME fmacm
GITHUB_REPOSITORY mitre/FMACM
GIT_TAG v5.2.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
GIT_TAG REL_2_1_2
OPTIONS
"BUILD_SHARED_LIBS FALSE"
"LOG4CPLUS_BUILD_TESTING FALSE"
"LOG4CPLUS_BUILD_LOGGINGSERVER FALSE"
)

# Create some common paths
if (log4cplus_ADDED)
set (LOG4CPLUS_DIRS
${log4cplus_BINARY_DIR}/include
${log4cplus_SOURCE_DIR}/include)
endif ()

set (unitslib_INCLUDE_DIRS ${fmacm_SOURCE_DIR}/units-2.1/src/)
set (LOADER_DIR ${fmacm_SOURCE_DIR}/Loader)
set (PUBLIC_DIR ${fmacm_SOURCE_DIR}/Public)
set (IM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/IntervalManagement)
set (fmacm_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
${fmacm_SOURCE_DIR}/include)
set (UNITTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unittest)

add_subdirectory(${IM_DIR})
add_subdirectory(${UNITTEST_DIR})
include(${UNITTEST_DIR}/unittest.cmake)
9 changes: 5 additions & 4 deletions IntervalManagement/AchieveObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// 2023 The MITRE Corporation. All Rights Reserved.
// ****************************************************************************

#include <cstdio>
#include "imalgs/AchieveObserver.h"

#include <cstdio>

using namespace std;
using namespace interval_management::open_source;

Expand Down Expand Up @@ -60,9 +61,9 @@ string AchieveObserver::ToString() {

char *txt = new char[301];

sprintf(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());
snprintf(txt, 301, "%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;

Expand Down
18 changes: 9 additions & 9 deletions IntervalManagement/AchievePointCalcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten

AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftIntent &intent, const VerticalPath &vpath,
const vector<HorizontalPath> &htraj, const AchievePointCalcs &ownship_calcs,
const AircraftIntent &ownship_intent) {
const AircraftIntent &ownship_intent,
const std::shared_ptr<TangentPlaneSequence> &position_converter) {
Clear();

m_waypoint_name = waypoint;
Expand All @@ -69,16 +70,16 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
if (m_waypoint_name == "CALCULATED_TRP") {
Waypoint traffic_reference_point;
size_t waypoint_index;
ComputeDefaultTRP(ownship_calcs, ownship_intent, intent, m_horizontal_path, traffic_reference_point, m_waypoint_x,
m_waypoint_y, waypoint_index);
ComputeDefaultTRP(ownship_calcs, ownship_intent, intent, position_converter, m_horizontal_path,
traffic_reference_point, m_waypoint_x, m_waypoint_y, waypoint_index);
LOG4CPLUS_DEBUG(m_logger, "Calculated TRP = (" << m_waypoint_x << "," << m_waypoint_y << ")");
// log the geographic coordinates
EarthModel::LocalPositionEnu xy;
xy.x = m_waypoint_x;
xy.y = m_waypoint_y;
xy.z = Units::zero();
EarthModel::GeodeticPosition geo;
intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
position_converter->ConvertLocalToGeodetic(xy, geo);
LOG4CPLUS_DEBUG(m_logger, "(lat,lon) = (" << std::setprecision(10) << Units::DegreesAngle(geo.latitude) << ","
<< Units::DegreesAngle(geo.longitude) << ")");
} else {
Expand All @@ -87,8 +88,6 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
ComputeEndValues(vpath);
}

AchievePointCalcs::~AchievePointCalcs() = default;

void AchievePointCalcs::Clear() {

m_waypoint_name = "";
Expand All @@ -107,6 +106,7 @@ void AchievePointCalcs::Clear() {

void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs, const AircraftIntent &ownship_intent,
const AircraftIntent &target_intent,
const std::shared_ptr<TangentPlaneSequence> &position_converter,
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) {
Expand Down Expand Up @@ -154,7 +154,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
// Search horizontal path for an intersecting segment
HorizontalTurnPath trp_turn;
bool first(true), crossed(false), end_is_usable(false);
double x0, y0, d0;
double x0{}, y0{}, d0{};
vector<HorizontalPath>::const_iterator hpi;
for (hpi = target_horizontal_path.begin(); hpi != target_horizontal_path.end(); ++hpi) {
double x1 = hpi->GetXPositionMeters();
Expand Down Expand Up @@ -343,7 +343,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
xy.y = waypoint_y;
xy.z = Units::zero();
EarthModel::GeodeticPosition geo;
target_intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
position_converter->ConvertLocalToGeodetic(xy, geo);

// populate traffic_reference_point
traffic_reference_point.SetName("CALCULATED_TRP");
Expand All @@ -353,7 +353,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
if (trp_turn.radius > Units::zero()) {
xy.x = Units::MetersLength(trp_turn.x_position_meters);
xy.y = Units::MetersLength(trp_turn.y_position_meters);
target_intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
position_converter->ConvertLocalToGeodetic(xy, geo);
traffic_reference_point.SetRfTurnCenterLatitude(geo.latitude);
traffic_reference_point.SetRfTurnCenterLongitude(geo.longitude);
} else {
Expand Down
31 changes: 15 additions & 16 deletions IntervalManagement/AircraftState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
#include "utility/CustomUnits.h"
#include "imalgs/IMUtils.h"

using namespace interval_management::open_source;

log4cplus::Logger interval_management::open_source::AircraftState::m_logger =
log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("AircraftState"));

AircraftState::AircraftState()
interval_management::open_source::AircraftState::AircraftState()
: m_x(0),
m_y(0),
m_z(0),
Expand All @@ -45,17 +43,18 @@ AircraftState::AircraftState()
m_gamma(Units::ZERO_ANGLE),
m_sensed_temperature(Units::negInfinity()) {}

const Units::UnsignedRadiansAngle AircraftState::GetHeadingCcwFromEastRadians() const {
const Units::UnsignedRadiansAngle interval_management::open_source::AircraftState::GetHeadingCcwFromEastRadians()
const {
double result = atan3(m_yd, m_xd);
return Units::UnsignedRadiansAngle(result);
}

const Units::Speed AircraftState::GetGroundSpeed() const {
const Units::Speed interval_management::open_source::AircraftState::GetGroundSpeed() const {
return Units::FeetPerSecondSpeed(sqrt(pow(m_xd, 2) + pow(m_yd, 2)));
}

AircraftState &AircraftState::Interpolate(const AircraftState &a, const AircraftState &b,
const Units::SecondsTime time) {
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;
Expand All @@ -80,7 +79,8 @@ AircraftState &AircraftState::Interpolate(const AircraftState &a, const Aircraft
return *this;
}

AircraftState &AircraftState::Extrapolate(const AircraftState &in, const Units::SecondsTime &time) {
interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Extrapolate(
const AircraftState &in, const Units::SecondsTime &time) {
const double dt = time.value() - in.GetTimeStamp().value();
m_time = time;
m_id = in.m_id;
Expand All @@ -93,21 +93,20 @@ AircraftState &AircraftState::Extrapolate(const AircraftState &in, const Units::
return *this;
}

Units::Speed AircraftState::GetTrueAirspeed() const {
Units::Speed interval_management::open_source::AircraftState::GetTrueAirspeed() const {
Units::MetersPerSecondSpeed tas_x, tas_y;
tas_x = Units::FeetPerSecondSpeed(m_xd) - m_sensed_wind_east_component;
tas_y = Units::FeetPerSecondSpeed(m_yd) - m_sensed_wind_north_component;
Units::MetersPerSecondSpeed tas = Units::sqrt(Units::sqr(tas_x) + Units::sqr(tas_y));
return tas;
}

AircraftState &AircraftState::Create(const int &id, const Units::Time &time,
const EarthModel::LocalPositionEnu &enu_position, const Units::Speed &xd,
const Units::Speed &yd, const Units::Speed &zd, const Units::Angle &gamma,
const Units::Speed &sensed_wind_east, 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) {
interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Create(
const int &id, const Units::Time &time, const EarthModel::LocalPositionEnu &enu_position, const Units::Speed &xd,
const Units::Speed &yd, const Units::Speed &zd, const Units::Angle &gamma, const Units::Speed &sensed_wind_east,
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;
Expand Down
8 changes: 2 additions & 6 deletions IntervalManagement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,5 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)

add_library(imalgs STATIC ${IMALGS_SOURCE_FILES} ${OBSERVER_SOURCE_FILES})
target_compile_options(imalgs PUBLIC "-Wno-inconsistent-missing-destructor-override" "-Wno-inconsistent-missing-override" "-Wno-overloaded-virtual")
target_include_directories(imalgs PUBLIC
${aaesim_INCLUDE_DIRS})
target_link_libraries(imalgs
pub)


target_include_directories(imalgs PUBLIC ${fmacm_INCLUDE_DIRS})
target_link_libraries(imalgs pub)
11 changes: 3 additions & 8 deletions IntervalManagement/ClosestPointMetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@

using namespace interval_management::open_source;

ClosestPointMetric::ClosestPointMetric(void) {
m_im_ac_id = 0;
m_target_ac_id = 0;
m_report_metrics = false;
mMinDist = Units::infinity();
}
ClosestPointMetric::ClosestPointMetric() = default;

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

Expand All @@ -38,8 +33,8 @@ void ClosestPointMetric::update(double imx, double imy, double targx, double tar
// imx,imy:position of IM aircraft.
// targx,targy:position of target aircraft.

Units::Length dist = AircraftCalculations::PtToPtDist(Units::FeetLength(imx), Units::FeetLength(imy),
Units::FeetLength(targx), Units::FeetLength(targy));
Units::Length dist = aaesim::open_source::AircraftCalculations::PtToPtDist(
Units::FeetLength(imx), Units::FeetLength(imy), Units::FeetLength(targx), Units::FeetLength(targy));

if (dist < mMinDist) {
mMinDist = dist;
Expand Down
Loading