mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-06-04 23:54:08 +00:00
Fix offset in sampled PRN codes
This commit is contained in:
parent
77dccae34e
commit
0fa695a825
@ -19,8 +19,7 @@
|
||||
#include "glonass_l1_signal_replica.h"
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
|
||||
const auto AUX_CEIL = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
|
||||
#include <cmath>
|
||||
|
||||
void glonass_l1_ca_code_gen_complex(own::span<std::complex<float>> dest, uint32_t chip_shift)
|
||||
{
|
||||
@ -104,8 +103,8 @@ void glonass_l1_ca_code_gen_complex_sampled(own::span<std::complex<float>> dest,
|
||||
// number of samples per millisecond (because one C/A code period is
|
||||
// one millisecond).
|
||||
|
||||
aux = (ts * (static_cast<float>(i) + 1)) / tc;
|
||||
codeValueIndex = AUX_CEIL(aux) - 1;
|
||||
aux = ts * static_cast<float>(i) / tc;
|
||||
codeValueIndex = static_cast<int32_t>(std::floor(aux));
|
||||
|
||||
// --- Make the digitized version of the C/A code ------------------
|
||||
// The "upsampled" code is made by selecting values form the CA code
|
||||
|
@ -19,8 +19,7 @@
|
||||
#include "glonass_l2_signal_replica.h"
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
|
||||
const auto AUX_CEIL = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
|
||||
#include <cmath>
|
||||
|
||||
void glonass_l2_ca_code_gen_complex(own::span<std::complex<float>> dest, uint32_t chip_shift)
|
||||
{
|
||||
@ -104,8 +103,8 @@ void glonass_l2_ca_code_gen_complex_sampled(own::span<std::complex<float>> dest,
|
||||
// number of samples per millisecond (because one C/A code period is
|
||||
// one millisecond).
|
||||
|
||||
aux = (ts * (static_cast<float>(i) + 1)) / tc;
|
||||
codeValueIndex = AUX_CEIL(aux) - 1;
|
||||
aux = ts * static_cast<float>(i) / tc;
|
||||
codeValueIndex = static_cast<int32_t>(std::floor(aux));
|
||||
|
||||
// --- Make the digitized version of the C/A code ------------------
|
||||
// The "upsampled" code is made by selecting values form the CA code
|
||||
|
@ -19,11 +19,10 @@
|
||||
#include "gnss_signal_replica.h"
|
||||
#include "MATH_CONSTANTS.h"
|
||||
#include <gnuradio/fxpt_nco.h>
|
||||
#include <cmath>
|
||||
#include <cstddef> // for size_t
|
||||
|
||||
|
||||
const auto AUX_CEIL2 = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
|
||||
|
||||
void complex_exp_gen(own::span<std::complex<float>> dest, double freq, double sampling_freq)
|
||||
{
|
||||
gr::fxpt_nco d_nco;
|
||||
@ -258,13 +257,11 @@ void resampler(const own::span<float> from, own::span<float> dest, float fs_in,
|
||||
float fs_out)
|
||||
{
|
||||
uint32_t codeValueIndex;
|
||||
float aux;
|
||||
const float t_out = 1.0F / fs_out; // Output sampling period
|
||||
const size_t dest_size = dest.size();
|
||||
for (size_t i = 0; i < dest_size - 1; i++)
|
||||
{
|
||||
aux = (t_out * (static_cast<float>(i) + 1.0F)) * fs_in;
|
||||
codeValueIndex = AUX_CEIL2(aux) - 1;
|
||||
codeValueIndex = static_cast<uint32_t>(std::floor(t_out * i * fs_in));
|
||||
dest[i] = from[codeValueIndex];
|
||||
}
|
||||
// Correct the last index (due to number rounding issues)
|
||||
@ -281,8 +278,8 @@ void resampler(own::span<const std::complex<float>> from, own::span<std::complex
|
||||
const size_t dest_size = dest.size();
|
||||
for (size_t i = 0; i < dest_size - 1; i++)
|
||||
{
|
||||
aux = (t_out * (static_cast<float>(i) + 1.0F)) * fs_in;
|
||||
codeValueIndex = AUX_CEIL2(aux) - 1;
|
||||
aux = (t_out * (static_cast<float>(i))) * fs_in;
|
||||
codeValueIndex = static_cast<uint32_t>(std::floor(aux));
|
||||
dest[i] = from[codeValueIndex];
|
||||
}
|
||||
// Correct the last index (due to number rounding issues)
|
||||
|
@ -92,7 +92,7 @@ void gps_l2c_m_code_gen_complex_sampled(own::span<std::complex<float>> dest, uin
|
||||
// === Digitizing ==================================================
|
||||
|
||||
// --- Make index array to read L2C code values --------------------
|
||||
codeValueIndex = std::ceil((ts * (static_cast<float>(i) + 1.0F)) / tc) - 1;
|
||||
codeValueIndex = static_cast<int32_t>(std::floor(ts * static_cast<float>(i) / tc));
|
||||
|
||||
// --- Make the digitized version of the L2C code ------------------
|
||||
if (i == samplesPerCode - 1)
|
||||
|
@ -210,7 +210,7 @@ void gps_l5i_code_gen_complex_sampled(own::span<std::complex<float>> dest, uint3
|
||||
// === Digitizing ==================================================
|
||||
|
||||
// --- Make index array to read L5 code values ---------------------
|
||||
codeValueIndex = static_cast<int32_t>(std::ceil(ts * (i + 1.0F) / tc)) - 1;
|
||||
codeValueIndex = static_cast<int32_t>(std::floor(ts * static_cast<float>(i) / tc));
|
||||
|
||||
// --- Make the digitized version of the L5I code ------------------
|
||||
if (i == samplesPerCode - 1)
|
||||
|
@ -19,8 +19,7 @@
|
||||
#include "gps_sdr_signal_replica.h"
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
|
||||
const auto AUX_CEIL = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
|
||||
#include <cmath>
|
||||
|
||||
void gps_l1_ca_code_gen_int(own::span<int32_t> dest, int32_t prn, uint32_t chip_shift)
|
||||
{
|
||||
@ -144,7 +143,6 @@ void gps_l1_ca_code_gen_complex_sampled(own::span<std::complex<float>> dest, uin
|
||||
const float ts = 1.0F / static_cast<float>(sampling_freq); // Sampling period in sec
|
||||
std::array<std::complex<float>, 1023> code_aux{};
|
||||
int32_t codeValueIndex;
|
||||
float aux;
|
||||
|
||||
gps_l1_ca_code_gen_complex(code_aux, prn, chip_shift); // generate C/A code 1 sample per chip
|
||||
|
||||
@ -157,8 +155,7 @@ void gps_l1_ca_code_gen_complex_sampled(own::span<std::complex<float>> dest, uin
|
||||
// number of samples per millisecond (because one C/A code period is one
|
||||
// millisecond).
|
||||
|
||||
aux = (ts * (static_cast<float>(i) + 1)) / tc;
|
||||
codeValueIndex = AUX_CEIL(aux) - 1;
|
||||
codeValueIndex = static_cast<int32_t>(std::floor(ts * static_cast<float>(i) / tc));
|
||||
|
||||
// --- Make the digitized version of the C/A code -------------------
|
||||
// The "upsampled" code is made by selecting values form the CA code
|
||||
|
Loading…
x
Reference in New Issue
Block a user