Skip to content

Commit cfd6bec

Browse files
Feat/update to v5.2.0 (#9)
* chore: sync code with internal 5.2.0; cmake build & test; github ci pipeline * chore: git ignores * docs: readme * chore: move file * chore: allow cmake 3.26 * chore: allow cmake 3.26 * docs: fixed broken link * chore: fix typo in ci.yml * docs: remove a section; clean up others * docs: * docs:
1 parent c10d0f7 commit cfd6bec

File tree

90 files changed

+1301
-3778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1301
-3778
lines changed

.cmake/get_cpm.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: MIT
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
4+
5+
set(CPM_DOWNLOAD_VERSION 0.40.8)
6+
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
7+
8+
if(CPM_SOURCE_CACHE)
9+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
10+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
11+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
12+
else()
13+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
14+
endif()
15+
16+
# Expand relative path. This is important if the provided path contains a tilde (~)
17+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
18+
19+
file(DOWNLOAD
20+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
21+
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
22+
)
23+
24+
include(${CPM_DOWNLOAD_LOCATION})

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
container: ${{ matrix.container }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: macos-latest
17+
container: ''
18+
install: |
19+
brew update
20+
brew upgrade
21+
- os: ubuntu-latest
22+
container: rockylinux:9
23+
install: |
24+
dnf -y install gcc gcc-c++ make cmake git
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install dependencies
29+
run: ${{ matrix.install }}
30+
31+
- name: Configure and Build
32+
run: |
33+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
34+
cmake --build build --target imalgs -j
35+
36+
37+
run_all_tests:
38+
runs-on: ubuntu-latest
39+
container:
40+
image: rockylinux:9
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Install dependencies
46+
run: |
47+
dnf -y install gcc gcc-c++ make cmake git
48+
49+
- name: Build project
50+
run: |
51+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
52+
53+
- name: Run tests
54+
run: |
55+
cmake --build build --target run_imalgs_test -j
56+
57+
- name: Upload test results
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: public-test-results
61+
path: unittest/*results.xml
62+
63+
# - name: Publish JUnit test results
64+
# uses: dorny/test-reporter@v2
65+
# if: always()
66+
# with:
67+
# name: Public Library Tests
68+
# path: unittest/*results.xml
69+
# reporter: jest-junit
70+
# fail-on-error: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

CMakeLists.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
cmake_minimum_required(VERSION 3.26...4.1.2)
2+
project(im_sample_algorithm VERSION 5.2.0.0) # the nano value is a boolean. 1 == SNAPSHOT, 0 == release
3+
4+
set (CMAKE_CXX_STANDARD 20)
5+
6+
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
7+
set (CMAKE_BUILD_TYPE "Release")
8+
endif()
9+
message (STATUS "${PROJECT_NAME}: Build type is ${CMAKE_BUILD_TYPE}")
10+
11+
option(BUILD_TESTING "Enable building ${PROJECT_NAME} tests" ON)
12+
if(NOT ${BUILD_TESTING})
13+
message(STATUS "${PROJECT_NAME}: skipping test targets")
14+
endif()
15+
16+
17+
include(${PROJECT_SOURCE_DIR}/.cmake/get_cpm.cmake)
18+
19+
if (${PROJECT_VERSION_TWEAK})
20+
# Append -SNAPSHOT to the version name if this is a pre-release version
21+
set(msg_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-SNAPSHOT)
22+
else()
23+
set(msg_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
24+
endif()
25+
message(STATUS "${PROJECT_NAME}: Generating build version ${msg_VERSION}")
26+
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
28+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-unused-function -Wno-sign-compare -O0 -g")
29+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-unused-function -Wno-sign-compare -O3 -g3")
30+
31+
# Begin project dependencies ------------------------------------------------------
32+
CPMAddPackage(
33+
NAME fmacm
34+
GITHUB_REPOSITORY mitre/FMACM
35+
GIT_TAG v5.2.0
36+
OPTIONS
37+
"BUILD_SHARED_LIBS FALSE"
38+
"BUILD_TESTING ${BUILD_TESTING}"
39+
)
40+
41+
# CPMAddPackage(
42+
# NAME unitslib
43+
# GIT_REPOSITORY https://mustache.mitre.org/scm/aaes/cpp-uom.git # FIXME use external repo when available
44+
# GIT_TAG 07445f7ec0f98b55cdd6e6188083145a293415a7
45+
# DOWNLOAD_ONLY TRUE
46+
# )
47+
48+
CPMAddPackage(
49+
NAME log4cplus
50+
GITHUB_REPOSITORY log4cplus/log4cplus
51+
GIT_TAG REL_2_1_2
52+
OPTIONS
53+
"BUILD_SHARED_LIBS FALSE"
54+
"LOG4CPLUS_BUILD_TESTING FALSE"
55+
"LOG4CPLUS_BUILD_LOGGINGSERVER FALSE"
56+
)
57+
58+
# Create some common paths
59+
if (log4cplus_ADDED)
60+
set (LOG4CPLUS_DIRS
61+
${log4cplus_BINARY_DIR}/include
62+
${log4cplus_SOURCE_DIR}/include)
63+
endif ()
64+
65+
set (unitslib_INCLUDE_DIRS ${fmacm_SOURCE_DIR}/units-2.1/src/)
66+
set (LOADER_DIR ${fmacm_SOURCE_DIR}/Loader)
67+
set (PUBLIC_DIR ${fmacm_SOURCE_DIR}/Public)
68+
set (IM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/IntervalManagement)
69+
set (fmacm_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
70+
${fmacm_SOURCE_DIR}/include)
71+
set (UNITTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unittest)
72+
73+
add_subdirectory(${IM_DIR})
74+
add_subdirectory(${UNITTEST_DIR})
75+
include(${UNITTEST_DIR}/unittest.cmake)

IntervalManagement/AchieveObserver.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
// 2023 The MITRE Corporation. All Rights Reserved.
1818
// ****************************************************************************
1919

20-
#include <cstdio>
2120
#include "imalgs/AchieveObserver.h"
2221

22+
#include <cstdio>
23+
2324
using namespace std;
2425
using namespace interval_management::open_source;
2526

@@ -60,9 +61,9 @@ string AchieveObserver::ToString() {
6061

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

63-
sprintf(txt, "%d,%d,%lf,%lf,%lf,%lf,%lf", m_iteration, m_id, Units::SecondsTime(m_time).value(),
64-
Units::SecondsTime(m_targ_ttg_to_ach).value(), Units::SecondsTime(m_own_ttg_to_ach).value(),
65-
Units::MetersLength(m_curr_dist).value(), Units::MetersLength(m_ref_dist).value());
64+
snprintf(txt, 301, "%d,%d,%lf,%lf,%lf,%lf,%lf", m_iteration, m_id, Units::SecondsTime(m_time).value(),
65+
Units::SecondsTime(m_targ_ttg_to_ach).value(), Units::SecondsTime(m_own_ttg_to_ach).value(),
66+
Units::MetersLength(m_curr_dist).value(), Units::MetersLength(m_ref_dist).value());
6667

6768
str = txt;
6869

IntervalManagement/AchievePointCalcs.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
5858

5959
AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftIntent &intent, const VerticalPath &vpath,
6060
const vector<HorizontalPath> &htraj, const AchievePointCalcs &ownship_calcs,
61-
const AircraftIntent &ownship_intent) {
61+
const AircraftIntent &ownship_intent,
62+
const std::shared_ptr<TangentPlaneSequence> &position_converter) {
6263
Clear();
6364

6465
m_waypoint_name = waypoint;
@@ -69,16 +70,16 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
6970
if (m_waypoint_name == "CALCULATED_TRP") {
7071
Waypoint traffic_reference_point;
7172
size_t waypoint_index;
72-
ComputeDefaultTRP(ownship_calcs, ownship_intent, intent, m_horizontal_path, traffic_reference_point, m_waypoint_x,
73-
m_waypoint_y, waypoint_index);
73+
ComputeDefaultTRP(ownship_calcs, ownship_intent, intent, position_converter, m_horizontal_path,
74+
traffic_reference_point, m_waypoint_x, m_waypoint_y, waypoint_index);
7475
LOG4CPLUS_DEBUG(m_logger, "Calculated TRP = (" << m_waypoint_x << "," << m_waypoint_y << ")");
7576
// log the geographic coordinates
7677
EarthModel::LocalPositionEnu xy;
7778
xy.x = m_waypoint_x;
7879
xy.y = m_waypoint_y;
7980
xy.z = Units::zero();
8081
EarthModel::GeodeticPosition geo;
81-
intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
82+
position_converter->ConvertLocalToGeodetic(xy, geo);
8283
LOG4CPLUS_DEBUG(m_logger, "(lat,lon) = (" << std::setprecision(10) << Units::DegreesAngle(geo.latitude) << ","
8384
<< Units::DegreesAngle(geo.longitude) << ")");
8485
} else {
@@ -87,8 +88,6 @@ AchievePointCalcs::AchievePointCalcs(const string &waypoint, const AircraftInten
8788
ComputeEndValues(vpath);
8889
}
8990

90-
AchievePointCalcs::~AchievePointCalcs() = default;
91-
9291
void AchievePointCalcs::Clear() {
9392

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

108107
void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs, const AircraftIntent &ownship_intent,
109108
const AircraftIntent &target_intent,
109+
const std::shared_ptr<TangentPlaneSequence> &position_converter,
110110
const vector<HorizontalPath> &target_horizontal_path,
111111
Waypoint &traffic_reference_point, Units::Length &waypoint_x,
112112
Units::Length &waypoint_y, size_t &waypoint_index_in_target_intent) {
@@ -154,7 +154,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
154154
// Search horizontal path for an intersecting segment
155155
HorizontalTurnPath trp_turn;
156156
bool first(true), crossed(false), end_is_usable(false);
157-
double x0, y0, d0;
157+
double x0{}, y0{}, d0{};
158158
vector<HorizontalPath>::const_iterator hpi;
159159
for (hpi = target_horizontal_path.begin(); hpi != target_horizontal_path.end(); ++hpi) {
160160
double x1 = hpi->GetXPositionMeters();
@@ -343,7 +343,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
343343
xy.y = waypoint_y;
344344
xy.z = Units::zero();
345345
EarthModel::GeodeticPosition geo;
346-
target_intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
346+
position_converter->ConvertLocalToGeodetic(xy, geo);
347347

348348
// populate traffic_reference_point
349349
traffic_reference_point.SetName("CALCULATED_TRP");
@@ -353,7 +353,7 @@ void AchievePointCalcs::ComputeDefaultTRP(const AchievePointCalcs &ownship_calcs
353353
if (trp_turn.radius > Units::zero()) {
354354
xy.x = Units::MetersLength(trp_turn.x_position_meters);
355355
xy.y = Units::MetersLength(trp_turn.y_position_meters);
356-
target_intent.GetTangentPlaneSequence()->convertLocalToGeodetic(xy, geo);
356+
position_converter->ConvertLocalToGeodetic(xy, geo);
357357
traffic_reference_point.SetRfTurnCenterLatitude(geo.latitude);
358358
traffic_reference_point.SetRfTurnCenterLongitude(geo.longitude);
359359
} else {

IntervalManagement/AircraftState.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
#include "utility/CustomUnits.h"
2323
#include "imalgs/IMUtils.h"
2424

25-
using namespace interval_management::open_source;
26-
2725
log4cplus::Logger interval_management::open_source::AircraftState::m_logger =
2826
log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("AircraftState"));
2927

30-
AircraftState::AircraftState()
28+
interval_management::open_source::AircraftState::AircraftState()
3129
: m_x(0),
3230
m_y(0),
3331
m_z(0),
@@ -45,17 +43,18 @@ AircraftState::AircraftState()
4543
m_gamma(Units::ZERO_ANGLE),
4644
m_sensed_temperature(Units::negInfinity()) {}
4745

48-
const Units::UnsignedRadiansAngle AircraftState::GetHeadingCcwFromEastRadians() const {
46+
const Units::UnsignedRadiansAngle interval_management::open_source::AircraftState::GetHeadingCcwFromEastRadians()
47+
const {
4948
double result = atan3(m_yd, m_xd);
5049
return Units::UnsignedRadiansAngle(result);
5150
}
5251

53-
const Units::Speed AircraftState::GetGroundSpeed() const {
52+
const Units::Speed interval_management::open_source::AircraftState::GetGroundSpeed() const {
5453
return Units::FeetPerSecondSpeed(sqrt(pow(m_xd, 2) + pow(m_yd, 2)));
5554
}
5655

57-
AircraftState &AircraftState::Interpolate(const AircraftState &a, const AircraftState &b,
58-
const Units::SecondsTime time) {
56+
interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Interpolate(
57+
const AircraftState &a, const AircraftState &b, const Units::SecondsTime time) {
5958

6059
const double dt = Units::SecondsTime(b.GetTimeStamp() - a.GetTimeStamp()).value();
6160
double weight_a, weight_b;
@@ -80,7 +79,8 @@ AircraftState &AircraftState::Interpolate(const AircraftState &a, const Aircraft
8079
return *this;
8180
}
8281

83-
AircraftState &AircraftState::Extrapolate(const AircraftState &in, const Units::SecondsTime &time) {
82+
interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Extrapolate(
83+
const AircraftState &in, const Units::SecondsTime &time) {
8484
const double dt = time.value() - in.GetTimeStamp().value();
8585
m_time = time;
8686
m_id = in.m_id;
@@ -93,21 +93,20 @@ AircraftState &AircraftState::Extrapolate(const AircraftState &in, const Units::
9393
return *this;
9494
}
9595

96-
Units::Speed AircraftState::GetTrueAirspeed() const {
96+
Units::Speed interval_management::open_source::AircraftState::GetTrueAirspeed() const {
9797
Units::MetersPerSecondSpeed tas_x, tas_y;
9898
tas_x = Units::FeetPerSecondSpeed(m_xd) - m_sensed_wind_east_component;
9999
tas_y = Units::FeetPerSecondSpeed(m_yd) - m_sensed_wind_north_component;
100100
Units::MetersPerSecondSpeed tas = Units::sqrt(Units::sqr(tas_x) + Units::sqr(tas_y));
101101
return tas;
102102
}
103103

104-
AircraftState &AircraftState::Create(const int &id, const Units::Time &time,
105-
const EarthModel::LocalPositionEnu &enu_position, const Units::Speed &xd,
106-
const Units::Speed &yd, const Units::Speed &zd, const Units::Angle &gamma,
107-
const Units::Speed &sensed_wind_east, const Units::Speed &sensed_wind_north,
108-
const Units::Speed &sensed_wind_parallel,
109-
const Units::Speed &sensed_wind_perpendicular,
110-
const Units::Temperature &sensed_temperature, const Units::Angle &psi_enu) {
104+
interval_management::open_source::AircraftState &interval_management::open_source::AircraftState::Create(
105+
const int &id, const Units::Time &time, const EarthModel::LocalPositionEnu &enu_position, const Units::Speed &xd,
106+
const Units::Speed &yd, const Units::Speed &zd, const Units::Angle &gamma, const Units::Speed &sensed_wind_east,
107+
const Units::Speed &sensed_wind_north, const Units::Speed &sensed_wind_parallel,
108+
const Units::Speed &sensed_wind_perpendicular, const Units::Temperature &sensed_temperature,
109+
const Units::Angle &psi_enu) {
111110

112111
this->m_id = id;
113112
this->m_time = time;

IntervalManagement/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,5 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
4747

4848
add_library(imalgs STATIC ${IMALGS_SOURCE_FILES} ${OBSERVER_SOURCE_FILES})
4949
target_compile_options(imalgs PUBLIC "-Wno-inconsistent-missing-destructor-override" "-Wno-inconsistent-missing-override" "-Wno-overloaded-virtual")
50-
target_include_directories(imalgs PUBLIC
51-
${aaesim_INCLUDE_DIRS})
52-
target_link_libraries(imalgs
53-
pub)
54-
55-
50+
target_include_directories(imalgs PUBLIC ${fmacm_INCLUDE_DIRS})
51+
target_link_libraries(imalgs pub)

IntervalManagement/ClosestPointMetric.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222

2323
using namespace interval_management::open_source;
2424

25-
ClosestPointMetric::ClosestPointMetric(void) {
26-
m_im_ac_id = 0;
27-
m_target_ac_id = 0;
28-
m_report_metrics = false;
29-
mMinDist = Units::infinity();
30-
}
25+
ClosestPointMetric::ClosestPointMetric() = default;
3126

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

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

41-
Units::Length dist = AircraftCalculations::PtToPtDist(Units::FeetLength(imx), Units::FeetLength(imy),
42-
Units::FeetLength(targx), Units::FeetLength(targy));
36+
Units::Length dist = aaesim::open_source::AircraftCalculations::PtToPtDist(
37+
Units::FeetLength(imx), Units::FeetLength(imy), Units::FeetLength(targx), Units::FeetLength(targy));
4338

4439
if (dist < mMinDist) {
4540
mMinDist = dist;

0 commit comments

Comments
 (0)