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:
Damian Miralles 2019-01-27 19:05:41 -06:00
parent e78ba653e6
commit 7f1619483f
7 changed files with 92 additions and 80 deletions

View File

@ -32,21 +32,23 @@ Channel.signal=B3
Channels.in_acquisition=1
Channels_B3.count=5;
Channel0.satellite = 21;
Channel0.satellite = 27;
Channel1.satellite = 22;
Channel2.satellite = 27;
Channel2.satellite = 21;
Channel3.satellite = 28;
Channel4.satellite = 30;
;######### ACQUISITION GLOBAL CONFIG ############
Acquisition_B3.implementation=BEIDOU_B3I_PCPS_Acquisition
Acquisition_B3.item_type=gr_complex
;Acquisition_B3.pfa=0.01
Acquisition_B3.threshold=0.00015
Acquisition_B3.coherent_integration_time_ms = 1
Acquisition_B3.max_dwells = 1
Acquisition_B3.threshold=0.0010
Acquisition_B3.doppler_max=10000
Acquisition_B3.doppler_step=100
Acquisition_B3.dump=false;
Acquisition_B3.dump_filename=/archive/bds_b3i_acq.dat
Acquisition_B3.doppler_step=50
Acquisition_B3.dump=true
Acquisition_B3.dump_channel = 0;
Acquisition_B3.dump_filename=/archive/bds_b3i_acq
Acquisition_B3.blocking=false;
Acquisition_B3.use_CFAR_algorithm=true;
Acquisition_B3.bit_transition_flag = false;
@ -68,7 +70,7 @@ TelemetryDecoder_B3.dump_filename=/archive/bds_b3i_tel_dec.dat
;######### OBSERVABLES CONFIG ############
Observables.implementation=Hybrid_Observables
Observables.dump=true;
Observables.dump_filename=/archive/bds_b2a_observables.dat
Observables.dump_filename=/archive/bds_b3i_observables.dat
;######### PVT CONFIG ############
PVT.implementation=RTKLIB_PVT

View File

@ -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 */

View File

@ -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,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> 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;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -36,10 +36,10 @@
#include "MATH_CONSTANTS.h"
// carrier and code frequencies
const double BEIDOU_B3I_FREQ_HZ = 1.268520e9; //!< b1I [Hz]
const double BEIDOU_B3I_CODE_RATE_HZ = 10.23e6; //!< beidou b1I code rate [chips/s]
const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< beidou b1I code length [chips]
const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< beidou b1I code period [seconds]
const double BEIDOU_B3I_FREQ_HZ = 1.268520e9; //!< BeiDou B3I [Hz]
const double BEIDOU_B3I_CODE_RATE_HZ = 10.23e6; //!< BeiDou B3I code rate [chips/s]
const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code length [chips]
const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< BeiDou B3I code period [seconds]
const unsigned int BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms]
const int BEIDOU_B3I_SECONDARY_CODE_LENGTH = 20;
const std::string BEIDOU_B3I_SECONDARY_CODE = "00000100110101001110";

View File

@ -28,13 +28,13 @@
%%%%%%%%% ?????? CONFIGURE !!! %%%%%%%%%%%%%
path = '/home/dmiralles/Documents/gnss-sdr/';
file = 'bds_acq';
path = '/archive/';
file = 'bds_b3i_acq';
sat = 32;
sat = 27;
channel = 0;
execution = 3;
execution = 6;
% Signal:
% 1 GPS L1
% 2 GPS L2M
@ -44,7 +44,7 @@ execution = 3;
% 6 Glo. 1G
% 7 BDS B1
signal_type = 7;
signal_type = 8;
%%% True for light acq_grid representation
lite_view = true;
@ -83,6 +83,10 @@ switch(signal_type)
n_chips = 2046;
system = 'C';
signal = 'B1';
case 8
n_chips = 10230;
system = 'C';
signal = 'B3';
end
filename = [path file '_' system '_' signal '_ch_' num2str(channel) '_' num2str(execution) '_sat_' num2str(sat) '.mat'];
load(filename);