cleaning code for gsoc

This commit is contained in:
Sergi Segura 2018-08-12 23:58:16 +02:00
parent a699c80673
commit fc98fa6afe
14 changed files with 109 additions and 231 deletions

View File

@ -2,6 +2,8 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
link to website: https://gnsssdrbeidoub1igsoc2018.wordpress.com/
**Welcome to GNSS-SDR!**
This program is a software-defined receiver which is able to process (that is, to perform detection, synchronization, demodulation and decoding of the navigation message, computation of observables and, finally, computation of position fixes) the following Global Navigation Satellite System's signals:

View File

@ -451,6 +451,34 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro>& gnss_observables_
}
break;
}
case 'C':
{
// BEIDOU B1I
// - find the ephemeris for the current BEIDOU SV observation. The SV PRN ID is the map key
std::string sig_(gnss_observables_iter->second.Signal);
if (sig_.compare("B1") == 0)
{
beidou_ephemeris_iter = beidou_ephemeris_map.find(gnss_observables_iter->second.PRN);
if (beidou_ephemeris_iter != beidou_ephemeris_map.cend())
{
// convert ephemeris from GNSS-SDR class to RTKLIB structure
eph_data[valid_obs] = eph_to_rtklib(beidou_ephemeris_iter->second);
// convert observation from GNSS-SDR class to RTKLIB structure
obsd_t newobs = {{0, 0}, '0', '0', {}, {}, {}, {}, {}, {}};
obs_data[valid_obs + glo_valid_obs] = insert_obs_to_rtklib(newobs,
gnss_observables_iter->second,
beidou_ephemeris_iter->second.i_BEIDOU_week,
0);
valid_obs++;
}
else // the ephemeris are not available for this SV
{
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->first;
}
}
break;
}
default:
DLOG(INFO) << "Hybrid observables: Unknown GNSS";
break;

View File

@ -1,11 +1,9 @@
/*!
* \file gps_l1_ca_pcps_acquisition.h
* \file beidou_bi1_pcps_acquisition.h
* \brief Adapts a PCPS acquisition block to an AcquisitionInterface for
* GPS L1 C/A signals
* Beidou B1I signals
* \authors <ul>
* <li> Javier Arribas, 2011. jarribas(at)cttc.es
* <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
* <li> Marc Molina, 2013. marc.molina.pena(at)gmail.com
* <li> Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
* </ul>
*
* -------------------------------------------------------------------------

View File

@ -1,179 +0,0 @@
void decodeBCHBeidou(std::list<bool> *firstBranch_encoded, std::list<int> *output)
{
bool input[15];
std::copy(firstBranch_encoded.begin(),firstBranch_encoded.end(),input);
std::array<bool, 4> D_register = {0,0,0,0};
std::array<bool, 15> stage_buffer;
std::array<bool, 15> ROM_list_circuit;
for (i = 0; i < 15; i++)
{
D_register = {inputBit[i] ^ D_register[3], D_register[0] ^ D_register[3], D_register[1], D_register[2]};
stage_buffer[i] = inputBit[i];
}
if(D_register == {0,0,0,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
} else if(D_register == {0,0,0,1}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
} else if(D_register == {0,0,1,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0};
} else if(D_register == {0,0,1,1}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0};
} else if(D_register == {0,1,0,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0};
} else if(D_register == {0,1,0,1}) {
ROM_list_circuit = {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0};
} else if(D_register == {0,1,1,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0};
} else if(D_register == {0,1,1,1}) {
ROM_list_circuit = {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0};
} else if(D_register == {1,0,0,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0};
} else if(D_register == {1,0,0,1}) {
ROM_list_circuit = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
} else if(D_register == {1,0,1,0}) {
ROM_list_circuit = {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0};
} else if(D_register == {1,0,1,1}) {
ROM_list_circuit = {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0};
} else if(D_register == {1,1,0,0}) {
ROM_list_circuit = {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0};
} else if(D_register == {1,1,0,1}) {
ROM_list_circuit = {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0};
} else if(D_register == {1,1,1,0}) {
ROM_list_circuit = {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0};
} else if(D_register == {1,1,1,1}) {
ROM_list_circuit = {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0};
}
for (i = 0; i < 15; i++)
{
if(stage_buffer[i] ^ ROM_list_circuit[i])
{
output.push_back(1);
}
else
{
output.push_back(-1);
}
}
}
void remove_NH_Beidou(bool *input, bool *output)
{
int *code_NH_Beidou = {-1,-1,-1,-1,-1,+1,-1,-1,+1,+1,-1,+1,-1,+1,-1,-1,+1,+1,+1,-1};
int corr_NH = 0;
int correlation = 0;
for (int i = 0; i < 20; i++)
{
if ((code_NH_Beidou[i] * input[i]) > 0.0)
{
corr_NH += 1;
}
else
{
corr_NH -= 1;
}
}
if (abs(corr_NH) == 20)
{
correlation = 1;
if (corr_NH > 0)
{
output = 1;
}
else
{
output = 0;
}
}
}
void process_TRK_output_Beidou(bool *input, int n_input_bits, int *output)
{
bool buffer_NH[15];
bool new_bit;
std::list<bool> firstBranch_encoded;
std::list<int> firstBranch_decoded;
std::list<bool> secondBranch_encoded;
std::list<int> secondBranch_decoded;
std::list<int> output_list;
for (int i = 0; i < n_input_bits/15; i++)
{
for (int j = 0; j < 15; i++)
{
buffer_NH[j] = input[i + j];
}
remove_NH_Beidou(buffer_NH, &new_bit)
if ( i % 2 == 0 )
{
firstBranch_encoded.push_back(new_bit);
}
else
{
secondBranch_encoded.push_back(new_bit);
}
if (firstBranch_encoded.size() == 15)
{
decodeBCHBeidou(&firstBranch_encoded, &firstBranch_decoded);
firstBranch_encoded.clear();
}
if (secondBranch_encoded.size() == 15)
{
decodeBCHBeidou(&secondBranch_encoded, &secondBranch_decoded);
secondBranch_encoded.clear();
}
if (firstBranch_decoded.size() > 10)
{
for (i = 0; i < 11; i++)
{
output_list.push_back(firstBranch_decoded.front());
firstBranch_decoded.pop_front();
}
}
if (secondBranch_decoded.size() > 10)
{
for (i = 0; i < 11; i++)
{
output_list.push_back(secondBranch_decoded.front());
secondBranch_decoded.pop_front();
}
}
}
std::copy(output_list.begin(),output_list.end(),output);
}

View File

@ -65,6 +65,9 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro
case 'R':
rtklib_obs.sat = gnss_synchro.PRN + NSATGPS;
break;
case 'C':
rtklib_obs.sat = gnss_synchro.PRN + NSATGPS + NSATGLO + NSATGAL;
break;
default:
rtklib_obs.sat = gnss_synchro.PRN;
@ -227,6 +230,62 @@ eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph)
return rtklib_sat;
}
eph_t eph_to_rtklib(const Beidou_Ephemeris& bei_eph)
{
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0 };
rtklib_sat.sat = bei_eph.i_satellite_PRN;
rtklib_sat.A = bei_eph.d_sqrt_A * bei_eph.d_sqrt_A;
rtklib_sat.M0 = bei_eph.d_M_0;
rtklib_sat.deln = bei_eph.d_Delta_n;
rtklib_sat.OMG0 = bei_eph.d_OMEGA0;
rtklib_sat.OMGd = bei_eph.d_OMEGA_DOT;
rtklib_sat.omg = bei_eph.d_OMEGA;
rtklib_sat.i0 = bei_eph.d_i_0;
rtklib_sat.idot = bei_eph.d_IDOT;
rtklib_sat.e = bei_eph.d_e_eccentricity;
rtklib_sat.Adot = 0; //only in CNAV;
rtklib_sat.ndot = 0; //only in CNAV;
rtklib_sat.week = adjgpsweek(bei_eph.i_BEIDOU_week); /* week of tow */
rtklib_sat.cic = bei_eph.d_Cic;
rtklib_sat.cis = bei_eph.d_Cis;
rtklib_sat.cuc = bei_eph.d_Cuc;
rtklib_sat.cus = bei_eph.d_Cus;
rtklib_sat.crc = bei_eph.d_Crc;
rtklib_sat.crs = bei_eph.d_Crs;
rtklib_sat.f0 = bei_eph.d_A_f0;
rtklib_sat.f1 = bei_eph.d_A_f1;
rtklib_sat.f2 = bei_eph.d_A_f2;
rtklib_sat.tgd[0] = bei_eph.d_TGD1;
rtklib_sat.tgd[1] = 0.0;
rtklib_sat.tgd[2] = 0.0;
rtklib_sat.tgd[3] = 0.0;
rtklib_sat.toes = bei_eph.d_Toe;
rtklib_sat.toc = gpst2time(rtklib_sat.week, bei_eph.d_Toc);
rtklib_sat.ttr = gpst2time(rtklib_sat.week, bei_eph.d_TOW);
/* adjustment for week handover */
double tow, toc;
tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week);
toc = time2gpst(rtklib_sat.toc, NULL);
if (rtklib_sat.toes < tow - 302400.0)
{
rtklib_sat.week++;
tow -= 604800.0;
}
else if (rtklib_sat.toes > tow + 302400.0)
{
rtklib_sat.week--;
tow += 604800.0;
}
rtklib_sat.toe = gpst2time(rtklib_sat.week, rtklib_sat.toes);
rtklib_sat.toc = gpst2time(rtklib_sat.week, toc);
rtklib_sat.ttr = gpst2time(rtklib_sat.week, tow);
return rtklib_sat;
}
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph)
{

View File

@ -38,10 +38,13 @@
#include "gps_cnav_ephemeris.h"
#include "glonass_gnav_ephemeris.h"
#include "glonass_gnav_utc_model.h"
#include "beidou_ephemeris.h"
eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph);
eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph);
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph);
eph_t eph_to_rtklib(const Beidou_Ephemeris& bei_eph);
/*!
* \brief Transforms a Glonass_Gnav_Ephemeris to its RTKLIB counterpart
* \param glonass_gnav_eph GLONASS GNAV Ephemeris structure

View File

@ -1,8 +1,8 @@
/*!
* \file gps_l1_ca_telemetry_decoder.cc
* \brief Implementation of an adapter of a GPS L1 C/A NAV data decoder block
* \file beidou_b1i_telemetry_decoder.cc
* \brief Implementation of an adapter of a Beidou B1I NAV data decoder block
* to a TelemetryDecoderInterface
* \author Javier Arribas, 2011. jarribas(at)cttc.es
* \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
*
* -------------------------------------------------------------------------
*

View File

@ -1,8 +1,8 @@
/*!
* \file gps_l1_ca_telemetry_decoder.h
* \brief Interface of an adapter of a GPS L1 C/A NAV data decoder block
* \file beidou_b1i_telemetry_decoder.h
* \brief Interface of an adapter of a Beidou B1I NAV data decoder block
* to a TelemetryDecoderInterface
* \author Javier Arribas, 2011. jarribas(at)cttc.es
* \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
*
* -------------------------------------------------------------------------
*

View File

@ -36,11 +36,6 @@
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#ifndef _rotl
#define _rotl(X, N) ((X << N) ^ (X >> (32 - N))) // Used in the parity check algorithm
#endif
using google::LogMessage;
beidou_b1i_telemetry_decoder_cc_sptr
@ -180,7 +175,6 @@ void beidou_b1i_telemetry_decoder_cc::decodebch_bi1(int *bits, int *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};
uint8_t bin;
for (unsigned int i = 0; i < 15; i++)
{
@ -208,7 +202,7 @@ void beidou_b1i_telemetry_decoder_cc::decodebch_bi1(int *bits, int *decbits)
void beidou_b1i_telemetry_decoder_cc::decode_word(int word_counter, boost::circular_buffer<signed int> *d_bit_buffer, unsigned int& d_BEIDOU_frame_4bytes)
{
d_BEIDOU_frame_4bytes = 0;
int bits[30], bitsdec[30], bitsbch[30], first_branch[15], second_branch[15];
int bitsdec[30], bitsbch[30], first_branch[15], second_branch[15];
if (word_counter == 1)
{
@ -273,7 +267,6 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
double current_time_samples = current_symbol.Tracking_sample_counter;
double current_samples_fs = current_symbol.fs;
int symbol_value = 0;
bool Flag_valid_symbol_output = false;
d_symbol_nh_history.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue
consume_each(1);
@ -353,7 +346,6 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
new_sym = false;
}*/
unsigned int required_symbols = BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS;
d_flag_preamble = false;
@ -469,7 +461,6 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
case 3: //we have a new set of ephemeris data for the current SV
*/ if (d_BEIDOU_FSM.d_nav.satellite_validation() == true)
{
std::cout << " we have a new set of ephemeris data for the current SV "<< std::endl;
// get ephemeris object for this SV (mandatory)
std::shared_ptr<Beidou_Ephemeris> tmp_obj = std::make_shared<Beidou_Ephemeris>(d_BEIDOU_FSM.d_nav.get_ephemeris());
@ -479,7 +470,6 @@ std::cout << " we have a new set of ephemeris data for the current SV "<< std::e
case 4: // Possible IONOSPHERE and UTC model update (page 18)
*/ if (d_BEIDOU_FSM.d_nav.flag_iono_valid == true)
{
std::cout << " we have a new set of iono data for the current SV "<< std::endl;
std::shared_ptr<Beidou_Iono> tmp_obj = std::make_shared<Beidou_Iono>(d_BEIDOU_FSM.d_nav.get_iono());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
@ -507,7 +497,7 @@ std::cout << " we have a new set of utc data for the current SV "<< std::endl;
//2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_flag_new_tow_available == true)
{
d_TOW_at_current_symbol_ms = static_cast<unsigned int>(d_BEIDOU_FSM.d_nav.d_SOW) * 1000 + BEIDOU_B1I_CODE_PERIOD_MS + BEIDOU_B1I_PREAMBLE_DURATION_MS;
d_TOW_at_current_symbol_ms = static_cast<unsigned int>(d_BEIDOU_FSM.d_nav.d_SOW) * 1000 + 599;
d_TOW_at_Preamble_ms = d_TOW_at_current_symbol_ms;
flag_TOW_set = true;
d_flag_new_tow_available = false;

View File

@ -1,5 +1,5 @@
/*!
* \file gps_l1_ca_subframe_fsm.h
* \file beidou_b1i_subframe_fsm.h
* \brief Interface of a BEIDOU NAV message word-to-subframe decoder state machine
* \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
*

View File

@ -1,10 +1,8 @@
/*!
* \file beidou_b1i_dll_pll_tracking.cc
* \brief Implementation of an adapter of a DLL+PLL tracking loop block
* for GPS L1 C/A to a TrackingInterface
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Javier Arribas, 2011. jarribas(at)cttc.es
* Sergi Segura, 2018. sergi.segura.munoz@gmail.com
* for Beidou B1I to a TrackingInterface
* \author Sergi Segura, 2018. sergi.segura.munoz@gmail.com
*
* Code DLL + carrier PLL according to the algorithms described in:
* K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,

View File

@ -1,9 +1,8 @@
/*!
* \file gps_l1_ca_dll_pll_tracking.h
* \file beidou_b1i_dll_pll_tracking.h
* \brief Interface of an adapter of a DLL+PLL tracking loop block
* for GPS L1 C/A to a TrackingInterface
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Javier Arribas, 2011. jarribas(at)cttc.es
* for Beidou B1I to a TrackingInterface
* \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
*
* Code DLL + carrier PLL according to the algorithms described in:
* K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,

View File

@ -828,13 +828,9 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetChannel_B1(
LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!";
}
config->set_property("Channel.item_type", acq_item_type);
std::cout << "Now Channel pass Through" << std::endl;
std::unique_ptr<GNSSBlockInterface> pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue);
std::cout << "Now Acquisition" << std::endl;
std::unique_ptr<AcquisitionInterface> acq_ = GetAcqBlock(configuration, "Acquisition_B1" + appendix1, acq, 1, 0);
std::cout << "Now Tracking" << std::endl;
std::unique_ptr<TrackingInterface> trk_ = GetTrkBlock(configuration, "Tracking_B1" + appendix2, trk, 1, 1);
std::cout << "Now Telemetry Decoder" << std::endl;
std::unique_ptr<TelemetryDecoderInterface> tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_B1" + appendix3, tlm, 1, 1);
std::unique_ptr<GNSSBlockInterface> channel_(new Channel(configuration.get(), channel, std::move(pass_through_),

View File

@ -444,9 +444,6 @@ int Beidou_Navigation_Message_D1::subframe_decoder(char *subframe)
d_SOW_SF1 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SOW));
d_SOW = d_SOW_SF1; // Set transmission time
std::cout << "I decoded subframe 1" << std::endl;
std::cout << "TOW: " << d_SOW_SF1 << std::endl;
i_SV_health = static_cast<int>(read_navigation_unsigned(subframe_bits, D1_SAT_H1));
d_AODC = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_AODC));
@ -507,9 +504,6 @@ std::cout << "TOW: " << d_SOW_SF1 << std::endl;
d_SOW_SF2 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SOW));
d_SOW = d_SOW_SF2; // Set transmission time
std::cout << "I decoded subframe 2" << std::endl;
std::cout << "TOW: " << d_SOW_SF2 << std::endl;
d_Cuc = static_cast<double>(read_navigation_signed(subframe_bits, D1_CUC));
d_Cuc = d_Cuc * D1_CUC_LSB;
@ -549,9 +543,6 @@ std::cout << "TOW: " << d_SOW_SF2 << std::endl;
d_SOW_SF3 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SOW));
d_SOW = d_SOW_SF3; // Set transmission time
std::cout << "I decoded subframe 3" << std::endl;
std::cout << "TOW: " << d_SOW_SF3 << std::endl;
d_Toe = d_Toe * D1_TOE_LSB;
d_i_0 = static_cast<double>(read_navigation_signed(subframe_bits, D1_I0));
@ -590,9 +581,6 @@ std::cout << "TOW: " << d_SOW_SF3 << std::endl;
d_SOW_SF4 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SOW));
d_SOW = d_SOW_SF4; // Set transmission time
std::cout << "I decoded subframe 4" << std::endl;
std::cout << "TOW: " << d_SOW_SF4 << std::endl;
d_SQRT_A_ALMANAC = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SQRT_A_ALMANAC));
d_SQRT_A_ALMANAC = d_SQRT_A_ALMANAC * D1_SQRT_A_ALMANAC_LSB;
@ -677,10 +665,6 @@ std::cout << "TOW: " << d_SOW_SF4 << std::endl;
d_SOW_SF5 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_SOW));
d_SOW = d_SOW_SF5; // Set transmission time
std::cout << "I decoded subframe 5" << std::endl;
std::cout << "TOW: " << d_SOW_SF5 << std::endl;
SV_page_5 = static_cast<int>(read_navigation_unsigned(subframe_bits, D1_PNUM));
if (SV_page_5 < 7)