mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Add more const, fix a bug in Galileo E5b generation
This commit is contained in:
parent
1e3d545034
commit
733ed54a98
@ -31,8 +31,8 @@
|
||||
|
||||
void galileo_e1_code_gen_int(own::span<int> _dest, const std::array<char, 3>& _Signal, int32_t _prn)
|
||||
{
|
||||
std::string _galileo_signal = _Signal.data();
|
||||
int32_t prn = _prn - 1;
|
||||
const std::string _galileo_signal = _Signal.data();
|
||||
const int32_t prn = _prn - 1;
|
||||
int32_t index = 0;
|
||||
|
||||
// A simple error check
|
||||
@ -63,7 +63,7 @@ void galileo_e1_code_gen_int(own::span<int> _dest, const std::array<char, 3>& _S
|
||||
void galileo_e1_sinboc_11_gen_int(own::span<int> _dest, own::span<const int> _prn)
|
||||
{
|
||||
constexpr uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
|
||||
const auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
|
||||
for (uint32_t i = 0; i < _length_in; i++)
|
||||
{
|
||||
for (uint32_t j = 0; j < (_period / 2); j++)
|
||||
@ -81,7 +81,7 @@ void galileo_e1_sinboc_11_gen_int(own::span<int> _dest, own::span<const int> _pr
|
||||
void galileo_e1_sinboc_61_gen_int(own::span<int> _dest, own::span<const int> _prn)
|
||||
{
|
||||
constexpr uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
|
||||
const auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
|
||||
|
||||
for (uint32_t i = 0; i < _length_in; i++)
|
||||
{
|
||||
@ -115,8 +115,7 @@ void galileo_e1_gen_float(own::span<float> _dest, own::span<int> _prn, const std
|
||||
constexpr uint32_t _codeLength = 12 * GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
const float alpha = std::sqrt(10.0F / 11.0F);
|
||||
const float beta = std::sqrt(1.0F / 11.0F);
|
||||
|
||||
std::string _galileo_signal = _Signal.data();
|
||||
const std::string _galileo_signal = _Signal.data();
|
||||
|
||||
std::array<int32_t, 12 * 4092> sinboc_11{};
|
||||
std::array<int32_t, 12 * 4092> sinboc_61{};
|
||||
@ -152,10 +151,10 @@ void galileo_e1_code_gen_float_sampled(own::span<float> _dest, const std::array<
|
||||
constexpr int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_CPS; // Hz
|
||||
const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2;
|
||||
const uint32_t _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
const std::string _galileo_signal = _Signal.data();
|
||||
auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS));
|
||||
const uint32_t delay = ((static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
|
||||
std::string _galileo_signal = _Signal.data();
|
||||
std::vector<int32_t> primary_code_E1_chips(static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS));
|
||||
|
||||
galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip
|
||||
@ -214,7 +213,7 @@ void galileo_e1_code_gen_complex_sampled(own::span<std::complex<float>> _dest, c
|
||||
bool _secondary_flag)
|
||||
{
|
||||
constexpr int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_CPS; // Hz
|
||||
std::string _galileo_signal = _Signal.data();
|
||||
const std::string _galileo_signal = _Signal.data();
|
||||
auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) /
|
||||
(static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS));
|
||||
|
||||
|
@ -35,7 +35,7 @@ void galileo_e5_a_code_gen_complex_primary(own::span<std::complex<float>> _dest,
|
||||
int32_t _prn,
|
||||
const std::array<char, 3>& _Signal)
|
||||
{
|
||||
uint32_t prn = _prn - 1;
|
||||
const uint32_t prn = _prn - 1;
|
||||
uint32_t index = 0;
|
||||
std::array<int32_t, 4> a{};
|
||||
if ((_prn < 1) || (_prn > 50))
|
||||
@ -102,18 +102,15 @@ void galileo_e5_a_code_gen_complex_sampled(own::span<std::complex<float>> _dest,
|
||||
int32_t _fs,
|
||||
uint32_t _chip_shift)
|
||||
{
|
||||
uint32_t _samplesPerCode;
|
||||
uint32_t delay;
|
||||
const uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS;
|
||||
const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_CPS;
|
||||
constexpr uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS;
|
||||
constexpr int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_CPS;
|
||||
|
||||
const auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
const uint32_t delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
std::vector<std::complex<float>> _code(_codeLength);
|
||||
galileo_e5_a_code_gen_complex_primary(_code, _prn, _Signal);
|
||||
|
||||
_samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
|
||||
delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
if (_fs != _codeFreqBasis)
|
||||
{
|
||||
std::vector<std::complex<float>> _resampled_signal(_samplesPerCode);
|
||||
@ -132,7 +129,7 @@ void galileo_e5_b_code_gen_complex_primary(own::span<std::complex<float>> _dest,
|
||||
int32_t _prn,
|
||||
const std::array<char, 3>& _Signal)
|
||||
{
|
||||
uint32_t prn = _prn - 1;
|
||||
const uint32_t prn = _prn - 1;
|
||||
uint32_t index = 0;
|
||||
std::array<int32_t, 4> a{};
|
||||
if ((_prn < 1) || (_prn > 50))
|
||||
@ -202,15 +199,12 @@ void galileo_e5_b_code_gen_complex_sampled(own::span<std::complex<float>> _dest,
|
||||
constexpr uint32_t _codeLength = GALILEO_E5B_CODE_LENGTH_CHIPS;
|
||||
constexpr int32_t _codeFreqBasis = GALILEO_E5B_CODE_CHIP_RATE_CPS;
|
||||
|
||||
auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
uint32_t delay;
|
||||
const auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
const uint32_t delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
std::vector<std::complex<float>> _code(_codeLength);
|
||||
galileo_e5_b_code_gen_complex_primary(_code, _prn, _Signal);
|
||||
|
||||
_samplesPerCode =
|
||||
delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
if (_fs != _codeFreqBasis)
|
||||
{
|
||||
std::vector<std::complex<float>> _resampled_signal(_samplesPerCode);
|
||||
|
@ -34,8 +34,7 @@ uint32_t gps_l2c_m_shift(uint32_t x)
|
||||
|
||||
void gps_l2c_m_code(own::span<int32_t> _dest, uint32_t _prn)
|
||||
{
|
||||
uint32_t x;
|
||||
x = GPS_L2C_M_INIT_REG[_prn - 1];
|
||||
uint32_t x = GPS_L2C_M_INIT_REG[_prn - 1];
|
||||
for (int32_t n = 0; n < GPS_L2_M_CODE_LENGTH_CHIPS; n++)
|
||||
{
|
||||
_dest[n] = static_cast<int8_t>(x & 1U);
|
||||
|
@ -3,7 +3,6 @@
|
||||
* \brief This class implements signal generators for the GPS L5 signals
|
||||
* \author Javier Arribas, 2017. jarribas(at)cttc.es
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
@ -25,41 +24,41 @@
|
||||
#include <cmath>
|
||||
#include <deque>
|
||||
|
||||
std::deque<bool> l5i_xa_shift(std::deque<bool> xa) // GPS-IS-705E Figure 3-4 pp. 15
|
||||
std::deque<bool> l5i_xa_shift(const std::deque<bool>& xa) // GPS-IS-705E Figure 3-4 pp. 15
|
||||
{
|
||||
if (xa == std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, false, true})
|
||||
{
|
||||
return std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, true, true};
|
||||
}
|
||||
std::deque<bool> out(xa.begin(), xa.end() - 1);
|
||||
std::deque<bool> out(xa.cbegin(), xa.cend() - 1);
|
||||
out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::deque<bool> l5q_xa_shift(std::deque<bool> xa)
|
||||
std::deque<bool> l5q_xa_shift(const std::deque<bool>& xa)
|
||||
{
|
||||
if (xa == std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, false, true})
|
||||
{
|
||||
return std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, true, true};
|
||||
}
|
||||
std::deque<bool> out(xa.begin(), xa.end() - 1);
|
||||
std::deque<bool> out(xa.cbegin(), xa.cend() - 1);
|
||||
out.push_front(xa[12] xor xa[11] xor xa[9] xor xa[8]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::deque<bool> l5i_xb_shift(std::deque<bool> xb) // GPS-IS-705E Figure 3-5 pp. 16
|
||||
std::deque<bool> l5i_xb_shift(const std::deque<bool>& xb) // GPS-IS-705E Figure 3-5 pp. 16
|
||||
{
|
||||
std::deque<bool> out(xb.begin(), xb.end() - 1);
|
||||
std::deque<bool> out(xb.cbegin(), xb.cend() - 1);
|
||||
out.push_front(xb[12] xor xb[11] xor xb[7] xor xb[6] xor xb[5] xor xb[3] xor xb[2] xor xb[0]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::deque<bool> l5q_xb_shift(std::deque<bool> xb)
|
||||
std::deque<bool> l5q_xb_shift(const std::deque<bool>& xb)
|
||||
{
|
||||
std::deque<bool> out(xb.begin(), xb.end() - 1);
|
||||
std::deque<bool> out(xb.cbegin(), xb.cend() - 1);
|
||||
out.push_front(xb[12] xor xb[11] xor xb[7] xor xb[6] xor xb[5] xor xb[3] xor xb[2] xor xb[0]);
|
||||
return out;
|
||||
}
|
||||
@ -123,10 +122,10 @@ std::deque<bool> make_l5q_xb()
|
||||
|
||||
void make_l5i(own::span<int32_t> _dest, int32_t prn)
|
||||
{
|
||||
int32_t xb_offset = GPS_L5I_INIT_REG[prn];
|
||||
const int32_t xb_offset = GPS_L5I_INIT_REG[prn];
|
||||
|
||||
std::deque<bool> xb = make_l5i_xb();
|
||||
std::deque<bool> xa = make_l5i_xa();
|
||||
const std::deque<bool> xb = make_l5i_xb();
|
||||
const std::deque<bool> xa = make_l5i_xa();
|
||||
std::deque<bool> xb_shift(GPS_L5I_CODE_LENGTH_CHIPS, false);
|
||||
|
||||
for (int32_t n = 0; n < GPS_L5I_CODE_LENGTH_CHIPS; n++)
|
||||
@ -143,10 +142,10 @@ void make_l5i(own::span<int32_t> _dest, int32_t prn)
|
||||
|
||||
void make_l5q(own::span<int32_t> _dest, int32_t prn)
|
||||
{
|
||||
int32_t xb_offset = GPS_L5Q_INIT_REG[prn];
|
||||
const int32_t xb_offset = GPS_L5Q_INIT_REG[prn];
|
||||
|
||||
std::deque<bool> xb = make_l5q_xb();
|
||||
std::deque<bool> xa = make_l5q_xa();
|
||||
const std::deque<bool> xb = make_l5q_xb();
|
||||
const std::deque<bool> xa = make_l5q_xa();
|
||||
std::deque<bool> xb_shift(GPS_L5Q_CODE_LENGTH_CHIPS, false);
|
||||
|
||||
for (int32_t n = 0; n < GPS_L5Q_CODE_LENGTH_CHIPS; n++)
|
||||
@ -271,18 +270,15 @@ void gps_l5q_code_gen_complex_sampled(own::span<std::complex<float>> _dest, uint
|
||||
make_l5q(_code, _prn - 1);
|
||||
}
|
||||
|
||||
int32_t _samplesPerCode;
|
||||
int32_t _codeValueIndex;
|
||||
float _ts;
|
||||
float _tc;
|
||||
const int32_t _codeLength = GPS_L5Q_CODE_LENGTH_CHIPS;
|
||||
constexpr int32_t _codeLength = GPS_L5Q_CODE_LENGTH_CHIPS;
|
||||
|
||||
// --- Find number of samples per spreading code ---------------------------
|
||||
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(GPS_L5Q_CODE_RATE_CPS) / static_cast<double>(_codeLength)));
|
||||
const auto _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(GPS_L5Q_CODE_RATE_CPS) / static_cast<double>(_codeLength)));
|
||||
|
||||
// --- Find time constants -------------------------------------------------
|
||||
_ts = 1.0F / static_cast<float>(_fs); // Sampling period in sec
|
||||
_tc = 1.0F / static_cast<float>(GPS_L5Q_CODE_RATE_CPS); // L5Q chip period in sec
|
||||
const float _ts = 1.0F / static_cast<float>(_fs); // Sampling period in sec
|
||||
constexpr float _tc = 1.0F / static_cast<float>(GPS_L5Q_CODE_RATE_CPS); // L5Q chip period in sec
|
||||
|
||||
for (int32_t i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
|
@ -27,18 +27,18 @@ const auto AUX_CEIL = [](float x) { return static_cast<int32_t>(static_cast<int6
|
||||
|
||||
void gps_l1_ca_code_gen_int(own::span<int32_t> _dest, int32_t _prn, uint32_t _chip_shift)
|
||||
{
|
||||
const uint32_t _code_length = 1023;
|
||||
constexpr uint32_t _code_length = 1023;
|
||||
std::bitset<_code_length> G1{};
|
||||
std::bitset<_code_length> G2{};
|
||||
std::bitset<10> G1_register{};
|
||||
std::bitset<10> G2_register{};
|
||||
bool feedback1;
|
||||
bool feedback2;
|
||||
bool aux;
|
||||
auto G1_register = std::bitset<10>{}.set(); // All true
|
||||
auto G2_register = std::bitset<10>{}.set(); // All true
|
||||
uint32_t lcv;
|
||||
uint32_t lcv2;
|
||||
uint32_t delay;
|
||||
int32_t prn_idx;
|
||||
bool feedback1;
|
||||
bool feedback2;
|
||||
bool aux;
|
||||
|
||||
// G2 Delays as defined in GPS-ISD-200D
|
||||
const std::array<int32_t, 51> delays = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254, 255, 256, 257, 258, 469, 470, 471, 472,
|
||||
@ -62,12 +62,6 @@ void gps_l1_ca_code_gen_int(own::span<int32_t> _dest, int32_t _prn, uint32_t _ch
|
||||
return;
|
||||
}
|
||||
|
||||
for (lcv = 0; lcv < 10; lcv++)
|
||||
{
|
||||
G1_register[lcv] = true;
|
||||
G2_register[lcv] = true;
|
||||
}
|
||||
|
||||
// Generate G1 & G2 Register
|
||||
for (lcv = 0; lcv < _code_length; lcv++)
|
||||
{
|
||||
@ -112,7 +106,7 @@ void gps_l1_ca_code_gen_int(own::span<int32_t> _dest, int32_t _prn, uint32_t _ch
|
||||
|
||||
void gps_l1_ca_code_gen_float(own::span<float> _dest, int32_t _prn, uint32_t _chip_shift)
|
||||
{
|
||||
const uint32_t _code_length = 1023;
|
||||
constexpr uint32_t _code_length = 1023;
|
||||
std::array<int32_t, _code_length> ca_code_int{};
|
||||
|
||||
gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift);
|
||||
@ -126,7 +120,7 @@ void gps_l1_ca_code_gen_float(own::span<float> _dest, int32_t _prn, uint32_t _ch
|
||||
|
||||
void gps_l1_ca_code_gen_complex(own::span<std::complex<float>> _dest, int32_t _prn, uint32_t _chip_shift)
|
||||
{
|
||||
const uint32_t _code_length = 1023;
|
||||
constexpr uint32_t _code_length = 1023;
|
||||
std::array<int32_t, _code_length> ca_code_int{};
|
||||
|
||||
gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift);
|
||||
@ -147,7 +141,7 @@ void gps_l1_ca_code_gen_complex_sampled(own::span<std::complex<float>> _dest, ui
|
||||
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
|
||||
constexpr int32_t _codeFreqBasis = 1023000; // Hz
|
||||
constexpr int32_t _codeLength = 1023;
|
||||
constexpr float _tc = 1.0 / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
|
||||
constexpr float _tc = 1.0F / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
|
||||
|
||||
const auto _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
const float _ts = 1.0F / static_cast<float>(_fs); // Sampling period in sec
|
||||
|
Loading…
Reference in New Issue
Block a user