mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-12 21:33:02 +00:00
bds_b3i: bug fix in code generation
Moved code generation logic to use bool type to keep same notation as the previous implementations. More testing in code is required
This commit is contained in:
@@ -269,10 +269,10 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration,
|
||||
|
||||
int num_bands = 0;
|
||||
|
||||
if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) num_bands = 1;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0) || (bds_B1_count > 0))) num_bands = 2;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 2;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0) || (bds_B1_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 3;
|
||||
if (( gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) num_bands = 1;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0) || (bds_B3_count > 0))) num_bands = 2;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 2;
|
||||
if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0) || (bds_B3_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 3;
|
||||
|
||||
int number_of_frequencies = configuration->property(role + ".num_bands", num_bands); /* (1:L1, 2:L1+L2, 3:L1+L2+L5) */
|
||||
if ((number_of_frequencies < 1) || (number_of_frequencies > 3))
|
||||
@@ -356,7 +356,7 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration,
|
||||
if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) nsys += SYS_GPS;
|
||||
if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) nsys += SYS_GAL;
|
||||
if ((glo_1G_count > 0) || (glo_2G_count > 0)) nsys += SYS_GLO;
|
||||
if ((bds_B1_count > 0)) nsys += SYS_BDS;
|
||||
if ((bds_B1_count > 0) || (bds_B3_count > 0)) nsys += SYS_BDS;
|
||||
|
||||
int navigation_system = configuration->property(role + ".navigation_system", nsys); /* (SYS_XXX) see src/algorithms/libs/rtklib/rtklib.h */
|
||||
if ((navigation_system < 1) || (navigation_system > 255)) /* GPS: 1 SBAS: 2 GPS+SBAS: 3 Galileo: 8 Galileo+GPS: 9 GPS+SBAS+Galileo: 11 All: 255 */
|
||||
|
||||
@@ -37,84 +37,89 @@ auto auxCeil = [](float x) { return static_cast<int>(static_cast<long>((x) + 1))
|
||||
void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift)
|
||||
{
|
||||
const unsigned int _code_length = 10230;
|
||||
int8_t G1[_code_length];
|
||||
int8_t G2[_code_length];
|
||||
std::array<int8_t,13> G1_register = {{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}};
|
||||
std::array<int8_t,13> G2_register = {{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}};
|
||||
std::array<int8_t,13> G1_register_reset = {{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1}};
|
||||
int8_t feedback1, feedback2;
|
||||
uint32_t lcv, lcv2;
|
||||
bool G1[_code_length];
|
||||
bool G2[_code_length];
|
||||
std::array<bool,13> G1_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}};
|
||||
std::array<bool,13> G2_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}};
|
||||
std::array<bool,13> G1_register_reset = {{0,0,1,1,1,1,1,1,1,1,1,1,1}};
|
||||
bool feedback1, feedback2, aux;
|
||||
uint32_t lcv, lcv2, delay;
|
||||
int32_t prn_idx = _prn - 1;
|
||||
|
||||
std::array<std::array<int8_t, 13>, 63> G2_register_shifted = {{
|
||||
{{-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1}}, {{-1,-1,-1,-1,1,1,1,-1,1,-1,1,-1,-1}},
|
||||
{{-1,1,-1,-1,-1,-1,1,1,1,-1,1,-1,1}}, {{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1}},
|
||||
{{-1,-1,1,1,-1,1,1,1,-1,-1,-1,-1,-1}}, {{-1,1,1,-1,1,1,-1,-1,1,1,-1,1,1}},
|
||||
{{-1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1}}, {{-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1}},
|
||||
{{-1,1,-1,1,1,1,1,1,1,1,1,-1,1}}, {{1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1}},
|
||||
{{-1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1}}, {{1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,1}},
|
||||
{{1,-1,-1,1,1,-1,1,1,-1,1,-1,1,-1}}, {{1,-1,-1,-1,1,1,1,-1,1,1,-1,-1,1}},
|
||||
{{-1,1,1,1,-1,-1,1,1,1,-1,1,1,-1}}, {{-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1}},
|
||||
{{1,1,-1,1,1,-1,-1,1,1,1,-1,1,-1}}, {{1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1}},
|
||||
{{-1,1,1,1,-1,1,-1,1,-1,1,-1,-1,-1}}, {{1,1,1,-1,1,-1,-1,1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,0,1,}}, {{0,1,1,0,1,1,0,1,1,1,1,0,0,}}, {{1,1,0,1,0,0,1,1,1,0,0,0,1,}},
|
||||
{{0,0,1,1,1,0,0,1,0,0,0,1,0,}}, {{0,1,0,1,0,1,1,0,0,0,1,0,1,}}, {{1,0,0,1,1,1,1,1,0,0,1,1,0,}}, {{1,1,1,1,1,0,1,0,0,1,0,0,0,}},
|
||||
{{0,0,0,0,1,0,1,0,0,1,0,0,1,}}, {{1,0,0,0,0,1,0,1,0,1,1,0,0,}}, {{1,1,1,1,0,0,1,0,0,1,1,0,0,}}, {{0,1,0,0,1,1,0,0,0,1,1,1,1,}},
|
||||
{{0,0,0,0,0,0,0,0,1,1,0,0,0,}}, {{1,0,0,0,0,0,0,0,0,0,1,0,0,}}, {{0,0,1,1,0,1,0,1,0,0,1,1,0,}}, {{1,0,1,1,0,0,1,0,0,0,1,1,0,}},
|
||||
{{0,1,1,1,0,0,1,1,1,1,0,0,0,}}, {{0,0,1,0,1,1,1,0,0,1,0,1,0,}}, {{1,1,0,0,1,1,1,1,1,0,1,1,0,}}, {{1,0,0,1,0,0,1,0,0,0,1,0,1,}},
|
||||
{{0,1,1,1,0,0,0,1,0,0,0,0,0,}}, {{0,0,1,1,0,0,1,0,0,0,0,1,0,}}, {{0,0,1,0,0,0,1,0,0,1,1,1,0,}}}};
|
||||
|
||||
/* A simple error check */
|
||||
if ((prn_idx < 0) || (prn_idx > 64))
|
||||
// A simple error check
|
||||
if ((prn_idx < 0) || (prn_idx > 63))
|
||||
return;
|
||||
|
||||
/*Assign shifted G2 register based on prn number*/
|
||||
// Assign shifted G2 register based on prn number
|
||||
G2_register = G2_register_shifted[prn_idx];
|
||||
std::reverse(G2_register.begin(), G2_register.end()) ;
|
||||
|
||||
/* Generate G1 and G2 Register */
|
||||
// Generate G1 and G2 Register
|
||||
for (lcv = 0; lcv < _code_length; lcv++)
|
||||
{
|
||||
G1[lcv] = G1_register[12];
|
||||
G2[lcv] = G2_register[12];
|
||||
G1[lcv] = G1_register[0];
|
||||
G2[lcv] = G2_register[0];
|
||||
|
||||
feedback1 = G1_register[0]*G1_register[2]*G1_register[3]*G1_register[12];
|
||||
feedback2 = G2_register[0]*G2_register[4]*G2_register[5]*G2_register[6]*
|
||||
G2_register[8]*G2_register[9]*G2_register[11]*G2_register[12];
|
||||
//feedback1 = (test_G1_register[0]+test_G1_register[2]+test_G1_register[3]+test_G1_register[12]) & 0x1;
|
||||
feedback1 = (G1_register[0]+G1_register[9]+G1_register[10]+G1_register[12]) & 0x01;
|
||||
feedback2 = (G2_register[0]+G2_register[1]+G2_register[3]+G2_register[4]+
|
||||
G2_register[6]+G2_register[7]+G2_register[8]+G2_register[12]) & 0x01;
|
||||
|
||||
for (lcv2 = 0; lcv2 < 12; lcv2++)
|
||||
{
|
||||
G1_register[lcv2 + 1] = G1_register[lcv2];
|
||||
G2_register[lcv2 + 1] = G2_register[lcv2];
|
||||
G1_register[lcv2] = G1_register[lcv2 + 1];
|
||||
G2_register[lcv2] = G2_register[lcv2 + 1];
|
||||
}
|
||||
|
||||
G1_register[0] = feedback1;
|
||||
G2_register[0] = feedback2;
|
||||
G1_register[12] = feedback1;
|
||||
G2_register[12] = feedback2;
|
||||
|
||||
// Reset G1 register if sequence found
|
||||
if(G1_register == G1_register_reset)
|
||||
{
|
||||
G1_register = {{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}};
|
||||
G1_register = {{1,1,1,1,1,1,1,1,1,1,1,1,1}};
|
||||
}
|
||||
|
||||
// Generate ranging code
|
||||
_dest[lcv] = static_cast<int>(-G1[lcv]*G2[lcv]);
|
||||
}
|
||||
|
||||
delay = _code_length;
|
||||
delay += _chip_shift;
|
||||
delay %= _code_length;
|
||||
|
||||
/* Generate PRN from G1 and G2 Registers */
|
||||
for (lcv = 0; lcv < _code_length; lcv++)
|
||||
{
|
||||
aux = (G1[(lcv + _chip_shift) % _code_length] + G2[delay]) & 0x01;
|
||||
if (aux == true)
|
||||
{
|
||||
_dest[lcv] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest[lcv] = -1;
|
||||
}
|
||||
|
||||
delay++;
|
||||
delay %= _code_length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
//!Generates int BeiDou B3I code for the desired SV ID and code shift
|
||||
void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift);
|
||||
|
||||
@@ -102,7 +102,7 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking(
|
||||
trk_param.very_early_late_space_narrow_chips = 0.0;
|
||||
trk_param.track_pilot = false;
|
||||
trk_param.system = 'C';
|
||||
char sig_[3] = "B1";
|
||||
char sig_[3] = "B3";
|
||||
std::memcpy(trk_param.signal, sig_, 3);
|
||||
int cn0_samples = configuration->property(role + ".cn0_samples", 20);
|
||||
if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples;
|
||||
|
||||
Reference in New Issue
Block a user