2023-12-29 01:08:49 +00:00
|
|
|
/// @file TestTracker.cpp
|
|
|
|
/// @brief Unit test for Tracker.cpp
|
|
|
|
/// @author 30hours
|
|
|
|
|
2023-12-24 01:07:03 +00:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
2024-01-11 09:11:49 +00:00
|
|
|
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
2023-12-29 01:08:49 +00:00
|
|
|
|
2023-12-24 05:35:27 +00:00
|
|
|
#include "data/Detection.h"
|
|
|
|
#include "data/Track.h"
|
|
|
|
#include "process/tracker/Tracker.h"
|
2024-01-20 12:43:31 +00:00
|
|
|
#include "data/meta/Constants.h"
|
2023-12-24 05:35:27 +00:00
|
|
|
|
2023-12-29 01:08:49 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <random>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
/// @brief Test constructor.
|
|
|
|
/// @details Check constructor parameters created correctly.
|
|
|
|
TEST_CASE("Constructor", "[constructor]")
|
|
|
|
{
|
2024-01-11 09:11:49 +00:00
|
|
|
uint32_t m = 3;
|
|
|
|
uint32_t n = 5;
|
|
|
|
uint32_t nDelete = 5;
|
|
|
|
double cpi = 1;
|
|
|
|
double maxAccInit = 10;
|
|
|
|
double fs = 2000000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double rangeRes = (double)Constants::c/fs;
|
2024-01-11 09:11:49 +00:00
|
|
|
double fc = 204640000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double lambda = (double)Constants::c/fc;
|
2024-01-11 09:11:49 +00:00
|
|
|
Tracker tracker = Tracker(m, n, nDelete,
|
|
|
|
cpi, maxAccInit, rangeRes, lambda);
|
2023-12-29 01:08:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Test process for an ACTIVE track.
|
|
|
|
TEST_CASE("Process ACTIVE track constant acc", "[process]")
|
|
|
|
{
|
|
|
|
uint32_t m = 3;
|
|
|
|
uint32_t n = 5;
|
|
|
|
uint32_t nDelete = 5;
|
2024-01-11 09:11:49 +00:00
|
|
|
double cpi = 1;
|
2023-12-29 01:08:49 +00:00
|
|
|
double maxAccInit = 10;
|
2024-01-11 09:11:49 +00:00
|
|
|
double fs = 2000000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double rangeRes = (double)Constants::c/fs;
|
2024-01-11 09:11:49 +00:00
|
|
|
double fc = 204640000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double lambda = (double)Constants::c/fc;
|
2023-12-29 01:08:49 +00:00
|
|
|
Tracker tracker = Tracker(m, n, nDelete,
|
2024-01-11 09:11:49 +00:00
|
|
|
cpi, maxAccInit, rangeRes, lambda);
|
2023-12-29 01:08:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
// create detections with constant acc 5 Hz/s
|
2024-01-11 09:11:49 +00:00
|
|
|
std::vector<uint64_t> timestamp = {0,1,2,3,4,5,6,7,8,9,10};
|
2023-12-29 01:08:49 +00:00
|
|
|
std::vector<double> delay = {10};
|
2024-01-11 09:11:49 +00:00
|
|
|
std::vector<double> doppler = {-20,-15,-10,-5,0,5,10,15,20,25};
|
2023-12-29 01:08:49 +00:00
|
|
|
|
|
|
|
std::string state = "ACTIVE";
|
2024-01-11 09:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Test predict for kinematics equations.
|
|
|
|
TEST_CASE("Test predict", "[predict]")
|
|
|
|
{
|
|
|
|
uint32_t m = 3;
|
|
|
|
uint32_t n = 5;
|
|
|
|
uint32_t nDelete = 5;
|
|
|
|
double cpi = 1;
|
|
|
|
double maxAccInit = 10;
|
|
|
|
double fs = 2000000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double rangeRes = (double)Constants::c/fs;
|
2024-01-11 09:11:49 +00:00
|
|
|
double fc = 204640000;
|
2024-01-20 12:43:31 +00:00
|
|
|
double lambda = (double)Constants::c/fc;
|
2024-01-11 09:11:49 +00:00
|
|
|
Tracker tracker = Tracker(m, n, nDelete,
|
|
|
|
cpi, maxAccInit, rangeRes, lambda);
|
|
|
|
|
|
|
|
Detection input = Detection(10, -20, 0);
|
|
|
|
double acc = 5;
|
|
|
|
double T = 1;
|
|
|
|
Detection prediction = tracker.predict(input, acc, T);
|
|
|
|
Detection prediction_truth = Detection(9.821, -15, 0);
|
|
|
|
|
|
|
|
CHECK_THAT(prediction.get_delay().front(),
|
|
|
|
Catch::Matchers::WithinAbs(prediction_truth.get_delay().front(), 0.01));
|
|
|
|
CHECK_THAT(prediction.get_doppler().front(),
|
|
|
|
Catch::Matchers::WithinAbs(prediction_truth.get_doppler().front(), 0.01));
|
2023-12-29 01:08:49 +00:00
|
|
|
}
|