0.3.0
Loading...
Searching...
No Matches
Functions.cpp
Go to the documentation of this file.
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
11namespace NAV
12{
13
14double doppler2rangeRate(double doppler, Frequency freq, int8_t num)
15{
16 return -InsConst::C / freq.getFrequency(num) * doppler;
17}
18
19double rangeRate2doppler(double rangeRate, Frequency freq, int8_t num)
20{
21 return -freq.getFrequency(num) / InsConst::C * rangeRate;
22}
23
24double ratioFreqSquared(Frequency f1, Frequency f2, int8_t num1, int8_t num2)
25{
26 return std::pow(f1.getFrequency(num1) / f2.getFrequency(num2), 2);
27}
28
29uint8_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
38double galSisaIdx2Val(uint8_t idx)
39{
40 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
47uint8_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
54double gpsUraIdx2Val(uint8_t idx)
55{
56 if (idx == 1) { return 2.8; }
57 if (idx == 3) { return 5.7; }
58 if (idx == 5) { return 11.3; }
59 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
GNSS helper functions.
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
double getFrequency(int8_t num) const
Get the frequency in [Hz].
static constexpr double C
Speed of light [m/s].
Definition Constants.hpp:34
double galSisaIdx2Val(uint8_t idx)
Converts a GALILEO SISA (Signal in space accuracy) index to it's value.
Definition Functions.cpp:38
double ratioFreqSquared(Frequency f1, Frequency f2, int8_t num1, int8_t num2)
Calculates the ration of the frequencies squared γ
Definition Functions.cpp:24
double gpsUraIdx2Val(uint8_t idx)
Converts a GPS URA (user range accuracy) index to it's value.
Definition Functions.cpp:54
uint8_t galSisaVal2Idx(double val)
Converts a GALILEO SISA (Signal in space accuracy) value to it's index.
Definition Functions.cpp:29
uint8_t gpsUraVal2Idx(double val)
Converts a GPS URA (user range accuracy) value to it's index.
Definition Functions.cpp:47
double doppler2rangeRate(double doppler, Frequency freq, int8_t num)
Transforms a doppler-shift into a range-rate.
Definition Functions.cpp:14
double rangeRate2doppler(double rangeRate, Frequency freq, int8_t num)
Transforms a range-rate into a doppler-shift.
Definition Functions.cpp:19