1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-25 22:43:14 +00:00

bds_b3i: Adding BeiDou B3I PVT computation

This commit is contained in:
Damian Miralles 2019-03-17 18:49:06 -05:00
parent 3f274e40d1
commit 3136817737
No known key found for this signature in database
GPG Key ID: 8A92BA854ED245E1
6 changed files with 91 additions and 90 deletions

View File

@ -53,7 +53,7 @@ beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(const
/*!
* \brief This class implements a block that decodes the GNAV data defined in BEIDOU ICD v5.1
* \brief This class implements a block that decodes the BeiDou DNAV data.
* \note Code added as part of GSoC 2018 program
*/
class beidou_b1i_telemetry_decoder_gs : public gr::block

View File

@ -34,6 +34,7 @@
#include "Beidou_DNAV.h"
#include "beidou_dnav_almanac.h"
#include "beidou_dnav_ephemeris.h"
#include "beidou_dnav_iono.h"
#include "beidou_dnav_utc_model.h"
#include "gnss_synchro.h"
#include <glog/logging.h>
@ -137,7 +138,7 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
{
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_secondary_code_symbols);
volk_gnsssdr_free(d_subframe_symbols);
@ -155,17 +156,17 @@ beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
}
void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(int32_t *bits, int32_t *decbits)
void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, int32_t *decbits)
{
int bit, err, reg[4] = {1, 1, 1, 1};
int errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2};
int32_t bit, err, reg[4] = {1, 1, 1, 1};
int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2};
for (unsigned int i = 0; i < 15; i++)
for (uint32_t i = 0; i < 15; i++)
{
decbits[i] = bits[i];
}
for (unsigned int i = 0; i < 15; i++)
for (uint32_t i = 0; i < 15; i++)
{
bit = reg[3];
reg[3] = reg[2];
@ -186,45 +187,43 @@ void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(int32_t *bits, int32_t
void beidou_b3i_telemetry_decoder_gs::decode_word(
int32_t word_counter,
double* enc_word_symbols,
const double* enc_word_symbols,
int32_t* dec_word_symbols)
{
int32_t bitsbch[30], first_branch[15], second_branch[15];
if (word_counter == 1)
{
for (unsigned int j = 0; j < 30; j++)
{
dec_word_symbols[j] = (int32_t)(enc_word_symbols[j] > 0) ? (1) : (-1);
}
for (uint32_t j = 0; j < 30; j++)
{
dec_word_symbols[j] = static_cast<int32_t>(enc_word_symbols[j] > 0) ? (1) : (-1);
}
}
else
{
for (unsigned int r = 0; r < 2; r++)
{
for (unsigned int c = 0; c < 15; c++)
for (uint32_t r = 0; r < 2; r++)
{
for (uint32_t c = 0; c < 15; c++)
{
bitsbch[r*15 + c] = (int32_t)(enc_word_symbols[c*2 + r] > 0) ? (1) : (-1);
bitsbch[r * 15 + c] = static_cast<int32_t>(enc_word_symbols[c*2 + r] > 0) ? (1) : (-1);
}
}
}
decode_bch15_11_01(&bitsbch[0], first_branch);
decode_bch15_11_01(&bitsbch[15], second_branch);
for (unsigned int j = 0; j < 11; j++)
{
dec_word_symbols[j] = first_branch[j];
dec_word_symbols[j + 11] = second_branch[j];
}
for (uint32_t j = 0; j < 11; j++)
{
dec_word_symbols[j] = first_branch[j];
dec_word_symbols[j + 11] = second_branch[j];
}
for (unsigned int j = 0; j < 4; j++)
{
dec_word_symbols[j + 22] = first_branch[11 + j];
dec_word_symbols[j + 26] = second_branch[11 + j];
}
for (uint32_t j = 0; j < 4; j++)
{
dec_word_symbols[j + 22] = first_branch[11 + j];
dec_word_symbols[j + 26] = second_branch[11 + j];
}
}
}
@ -256,7 +255,6 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(double *frame_symbols)
d_nav.d1_subframe_decoder(data_bits);
}
// 3. Check operation executed correctly
if (d_nav.flag_crc_test == true)
{
@ -358,7 +356,7 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell
}
void beidou_b3i_telemetry_decoder_gs::set_channel(int channel)
void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
@ -391,8 +389,8 @@ int beidou_b3i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
int32_t corr_value = 0;
int32_t preamble_diff = 0;
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const Gnss_Synchro **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block
//1. Copy the current tracking output
@ -406,7 +404,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
if (d_symbol_history.size() > d_required_symbols)
{
//******* preamble correlation ********
for (int i = 0; i < d_samples_per_preamble; i++)
for (int32_t i = 0; i < d_samples_per_preamble; i++)
{
if (d_symbol_history[i] < 0) // symbols clipping
{
@ -461,7 +459,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
//******* SAMPLES TO SYMBOLS *******
if (corr_value > 0) //normal PLL lock
{
int k = 0;
int32_t k = 0;
for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++)
{
d_subframe_symbols[i] = 0;
@ -485,7 +483,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
}
else //180 deg. inverted carrier phase PLL lock
{
int k = 0;
int32_t k = 0;
for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++)
{
d_subframe_symbols[i] = 0;
@ -571,14 +569,16 @@ int beidou_b3i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
// MULTIPLEXED FILE RECORDING - Record results to file
try
{
double tmp_double;
unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol_ms;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(unsigned long int));
tmp_double = 0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
double tmp_double;
uint64_t tmp_ulong_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms);
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = d_nav.d_SOW;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = static_cast<uint64_t>(d_required_symbols);
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
}
catch (const std::ifstream::failure &e)
{

View File

@ -23,7 +23,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
@ -34,12 +34,12 @@
#include "beidou_dnav_navigation_message.h"
#include "gnss_satellite.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h>
#include <boost/shared_ptr.hpp> // for boost::shared_ptr
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint>
#include <fstream>
#include <string>
#include <boost/shared_ptr.hpp> // for boost::shared_ptr
#include <cstdint>
class beidou_b3i_telemetry_decoder_gs;
@ -55,7 +55,7 @@ beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(const
class beidou_b3i_telemetry_decoder_gs : public gr::block
{
public:
~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor
~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
@ -67,12 +67,12 @@ public:
private:
friend beidou_b3i_telemetry_decoder_gs_sptr
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
void decode_subframe(double *symbols);
void decode_word(int32_t word_counter, double* enc_word_symbols, int32_t* dec_word_symbols);
void decode_bch15_11_01(int32_t *bits, int32_t *decbits);
void decode_word(int32_t word_counter, const double *enc_word_symbols, int32_t* dec_word_symbols);
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits);
// Preamble decoding
@ -97,15 +97,15 @@ private:
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_SOW_set; // Indicates when time of week is set
// Navigation Message variable
//!< Navigation Message variable
Beidou_Dnav_Navigation_Message d_nav;
// Values to populate gnss synchronization structure
//!< Values to populate gnss synchronization structure
uint32_t d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
bool Flag_valid_word;
// Satellite Information and logging capacity
//!< Satellite Information and logging capacity
Gnss_Satellite d_satellite;
int32_t d_channel;
bool d_dump;

View File

@ -672,7 +672,7 @@ void dll_pll_veml_tracking::start_tracking()
n++;
}
}
d_symbol_history.set_capacity(22); // Change fixed buffer size
d_symbol_history.resize(22); // Change fixed buffer size
d_symbol_history.clear();
}
}

View File

@ -29,34 +29,37 @@
close all;clear;
samplingFreq = 25000000; %[Hz]
channels=[0:9];
path='/home/dmiralles/Documents/gnss-sdr-bds_b1i_v2/';
path='/home/dmiralles/Documents/gnss-sdr/';
addpath('libs/');
clear PRN_absolute_sample_start;
for N=1:1:length(channels)
telemetry_log_path=[path 'telemetry' num2str(channels(N)) '.dat'];
GNSS_telemetry_v2(N)= gps_l1_ca_read_telemetry_dump(telemetry_log_path);
GNSS_telemetry(N)= gps_l1_ca_read_telemetry_dump(telemetry_log_path);
end
%% Plotting values
%--- Configurations
chn_num_a = 6;
chn_num_b = 2;
%--- Plot results
figure;
plot(GNSS_telemetry_v2(6).tracking_sample_counter, ...
GNSS_telemetry_v2(6).tow_current_symbol_ms, 'b+');
plot(GNSS_telemetry(chn_num_a).tracking_sample_counter, ...
GNSS_telemetry(chn_num_a).tow_current_symbol_ms, 'b+');
hold on;
grid on;
plot(GNSS_telemetry_v2(1).tracking_sample_counter, ...
GNSS_telemetry_v2(1).tow_current_symbol_ms, 'ro');
plot(GNSS_telemetry(chn_num_b).tracking_sample_counter, ...
GNSS_telemetry(chn_num_b).tow_current_symbol_ms, 'ro');
xlabel('TRK Sampling Counter');
ylabel('Current Symbol TOW');
legend('BDS-1', 'BDS-6');
legend(['CHN-',num2str(chn_num_a-1)], ['CHN-',num2str(chn_num_b-1)]);
figure;
plot(GNSS_telemetry_v2(6).tracking_sample_counter, ...
GNSS_telemetry_v2(6).tow, 'b+');
plot(GNSS_telemetry(chn_num_a).tracking_sample_counter, ...
GNSS_telemetry(chn_num_a).tow, 'b+');
hold on;
grid on;
plot(GNSS_telemetry_v2(1).tracking_sample_counter, ...
GNSS_telemetry_v2(1).tow, 'ro');
plot(GNSS_telemetry(chn_num_b).tracking_sample_counter, ...
GNSS_telemetry(chn_num_b).tow, 'ro');
xlabel('TRK Sampling Counter');
ylabel('Decoded Nav TOW');
legend('BDS-1', 'BDS-6');
legend(['CHN-',num2str(chn_num_a-1)], ['CHN-',num2str(chn_num_b-1)]);

View File

@ -23,9 +23,7 @@
% -------------------------------------------------------------------------
%
% Read observables dump
%clear all;
%% Read Hibrid Observables Dump
clearvars;
close all;
addpath('./libs');
@ -35,38 +33,38 @@ path='/home/dmiralles/Documents/gnss-sdr/';
observables_log_path=[path 'observables.dat'];
GNSS_observables= read_hybrid_observables_dump(channels,observables_log_path);
%%
%optional:
%search all channels having good satellite simultaneously
min_idx=1;
%% Plo data
%--- optional: search all channels having good satellite simultaneously
min_tow_idx=1;
obs_idx=1;
for n=1:1:channels
idx=find(GNSS_observables.valid(n,:)>0,1,'first');
if min_idx<idx
min_idx=idx
if min_tow_idx<idx
min_tow_idx=idx;
obs_idx = n;
end
end
min_idx=min_idx;
%plot observables from that index
%--- plot observables from that index
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Pseudorange_m(:,min_idx+1:end)');
title('Pseudoranges [m]')
plot(GNSS_observables.RX_time(obs_idx,min_tow_idx+1:end),GNSS_observables.Pseudorange_m(:,min_tow_idx+1:end)');
grid on;
xlabel('TOW [s]')
ylabel('[m]');
ylabel('Pseudorange [m]');
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Carrier_phase_hz(:,min_idx+1:end)');
title('Accumulated carrier phase')
plot(GNSS_observables.RX_time(obs_idx,min_tow_idx+1:end),GNSS_observables.Carrier_phase_hz(:,min_tow_idx+1:end)');
xlabel('TOW [s]')
ylabel('[cycles]');
ylabel('Accumulated Carrier Phase [cycles]');
grid on;
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Carrier_Doppler_hz(:,min_idx+1:end)');
title('Doppler frequency')
xlabel('TOW [s]')
ylabel('[Hz]');
plot(GNSS_observables.RX_time(obs_idx,min_tow_idx+1:end),GNSS_observables.Carrier_Doppler_hz(:,min_tow_idx+1:end)');
xlabel('TOW [s]');
ylabel('Doppler Frequency [Hz]');
grid on;
%
%% Deprecated Code
% %read true obs from simulator (optional)
% GPS_STARTOFFSET_s = 68.802e-3;
%