INSTINCT Code Coverage Report


Directory: src/
File: Navigation/GNSS/Functions.cpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 11 29 37.9%
Functions: 4 7 57.1%
Branches: 5 32 15.6%

Line Branch Exec Source
1 // This file is part of INSTINCT, the INS Toolkit for Integrated
2 // Navigation Concepts and Training by the Institute of Navigation of
3 // the University of Stuttgart, Germany.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9 #include "Functions.hpp"
10
11 namespace NAV
12 {
13
14 81844 double doppler2rangeRate(double doppler, Frequency freq, int8_t num)
15 {
16 81844 return -InsConst::C / freq.getFrequency(num) * doppler;
17 }
18
19 double rangeRate2doppler(double rangeRate, Frequency freq, int8_t num)
20 {
21 return -freq.getFrequency(num) / InsConst::C * rangeRate;
22 }
23
24 104073 double ratioFreqSquared(Frequency f1, Frequency f2, int8_t num1, int8_t num2)
25 {
26 104073 return std::pow(f1.getFrequency(num1) / f2.getFrequency(num2), 2);
27 }
28
29 uint8_t galSisaVal2Idx(double val)
30 {
31 if (val < 0.0 || val > 6.0) { return 255; } // No Accuracy Prediction Available (NAPA)
32 if (val <= 0.5) { return static_cast<uint8_t>(static_cast<unsigned int>(val) / 0.01); }
33 if (val <= 1.0) { return static_cast<uint8_t>(static_cast<unsigned int>((val - 0.5)) / 0.02) + 50; }
34 if (val <= 2.0) { return static_cast<uint8_t>(static_cast<unsigned int>((val - 1.0)) / 0.04) + 75; }
35 return static_cast<uint8_t>(static_cast<unsigned int>((val - 2.0)) / 0.16) + 100;
36 }
37
38 225 double galSisaIdx2Val(uint8_t idx)
39 {
40
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if (idx <= 49) { return static_cast<double>(idx) * 0.01; }
41 if (idx <= 74) { return 0.5 + (static_cast<double>(idx) - 50.0) * 0.02; }
42 if (idx <= 99) { return 1.0 + (static_cast<double>(idx) - 75.0) * 0.04; }
43 if (idx <= 125) { return 2.0 + (static_cast<double>(idx) - 100.0) * 0.16; }
44 return 500.0;
45 }
46
47 uint8_t gpsUraVal2Idx(double val)
48 {
49 constexpr std::array<double, 15> URA = { 2.4, 3.4, 4.85, 6.85, 9.65, 13.65, 24.0, 48.0, 96.0, 192.0, 384.0, 768.0, 1536.0, 3072.0, 6144.0 };
50 return val < 0.0 ? static_cast<uint8_t>(URA.size())
51 : static_cast<uint8_t>(std::ranges::lower_bound(URA, val) - URA.begin());
52 }
53
54 245 double gpsUraIdx2Val(uint8_t idx)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if (idx == 1) { return 2.8; }
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if (idx == 3) { return 5.7; }
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if (idx == 5) { return 11.3; }
59
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if (idx <= 6) { return std::pow(2, 1.0 + idx / 2.0); }
60 if (idx < 15) { return std::pow(2, idx - 2); }
61 return 6144.0;
62 }
63
64 } // namespace NAV
65