diff --git a/conf/gnss-sdr_BDS_B1I_GPS_L1_CA_ibyte.conf b/conf/gnss-sdr_BDS_B1I_GPS_L1_CA_ibyte.conf deleted file mode 100644 index d050831a7..000000000 --- a/conf/gnss-sdr_BDS_B1I_GPS_L1_CA_ibyte.conf +++ /dev/null @@ -1,265 +0,0 @@ -; This is a GNSS-SDR configuration file -; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ - -; You can define your own receiver and invoke it by doing -; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf -; - -[GNSS-SDR] - -;######### GLOBAL OPTIONS ################## -;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. -GNSS-SDR.internal_fs_sps=10000000 -Receiver.sources_count=2 - -;######### CONTROL_THREAD CONFIG ############ -ControlThread.wait_for_flowgraph=false - -;######### SIGNAL_SOURCE CONFIG ############ -;# Signal Source config for GPS, Galileo signals -SignalSource0.implementation=File_Signal_Source -SignalSource0.filename=/archive/BDS3_datasets/long/20180713_211400_3.dat -SignalSource0.item_type=ibyte -SignalSource0.sampling_frequency=10000000 -SignalSource0.samples=0 -SignalSource0.repeat=false -SignalSource0.dump=false -SignalSource0.enable_throttle_control=false - -;# Signal Source config for BDS signals -SignalSource1.implementation=File_Signal_Source -SignalSource1.filename=/archive/BDS3_datasets/long/20180713_211400_1.dat -SignalSource1.item_type=ibyte -SignalSource1.sampling_frequency=10000000 -SignalSource1.samples=0 -SignalSource1.repeat=false -SignalSource1.dump=false -SignalSource1.enable_throttle_control=false - -;######### SIGNAL_CONDITIONER CONFIG ############ -;# Signal Conditioner config for GPS, Galileo signals -SignalConditioner0.implementation=Signal_Conditioner -DataTypeAdapter0.implementation=Ibyte_To_Complex -InputFilter0.implementation=Freq_Xlating_Fir_Filter -InputFilter0.input_item_type=gr_complex -InputFilter0.output_item_type=gr_complex -InputFilter0.taps_item_type=float -InputFilter0.number_of_taps=5 -InputFilter0.number_of_bands=2 -InputFilter0.band1_begin=0.0 -InputFilter0.band1_end=0.70 -InputFilter0.band2_begin=0.80 -InputFilter0.band2_end=1.0 -InputFilter0.ampl1_begin=1.0 -InputFilter0.ampl1_end=1.0 -InputFilter0.ampl2_begin=0.0 -InputFilter0.ampl2_end=0.0 -InputFilter0.band1_error=1.0 -InputFilter0.band2_error=1.0 -InputFilter0.filter_type=bandpass -InputFilter0.grid_density=16 -InputFilter0.sampling_frequency=10000000 -InputFilter0.IF=420000 -Resampler0.implementation=Pass_Through -Resampler0.sample_freq_in=10000000 -Resampler0.sample_freq_out=10000000 -Resampler0.item_type=gr_complex - -;# Signal Conditioner config for BDS signals -SignalConditioner1.implementation=Signal_Conditioner -DataTypeAdapter1.implementation=Ibyte_To_Complex -InputFilter1.implementation=Freq_Xlating_Fir_Filter -InputFilter1.input_item_type=gr_complex -InputFilter1.output_item_type=gr_complex -InputFilter1.taps_item_type=float -InputFilter1.number_of_taps=5 -InputFilter1.number_of_bands=2 -InputFilter1.band1_begin=0.0 -InputFilter1.band1_end=0.70 -InputFilter1.band2_begin=0.80 -InputFilter1.band2_end=1.0 -InputFilter1.ampl1_begin=1.0 -InputFilter1.ampl1_end=1.0 -InputFilter1.ampl2_begin=0.0 -InputFilter1.ampl2_end=0.0 -InputFilter1.band1_error=1.0 -InputFilter1.band2_error=1.0 -InputFilter1.filter_type=bandpass -InputFilter1.grid_density=16 -InputFilter1.sampling_frequency=10000000 -InputFilter1.IF=1098000 -Resampler1.implementation=Pass_Through -Resampler1.sample_freq_in=10000000 -Resampler1.sample_freq_out=10000000 -Resampler1.item_type=gr_complex - -;######### CHANNELS GLOBAL CONFIG ############ -Channels_1C.count=7 -Channels_1B.count=7 -Channels_B1.count=4 -Channels.in_acquisition=18 - -;# Preparing collection for GPS satellites -Channel0.RF_channel_ID=0 -Channel1.RF_channel_ID=0 -Channel2.RF_channel_ID=0 -Channel3.RF_channel_ID=0 -Channel4.RF_channel_ID=0 -Channel5.RF_channel_ID=0 -Channel6.RF_channel_ID=0 -Channel0.signal=1C -Channel0.satellite = 2 -Channel1.signal=1C -Channel1.satellite = 5 -Channel2.signal=1C -Channel2.satellite = 25 -Channel3.signal=1C -Channel3.satellite = 31 -Channel4.signal=1C -Channel4.satellite = 24 -Channel5.signal=1C -Channel5.satellite = 6 -Channel6.signal=1C -Channel6.satellite = 29 - -;# Preparing collection for Galileo satellites -Channel7.RF_channel_ID=0 -Channel8.RF_channel_ID=0 -Channel9.RF_channel_ID=0 -Channel10.RF_channel_ID=0 -Channel11.RF_channel_ID=0 -Channel12.RF_channel_ID=0 -Channel13.RF_channel_ID=0 -Channel7.signal=1B -Channel7.satellite = 30 -Channel8.signal=1B -Channel8.satellite = 21 -Channel9.signal=1B -Channel9.satellite = 5 -Channel10.signal=1B -Channel10.satellite = 3 -Channel11.signal=1B -Channel11.satellite = 27 -Channel12.signal=1B -Channel12.satellite = 9 -Channel13.signal=1B -Channel13.satellite = 10 - -;# Preparing collection for BDS satellites -Channel14.RF_channel_ID=1 -Channel15.RF_channel_ID=1 -Channel16.RF_channel_ID=1 -Channel17.RF_channel_ID=1 -Channel18.RF_channel_ID=1 -Channel19.RF_channel_ID=1 -Channel20.RF_channel_ID=1 -Channel21.RF_channel_ID=1 -Channel22.RF_channel_ID=1 -Channel23.RF_channel_ID=1 - -Channel14.signal=B1 -Channel14.satellite = 29 -Channel15.signal=B1 -Channel15.satellite = 19 -Channel16.signal=B1 -Channel16.satellite = 20 -Channel17.signal=B1 -Channel17.satellite = 30 - - -;######### ACQUISITION GLOBAL CONFIG ############ -;# Acquisition config for BDS signals -Acquisition_B1.implementation=BEIDOU_B1I_PCPS_Acquisition -Acquisition_B1.item_type=gr_complex -Acquisition_B1.coherent_integration_time_ms=1 -Acquisition_B1.threshold=0.0005 -Acquisition_B1.doppler_max=15000 -Acquisition_B1.doppler_step=100 -Acquisition_B1.dump=false -Acquisition_B1.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/bds_b1i_acq -Acquisition_B1.blocking=false; -Acquisition_B1.use_CFAR_algorithm=true; -Acquisition_B1.bit_transition_flag = false; - -;# Acquisition config for GPS signals -Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition -Acquisition_1C.item_type=gr_complex -Acquisition_1C.coherent_integration_time_ms=1 -Acquisition_1C.threshold=0.0005 -Acquisition_1C.doppler_max=15000 -Acquisition_1C.doppler_step=100 -Acquisition_1C.dump=true -Acquisition_1C.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/gps_l1ca_acq -Acquisition_1C.blocking=false; -Acquisition_1C.use_CFAR_algorithm=true; -Acquisition_1C.bit_transition_flag = false; - -;# Acquisition config for Galileo signals -Acquisition_1B.implementation=Galileo_E1_PCPS_Ambiguous_Acquisition -Acquisition_1B.item_type=gr_complex -Acquisition_1B.coherent_integration_time_ms=4 -Acquisition_1B.threshold=0.0015 -Acquisition_1B.doppler_max=15000 -Acquisition_1B.doppler_step=100 -Acquisition_1B.dump=true -Acquisition_1B.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/gal_e1b_acq -Acquisition_1B.blocking=false; -Acquisition_1B.use_CFAR_algorithm=true; -Acquisition_1B.bit_transition_flag = false; - -;######### TRACKING GLOBAL CONFIG ############ -Tracking_B1.implementation=BEIDOU_B1I_DLL_PLL_Tracking -Tracking_B1.item_type=gr_complex -Tracking_B1.pll_bw_hz=25.0; -Tracking_B1.dll_bw_hz=2.50; -Tracking_B1.dump=true; -Tracking_B1.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/bds_b1i_trk_ch_ - -Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking -Tracking_1C.item_type=gr_complex -Tracking_1C.pll_bw_hz=25.0; -Tracking_1C.dll_bw_hz=2.50; -Tracking_1C.dump=true; -Tracking_1C.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/gps_l1ca_trk_ch_ - -Tracking_1B.implementation=Galileo_E1_DLL_PLL_VEML_Tracking -Tracking_1B.item_type=gr_complex -Tracking_1B.pll_bw_hz=25.0; -Tracking_1B.dll_bw_hz=2.50; -Tracking_1B.dump=true; -Tracking_1B.dump_filename=/home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/gal_e1b_trk_ch_ - -;######### TELEMETRY DECODER GPS CONFIG ############ -TelemetryDecoder_B1.implementation=BEIDOU_B1I_Telemetry_Decoder -TelemetryDecoder_B1.dump=true -TelemetryDecoder_B1.dump_filename = ./bds_tel_dec - -TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder -TelemetryDecoder_1C.dump=true -TelemetryDecoder_1C.dump_filename=./gps_tel_dec - -TelemetryDecoder_1B.implementation=Galileo_E1B_Telemetry_Decoder -TelemetryDecoder_1B.dump=false - -;######### OBSERVABLES CONFIG ############ -Observables.implementation=Hybrid_Observables -Observables.dump=true -Observables.dump_filename=./observables.dat - - -;######### PVT CONFIG ############ -PVT.implementation=RTKLIB_PVT -PVT.positioning_mode=Single ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic -PVT.iono_model=OFF ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX -PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad -PVT.output_rate_ms=100 -PVT.display_rate_ms=500 -PVT.dump=true -PVT.dump_filename = /home/dmiralles/Documents/Research/Publications/INSIDE_GNSS/bds_leg_pvt/Data/pvt_l1 -PVT.kml_output_enabled = false; -PVT.xml_output_enabled = false; -PVT.gpx_output_enabled = false; -PVT.rinex_output_enabled = false; -PVT.rtcm_output_enabled = false; -PVT.nmea_output_enabled = false; -PVT.geojson_output_enabled = false; diff --git a/conf/gnss-sdr_BDS_B1I_byte.conf b/conf/gnss-sdr_BDS_B1I_byte.conf index 15e86537d..1f8dffee4 100644 --- a/conf/gnss-sdr_BDS_B1I_byte.conf +++ b/conf/gnss-sdr_BDS_B1I_byte.conf @@ -16,7 +16,7 @@ ControlThread.wait_for_flowgraph=false ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=File_Signal_Source -SignalSource.filename=/home/dmiralles/Documents/gnss-metadata-standard/install/BdsB1IStr01.dat +SignalSource.filename=/archive/BDS3_datasets/BdsB1IStr01.dat SignalSource.item_type=byte SignalSource.sampling_frequency=25000000 SignalSource.samples=0 diff --git a/conf/gnss-sdr_BDS_B1I_ibyte.conf b/conf/gnss-sdr_BDS_B1I_ibyte.conf deleted file mode 100644 index 5e5eebcd1..000000000 --- a/conf/gnss-sdr_BDS_B1I_ibyte.conf +++ /dev/null @@ -1,127 +0,0 @@ -; This is a GNSS-SDR configuration file -; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ - -; You can define your own receiver and invoke it by doing -; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf -; - -[GNSS-SDR] - -;######### GLOBAL OPTIONS ################## -;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. -GNSS-SDR.internal_fs_sps=10000000 - -;######### CONTROL_THREAD CONFIG ############ -ControlThread.wait_for_flowgraph=false - -;######### SIGNAL_SOURCE CONFIG ############ -SignalSource.implementation=File_Signal_Source -SignalSource.filename=/archive/BDS3_datasets/long/20180713_211400_1.dat -SignalSource.item_type=ibyte -SignalSource.sampling_frequency=10000000 -SignalSource.samples=0 -SignalSource.repeat=false -SignalSource.dump=false -SignalSource.enable_throttle_control=false - -;######### SIGNAL_CONDITIONER CONFIG ############ -SignalConditioner.implementation=Signal_Conditioner -DataTypeAdapter.implementation=Ibyte_To_Complex -InputFilter.implementation=Freq_Xlating_Fir_Filter -InputFilter.input_item_type=gr_complex -InputFilter.output_item_type=gr_complex -InputFilter.taps_item_type=float -InputFilter.number_of_taps=5 -InputFilter.number_of_bands=2 -InputFilter.band1_begin=0.0 -InputFilter.band1_end=0.70 -InputFilter.band2_begin=0.80 -InputFilter.band2_end=1.0 -InputFilter.ampl1_begin=1.0 -InputFilter.ampl1_end=1.0 -InputFilter.ampl2_begin=0.0 -InputFilter.ampl2_end=0.0 -InputFilter.band1_error=1.0 -InputFilter.band2_error=1.0 -InputFilter.filter_type=bandpass -InputFilter.grid_density=16 -InputFilter.sampling_frequency=10000000 -InputFilter.IF=1098000 -Resampler.implementation=Pass_Through -Resampler.sample_freq_in=10000000 -Resampler.sample_freq_out=10000000 -Resampler.item_type=gr_complex - - -;######### CHANNELS GLOBAL CONFIG ############ -Channels_B1.count=4 -Channels.in_acquisition=1 -Channel.signal=B1 - -Channel0.satellite = 29; -Channel1.satellite = 19; -Channel2.satellite = 20; -Channel3.satellite = 30; - - -;Channel0.satellite = 6; -;Channel1.satellite = 8; -;Channel2.satellite = 9; -;Channel3.satellite = 13; -;Channel4.satellite = 17; -;Channel5.satellite = 1; -;Channel6.satellite = 2; -;Channel7.satellite = 3; -;Channel8.satellite = 4; -;Channel9.satellite = 5; - -;######### ACQUISITION GLOBAL CONFIG ############ -Acquisition_B1.implementation=BEIDOU_B1I_PCPS_Acquisition -Acquisition_B1.item_type=gr_complex -Acquisition_B1.coherent_integration_time_ms=1 -Acquisition_B1.threshold=0.0004 -;Acquisition_B1.pfa=0.0000001; -Acquisition_B1.doppler_max=10000 -Acquisition_B1.doppler_step=50 -Acquisition_B1.dump=true -Acquisition_B1.dump_filename=./bds_acq -Acquisition_B1.blocking=false; -Acquisition_B1.use_CFAR_algorithm=true; -Acquisition_B1.bit_transition_flag = false; - - -;######### TRACKING GLOBAL CONFIG ############ -Tracking_B1.implementation=BEIDOU_B1I_DLL_PLL_Tracking -Tracking_B1.item_type=gr_complex -Tracking_B1.pll_bw_hz=25.0; -Tracking_B1.dll_bw_hz=2.50; -Tracking_B1.dump=true; -Tracking_B1.dump_filename=./epl_tracking_ch_ - - -;######### TELEMETRY DECODER GPS CONFIG ############ -TelemetryDecoder_B1.implementation=BEIDOU_B1I_Telemetry_Decoder -TelemetryDecoder_B1.dump=false - - -;######### OBSERVABLES CONFIG ############ -Observables.implementation=Hybrid_Observables -Observables.dump=true -Observables.dump_filename=./observables.dat - - -;######### PVT CONFIG ############ -PVT.implementation=RTKLIB_PVT -PVT.positioning_mode=Single ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic -PVT.iono_model=OFF ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX -PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad -PVT.output_rate_ms=100 -PVT.display_rate_ms=500 -PVT.dump_filename=./PVT -PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; -PVT.flag_nmea_tty_port=false; -PVT.nmea_dump_devname=/dev/pts/4 -PVT.flag_rtcm_server=false -PVT.flag_rtcm_tty_port=false -PVT.rtcm_dump_devname=/dev/pts/1 -PVT.dump=true diff --git a/conf/gnss-sdr_BDS_B3I_byte.conf b/conf/gnss-sdr_BDS_B3I_byte.conf index 2c3180779..a2c8b1e56 100644 --- a/conf/gnss-sdr_BDS_B3I_byte.conf +++ b/conf/gnss-sdr_BDS_B3I_byte.conf @@ -16,7 +16,7 @@ ControlThread.wait_for_flowgraph=false ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=File_Signal_Source -SignalSource.filename=/home/dmiralles/Documents/gnss-metadata-standard/install/BdsB3IStr01.dat +SignalSource.filename=/archive/BDS3_datasets/BdsB3IStr01.dat SignalSource.item_type=byte SignalSource.sampling_frequency=50000000 SignalSource.samples=0 @@ -93,10 +93,9 @@ Tracking_B3.dll_bw_narrow_hz=3.0; Tracking_B3.dump=false; Tracking_B3.dump_filename=./epl_tracking_ch_ - ;######### TELEMETRY DECODER GPS CONFIG ############ TelemetryDecoder_B3.implementation=BEIDOU_B3I_Telemetry_Decoder -TelemetryDecoder_B3.dump=true +TelemetryDecoder_B3.dump=false ;######### OBSERVABLES CONFIG ############ diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 51579ad06..e8857561d 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -180,18 +180,25 @@ Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, * * * Skipped previous values to avoid overlapping - * 50 | Beidou B1I - * 51 | Beidou B1I + GPS L1 C/A - * 52 | Beidou B1I + Galileo E1B - * 53 | Beidou B1I + GLONASS L1 C/A - * 54 | Beidou B1I + GPS L1 C/A + Galileo E1B - * 55 | Beidou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B - * 56 | Beidou B1I + Beidou B3I + * 500 | BeiDou B1I + * 501 | BeiDou B1I + GPS L1 C/A + * 502 | BeiDou B1I + Galileo E1B + * 503 | BeiDou B1I + GLONASS L1 C/A + * 504 | BeiDou B1I + GPS L1 C/A + Galileo E1B + * 505 | BeiDou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B + * 506 | BeiDou B1I + Beidou B3I * Skipped previous values to avoid overlapping - * 60 | Beidou B3I - * 61 | Beidou B3I + GPS L2C - * 62 | Beidou B3I + GLONASS L2 C/A - * 63 | Beidou B3I + GPS L2C + GLONASS L2 C/A + * 600 | BeiDou B3I + * 601 | BeiDou B3I + GPS L2C + * 602 | BeiDou B3I + GLONASS L2 C/A + * 603 | BeiDou B3I + GPS L2C + GLONASS L2 C/A + * 604 | BeiDou B3I + GPS L1 C/A + * 605 | BeiDou B3I + Galileo E1B + * 606 | BeiDou B3I + GLONASS L1 C/A + * 607 | BeiDou B3I + GPS L1 C/A + Galileo E1B + * 608 | BeiDou B3I + GPS L1 C/A + Galileo E1B + BeiDou B1I + * 609 | BeiDou B3I + GPS L1 C/A + Galileo E1B + GLONASS L1 C/A + * 610 | BeiDou B3I + GPS L1 C/A + Galileo E1B + GLONASS L1 C/A + BeiDou B1I */ int gps_1C_count = configuration->property("Channels_1C.count", 0); int gps_2S_count = configuration->property("Channels_2S.count", 0); @@ -330,48 +337,48 @@ Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, // BeiDou B1I Receiver if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 50; // Beidou B1I + pvt_output_parameters.type_of_receiver = 500; // Beidou B1I } if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 51; // Beidou B1I + GPS L1 C/A + pvt_output_parameters.type_of_receiver = 501; // Beidou B1I + GPS L1 C/A } if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 52; // Beidou B1I + Galileo E1B + pvt_output_parameters.type_of_receiver = 502; // Beidou B1I + Galileo E1B } if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 53; // Beidou B1I + GLONASS L1 C/A + pvt_output_parameters.type_of_receiver = 503; // Beidou B1I + GLONASS L1 C/A } if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 54; // Beidou B1I + GPS L1 C/A + Galileo E1B + pvt_output_parameters.type_of_receiver = 504; // Beidou B1I + GPS L1 C/A + Galileo E1B } if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count == 0)) { - pvt_output_parameters.type_of_receiver = 55; // Beidou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B + pvt_output_parameters.type_of_receiver = 505; // Beidou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B } if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0) && (bds_B3_count != 0)) { - pvt_output_parameters.type_of_receiver = 56; // Beidou B1I + Beidou B3I + pvt_output_parameters.type_of_receiver = 506; // Beidou B1I + Beidou B3I } // BeiDou B3I Receiver if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) { - pvt_output_parameters.type_of_receiver = 60; // Beidou B3I + pvt_output_parameters.type_of_receiver = 600; // Beidou B3I } if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) { - pvt_output_parameters.type_of_receiver = 61; // Beidou B3I + GPS L2C + pvt_output_parameters.type_of_receiver = 601; // Beidou B3I + GPS L2C } if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) { - pvt_output_parameters.type_of_receiver = 62; // Beidou B3I + GLONASS L2 C/A + pvt_output_parameters.type_of_receiver = 602; // Beidou B3I + GLONASS L2 C/A } if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0) && (bds_B3_count != 0)) { - pvt_output_parameters.type_of_receiver = 63; // Beidou B3I + GPS L2C + GLONASS L2 C/A + pvt_output_parameters.type_of_receiver = 603; // Beidou B3I + GPS L2C + GLONASS L2 C/A } // RTKLIB PVT solver options diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 199ce7d04..9ba86b425 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2178,7 +2178,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item b_rinex_header_written = true; // do not write header anymore } break; - case 50: // BDS B1I only + case 500: // BDS B1I only if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) { rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); @@ -2188,7 +2188,68 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item } break; - case 60: // BDS B1I only + case 501: // BeiDou B1I + GPS L1 C/A + if ((gps_ephemeris_iter != d_pvt_solver->gps_ephemeris_map.cend()) and (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend())) + { + std::string bds_signal("B1"); + //rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, beidou_dnav_ephemeris_iter->second, d_rx_time, bds_signal); + //rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, gps_ephemeris_iter->second, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 502: // BeiDou B1I + Galileo E1B + if ((galileo_ephemeris_iter != d_pvt_solver->galileo_ephemeris_map.cend()) and (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend())) + { + std::string bds_signal("B1"); + std::string gal_signal("1B"); + //rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, beidou_dnav_ephemeris_iter->second, d_rx_time, gal_signal, bds_signal); + //rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->galileo_iono, d_pvt_solver->galileo_utc_model, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 503: // BeiDou B1I + GLONASS L1 C/A + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + //rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + //rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 504: // BeiDou B1I + GPS L1 C/A + Galileo E1B + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + //rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + //rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 505: // BeiDou B1I + GPS L1 C/A + GLONASS L1 C/A + Galileo E1B + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + //rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + //rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 506: // BeiDou B1I + Beidou B3I + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + //rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B1"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + //rp->log_rinex_nav(rp->navFile, d_pvt_solver->beidou_dnav_ephemeris_map); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 600: // BDS B3I only if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) { rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); @@ -2196,6 +2257,33 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item b_rinex_header_written = true; // do not write header anymore } + break; + case 601: // BeiDou B3I + GPS L2C + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 602: // BeiDou B3I + GLONASS L2 C/A + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + + break; + case 603: // BeiDou B3I + GPS L2C + GLONASS L2 C/A + if (beidou_dnav_ephemeris_iter != d_pvt_solver->beidou_dnav_ephemeris_map.cend()) + { + rp->rinex_obs_header(rp->obsFile, beidou_dnav_ephemeris_iter->second, d_rx_time, "B3"); + //rp->rinex_nav_header(rp->navFile, d_pvt_solver->beidou_dnav_iono, d_pvt_solver->beidou_dnav_utc_model); + b_rinex_header_written = true; // do not write header anymore + } + break; default: break; diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index e8a5e2e9c..7b6f14ee6 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -29,7 +29,7 @@ */ #include "rinex_printer.h" -#include "Beidou_B1I.h" +#include "Beidou_DNAV.h" #include "GLONASS_L1_L2_CA.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" @@ -1787,7 +1787,6 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_alpha3, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); out << line << std::endl; @@ -1801,7 +1800,6 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.d_beta3, 10, 2), 12); line += std::string(7, ' '); line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); out << line << std::endl; @@ -1812,7 +1810,6 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.d_A1_UTC, 15, 2), 16); line += std::string(22, ' '); line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); out << line << std::endl; @@ -1837,6 +1834,535 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& } +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Gps_Ephemeris& gps_eph, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) +{ + std::string line; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += std::string("M: MIXED"); + line += std::string(12, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1, only version 3 supported + line.clear(); + line += std::string("BDSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("BDSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("GPSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 5 system time correction + line.clear(); + line += std::string("BDUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A0_UTC, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A1_UTC, 15, 2), 16); + line += std::string(22, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction 3 + line.clear(); + line += std::string("GPUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A0, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.d_A1, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_t_OT), 7); + if (gps_eph.i_GPS_week < 512) + { + if (gps_utc_model.i_WN_T == 0) + { + line += Rinex_Printer::rightJustify(std::to_string(gps_eph.i_GPS_week + 2048), 5); // valid from 2019 to 2029 + } + else + { + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + (gps_eph.i_GPS_week / 256) * 256 + 2048), 5); // valid from 2019 to 2029 + } + } + else + { + if (gps_utc_model.i_WN_T == 0) + { + line += Rinex_Printer::rightJustify(std::to_string(gps_eph.i_GPS_week + 1024), 5); // valid from 2009 to 2019 + } + else + { + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_T + (gps_eph.i_GPS_week / 256) * 256 + 1024), 5); // valid from 2009 to 2019 + } + } + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.i_DN), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_cnav_iono, const Gps_CNAV_Utc_Model& gps_cnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) +{ + std::string line; + stringVersion = "3.02"; + version = 3; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += std::string("M: MIXED"); + line += std::string(12, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1, only version 3 supported + line.clear(); + line += std::string("BDSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("BDSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1 + line.clear(); + line += std::string("GPSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 5 system time correction + line.clear(); + line += std::string("BDUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A0_UTC, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A1_UTC, 15, 2), 16); + line += std::string(22, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction 3 + line.clear(); + line += std::string("GPUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_utc_model.d_A0, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_utc_model.d_A1, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.d_t_OT), 7); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.i_WN_T), 5); + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.i_DN), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glo_gnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) +{ + std::string line; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += std::string("M: MIXED"); + line += std::string(12, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1, only version 3 supported + line.clear(); + line += std::string("BDSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("BDSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 5 system time correction + line.clear(); + line += std::string("BDUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A0_UTC, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A1_UTC, 15, 2), 16); + line += std::string(22, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction 1 + line.clear(); + line += std::string("GLUT"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glo_gnav_utc_model.d_tau_c, 16, 2), 17); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); + line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.d_DeltaT_LS), 6); + line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.d_DeltaT_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.i_WN_LSF), 6); + line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.i_DN), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + +void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) +{ + std::string line; + + // -------- Line 1 + line = std::string(5, ' '); + line += stringVersion; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += std::string("M: MIXED"); + line += std::string(12, ' '); + line += std::string("RINEX VERSION / TYPE"); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 2 + line.clear(); + line += Rinex_Printer::getLocalTime(); + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line COMMENT + line.clear(); + line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); + line += Rinex_Printer::leftJustify("COMMENT", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1 + line.clear(); + line += std::string("GAL "); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0_5, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1_5, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2_5, 10, 2), 12); + double zero = 0.0; + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 1, only version 3 supported + line.clear(); + line += std::string("BDSA"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_alpha3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line ionospheric info 2 + line.clear(); + line += std::string("BDSB"); + line += std::string(1, ' '); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta0, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta1, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta2, 10, 2), 12); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.d_beta3, 10, 2), 12); + line += std::string(7, ' '); + line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction + line.clear(); + line += std::string("GAUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0_6, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1_6, 15, 2), 16); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t0t_6), 7); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot_6), 5); + line += std::string(10, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line system time correction 1 + // -------- Line 5 system time correction + line.clear(); + line += std::string("BDUT"); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A0_UTC, 16, 2), 18); + line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.d_A1_UTC, 15, 2), 16); + line += std::string(22, ' '); + line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- Line 6 leap seconds + // For leap second information, see http://www.endruntechnologies.com/leap.htm + line.clear(); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF_6), 6); + line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN_6), 6); + line += std::string(36, ' '); + line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; + + // -------- End of Header + line.clear(); + line += std::string(60, ' '); + line += Rinex_Printer::leftJustify("END OF HEADER", 20); + Rinex_Printer::lengthCheck(line); + out << line << std::endl; +} + + void Rinex_Printer::rinex_sbs_header(std::fstream& out) { std::string line; @@ -11045,7 +11571,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); // CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (BEIDOU_TWO_PI), 3), 14); + lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (BEIDOU_DNAV_TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 2bc13025c..90724d0d9 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -149,8 +149,31 @@ public: */ void rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_iono, const Gps_CNAV_Utc_Model& gps_utc_model, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Almanac& glonass_gnav_almanac); + /*! + * \brief Generates the BDS B1I or B3I Navigation Data header + */ void rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& iono, const Beidou_Dnav_Utc_Model& utc_model); + /*! + * \brief Generates the Mixed GPS L1,L5 + BDS B1I, B3I Navigation Data header + */ + void rinex_nav_header(std::fstream& out, const Gps_Iono& gps_lnav_iono, const Gps_Utc_Model& gps_lnav_utc_model, const Gps_Ephemeris& eph, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); + + /*! + * \brief Generates the Mixed GPS L2C + BDS B1I, B3I Navigation Data header + */ + void rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_cnav_iono, const Gps_CNAV_Utc_Model& gps_cnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); + + /*! + * \brief Generates the Mixed GLONASS L1,L2 + BDS B1I, B3I Navigation Data header + */ + void rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glo_gnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); + + /*! + * \brief Generates the Mixed (Galileo/BDS B1I, B3I) Navigation Data header + */ + void rinex_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); + /*! * \brief Generates the GPS Observation data header */ diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index ffc190d46..283584b7e 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -54,6 +54,7 @@ #include "rtklib_solver.h" #include "Beidou_B1I.h" #include "Beidou_B3I.h" +#include "Beidou_DNAV.h" #include "GLONASS_L1_L2_CA.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" @@ -730,7 +731,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ 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 + 1356, + beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 0); valid_obs++; } @@ -752,7 +753,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ { obs_data[i + glo_valid_obs] = insert_obs_to_rtklib(obs_data[i + glo_valid_obs], gnss_observables_iter->second, - beidou_ephemeris_iter->second.i_BEIDOU_week + 1356, + beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 1); // Band 3 (L2/G2/B3) found_B1I_obs = true; break; @@ -770,7 +771,7 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ {}, {0.0, 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 + 1356, + beidou_ephemeris_iter->second.i_BEIDOU_week + BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET, 1); // Band 2 (L2/G2) valid_obs++; } diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.cc b/src/algorithms/libs/rtklib/rtklib_conversions.cc index a07abb5b6..60afc63fd 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.cc +++ b/src/algorithms/libs/rtklib/rtklib_conversions.cc @@ -301,6 +301,9 @@ eph_t eph_to_rtklib(const Beidou_Dnav_Ephemeris& bei_eph) rtklib_sat.Adot = 0; //only in CNAV; rtklib_sat.ndot = 0; //only in CNAV; + rtklib_sat.svh = bei_eph.i_SV_health; + rtklib_sat.sva = bei_eph.i_SV_accuracy; + rtklib_sat.code = bei_eph.i_sig_type; /*B1I data*/ rtklib_sat.flag = bei_eph.i_nav_type; /*MEO/IGSO satellite*/ rtklib_sat.iode = static_cast(bei_eph.d_AODE); /* AODE */ diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 2715a369a..901161d58 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -282,6 +282,11 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel, PC = P2 + P1_P2 - ISCl5i; } } + if (sys == SYS_BDS) + { + P2 += P2_C2; /* C2->P2 */ + PC = P2; // no tgd corrections for B3I + } else if (sys == SYS_GAL or sys == SYS_GLO or sys == SYS_BDS) // Gal. E5a single freq. { P2 += P2_C2; /* C2->P2 */ diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index 57f8d5e7b..b6ab145b3 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -29,10 +29,10 @@ * * ------------------------------------------------------------------------- */ - - #include "beidou_b1i_telemetry_decoder_gs.h" #include "Beidou_B1I.h" +#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" @@ -57,7 +57,6 @@ beidou_b1i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) return beidou_b1i_telemetry_decoder_gs_sptr(new beidou_b1i_telemetry_decoder_gs(satellite, dump)); } - beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs( const Gnss_Satellite &satellite, bool dump) : gr::block("beidou_b1i_telemetry_decoder_gs", @@ -75,63 +74,38 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs( d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); LOG(INFO) << "Initializing BeiDou B1I Telemetry Decoding for satellite " << this->d_satellite; - d_samples_per_symbol = (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS) / BEIDOU_D1NAV_SYMBOL_RATE_SPS; + d_symbol_duration_ms = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_B1I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); - d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - - // Setting samples of secondary code - for (int32_t i = 0; i < BEIDOU_B1I_SECONDARY_CODE_LENGTH; i++) - { - if (BEIDOU_B1I_SECONDARY_CODE.at(i) == '1') - { - d_secondary_code_symbols[i] = 1; - } - else - { - d_secondary_code_symbols[i] = -1; - } - } + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of preamble code - int32_t n = 0; for (int32_t i = 0; i < d_symbols_per_preamble; i++) { - int32_t m = 0; if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B1I_SECONDARY_CODE_LENGTH; - } + d_preamble_samples[i] = 1; } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = -d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B1I_SECONDARY_CODE_LENGTH; - } + d_preamble_samples[i] = -1; } } - d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); + d_last_valid_preamble = 0; + d_sent_tlm_failed_msg = false; + d_flag_valid_word = false; // Generic settings d_sample_counter = 0; d_stat = 0; d_preamble_index = 0; d_flag_frame_sync = false; - d_TOW_at_current_symbol_ms = 0; + d_TOW_at_current_symbol_ms = 0U; d_TOW_at_Preamble_ms = 0U; Flag_valid_word = false; d_CRC_error_counter = 0; @@ -144,7 +118,6 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs( beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs() { volk_gnsssdr_free(d_preamble_samples); - volk_gnsssdr_free(d_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); if (d_dump_file.is_open() == true) @@ -192,7 +165,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, in void beidou_b1i_telemetry_decoder_gs::decode_word( int32_t word_counter, - const double *enc_word_symbols, + const float *enc_word_symbols, int32_t *dec_word_symbols) { int32_t bitsbch[30], first_branch[15], second_branch[15]; @@ -232,7 +205,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_word( } -void beidou_b1i_telemetry_decoder_gs::decode_subframe(double *frame_symbols) +void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) { // 1. Transform from symbols to bits std::string data_bits; @@ -263,11 +236,13 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(double *frame_symbols) // 3. Check operation executed correctly if (d_nav.flag_crc_test == true) { - DLOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel + << " from satellite " << d_satellite; } else { - DLOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel + << " from satellite " << d_satellite; } // 4. Push the new navigation data to the queues if (d_nav.have_new_ephemeris() == true) @@ -322,41 +297,59 @@ void beidou_b1i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell { // Clear values from previous declaration volk_gnsssdr_free(d_preamble_samples); - volk_gnsssdr_free(d_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); - d_samples_per_symbol = (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS) / BEIDOU_D2NAV_SYMBOL_RATE_SPS; d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = nullptr; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); - d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of preamble code - int32_t n = 0; for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = 1; - n++; - } + d_preamble_samples[i] = 1; } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = -1; - n++; - } + d_preamble_samples[i] = -1; } } - d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); + d_symbol_duration_ms = BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); + } + else + { + // Clear values from previous declaration + volk_gnsssdr_free(d_preamble_samples); + volk_gnsssdr_free(d_subframe_symbols); + //back to normal satellites + d_symbol_duration_ms = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; + + // Setting samples of preamble code + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + d_preamble_samples[i] = 1; + } + else + { + d_preamble_samples[i] = -1; + } + } + + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); } } @@ -387,6 +380,15 @@ void beidou_b1i_telemetry_decoder_gs::set_channel(int32_t channel) } } +void beidou_b1i_telemetry_decoder_gs::reset() +{ + d_last_valid_preamble = d_sample_counter; + d_TOW_at_current_symbol_ms = 0; + d_sent_tlm_failed_msg = false; + d_flag_valid_word = false; + DLOG(INFO) << "Beidou B1I Telemetry decoder reset for satellite " << d_satellite; + return; +} int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -403,10 +405,9 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue d_sample_counter++; // count for the processed samples consume_each(1); - d_flag_preamble = false; - if (d_symbol_history.size() > d_required_symbols) + if (d_symbol_history.size() >= d_required_symbols) { //******* preamble correlation ******** for (int32_t i = 0; i < d_samples_per_preamble; i++) @@ -421,7 +422,6 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ } } } - //******* frame sync ****************** if (d_stat == 0) // no preamble information { @@ -429,7 +429,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ { // Record the preamble sample stamp d_preamble_index = d_sample_counter; - LOG(INFO) << "Preamble detection for BEIDOU B1I SAT " << this->d_satellite; + DLOG(INFO) << "Preamble detection for BEIDOU B1I SAT " << this->d_satellite; // Enter into frame pre-detection status d_stat = 1; } @@ -443,9 +443,54 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ if (abs(preamble_diff - d_preamble_period_samples) == 0) { // try to decode frame - LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; + DLOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; d_preamble_index = d_sample_counter; //record the preamble sample stamp + + d_stat = 2; + + // ******* SAMPLES TO SYMBOLS ******* + if (corr_value > 0) //normal PLL lock + { + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = d_symbol_history.at(i); + } + } + else // 180 deg. inverted carrier phase PLL lock + { + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = -d_symbol_history.at(i); + } + } + + // call the decoder + decode_subframe(d_subframe_symbols); + + if (d_nav.flag_crc_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << "BeiDou DNAV frame sync found for SAT " << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + DLOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + flag_SOW_set = false; + } + } } else { @@ -464,50 +509,16 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ // ******* SAMPLES TO SYMBOLS ******* if (corr_value > 0) //normal PLL lock { - int32_t k = 0; for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) - { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += d_symbol_history.at(i * d_samples_per_symbol + m); - } - else - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += static_cast(d_secondary_code_symbols[k]) * d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B1I_SECONDARY_CODE_LENGTH; - } - } + d_subframe_symbols[i] = d_symbol_history.at(i); } } else // 180 deg. inverted carrier phase PLL lock { - int32_t k = 0; for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) - { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= d_symbol_history.at(i * d_samples_per_symbol + m); - } - else - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= static_cast(d_secondary_code_symbols[k]) * d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B1I_SECONDARY_CODE_LENGTH; - } - } + d_subframe_symbols[i] = -d_symbol_history.at(i); } } @@ -531,7 +542,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { - LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite; + DLOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite; d_flag_frame_sync = false; d_stat = 0; flag_SOW_set = false; @@ -539,60 +550,74 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_ } } } - // UPDATE GNSS SYNCHRO DATA // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) // update TOW at the preamble instant { // Reporting sow as gps time of week - d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * BEIDOU_B1I_CODE_PERIOD_MS); + d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); + //check TOW update consistency + uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + //compute new TOW + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + d_required_symbols * d_symbol_duration_ms; flag_SOW_set = true; d_nav.flag_new_SOW_available = false; - } - else // if there is not a new preamble, we define the TOW of the current symbol - { - d_TOW_at_current_symbol_ms += static_cast(BEIDOU_B1I_CODE_PERIOD_MS); - } + if (last_d_TOW_at_current_symbol_ms != 0 and abs(static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > d_symbol_duration_ms) + { + LOG(INFO) << "Warning: BEIDOU B1I TOW update in ch " << d_channel + << " does not match the TLM TOW counter " << static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms) << " ms \n"; - if (d_flag_frame_sync == true and flag_SOW_set == true) - { - current_symbol.Flag_valid_word = true; + d_TOW_at_current_symbol_ms = 0; + d_flag_valid_word = false; + } + else + { + d_last_valid_preamble = d_sample_counter; + d_flag_valid_word = true; + } } else { - current_symbol.Flag_valid_word = false; + if (d_flag_valid_word) + { + d_TOW_at_current_symbol_ms += d_symbol_duration_ms; + if (current_symbol.Flag_valid_symbol_output == false) + { + d_flag_valid_word = false; + } + } } - current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; - - if (d_dump == true) + if (d_flag_valid_word == true) { - // MULTIPLEXED FILE RECORDING - Record results to file - try + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_symbol.Flag_valid_word = d_flag_valid_word; + + if (d_dump == true) { - double tmp_double; - uint64_t tmp_ulong_int; - tmp_double = static_cast(d_TOW_at_current_symbol_ms); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); - tmp_double = d_nav.d_SOW; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = static_cast(d_required_symbols); - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); + } } + + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + return 1; } - - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; - - return 1; + return 0; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h index 3a7b8debf..9485008fd 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h @@ -39,7 +39,7 @@ #include #include // for boost::shared_ptr #include // for block -#include // for gr_vector_const_void_star +#include // for gr_vector_const_void_star #include #include #include @@ -62,10 +62,8 @@ public: ~beidou_b1i_telemetry_decoder_gs(); //!< Class destructor void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN void set_channel(int channel); //!< Set receiver's channel - inline void reset() - { - return; - } + void reset(); + /*! * \brief This is where all signal processing takes place */ @@ -77,19 +75,17 @@ private: beidou_b1i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); - void decode_subframe(double *symbols); - void decode_word(int32_t word_counter, const double *enc_word_symbols, int32_t *dec_word_symbols); + void decode_subframe(float *symbols); + void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols); void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); // Preamble decoding int32_t *d_preamble_samples; - int32_t *d_secondary_code_symbols; - uint32_t d_samples_per_symbol; int32_t d_symbols_per_preamble; int32_t d_samples_per_preamble; int32_t d_preamble_period_samples; - double *d_subframe_symbols; + float *d_subframe_symbols; uint32_t d_required_symbols; // Storage for incoming data @@ -107,12 +103,16 @@ private: //!< Navigation Message variable Beidou_Dnav_Navigation_Message d_nav; - //!< Values to populate gnss synchronization structure + // Values to populate gnss synchronization structure + uint32_t d_symbol_duration_ms; uint32_t d_TOW_at_Preamble_ms; uint32_t d_TOW_at_current_symbol_ms; + uint64_t d_last_valid_preamble; + bool d_flag_valid_word; + bool d_sent_tlm_failed_msg; 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; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index 01530cd32..395b4bc82 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -53,8 +53,7 @@ beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) { - return beidou_b3i_telemetry_decoder_gs_sptr( - new beidou_b3i_telemetry_decoder_gs(satellite, dump)); + return beidou_b3i_telemetry_decoder_gs_sptr(new beidou_b3i_telemetry_decoder_gs(satellite, dump)); } @@ -70,74 +69,37 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs( this->message_port_register_out(pmt::mp("telemetry")); // Control messages to tracking block this->message_port_register_out(pmt::mp("telemetry_to_trk")); - // initialize internal vars d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " - << this->d_satellite; + LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " << this->d_satellite; - d_samples_per_symbol = - (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / - BEIDOU_D1NAV_SYMBOL_RATE_SPS; + d_symbol_duration_ms = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS; d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = - BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = static_cast( - volk_gnsssdr_malloc(BEIDOU_B3I_SECONDARY_CODE_LENGTH * sizeof(int32_t), - volk_gnsssdr_get_alignment())); - d_preamble_samples = static_cast(volk_gnsssdr_malloc( - d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); - d_preamble_period_samples = - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - - // Setting samples of secondary code - for (int32_t i = 0; i < BEIDOU_B3I_SECONDARY_CODE_LENGTH; i++) - { - if (BEIDOU_B3I_SECONDARY_CODE.at(i) == '1') - { - d_secondary_code_symbols[i] = 1; - } - else - { - d_secondary_code_symbols[i] = -1; - } - } + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of preamble code - int32_t n = 0; for (int32_t i = 0; i < d_symbols_per_preamble; i++) { - int32_t m = 0; if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } + d_preamble_samples[i] = 1; } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = -d_secondary_code_symbols[m]; - n++; - m++; - m = m % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } + d_preamble_samples[i] = -1; } } - d_subframe_symbols = static_cast( - volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), - volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + - d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); + d_last_valid_preamble = 0; + d_sent_tlm_failed_msg = false; + d_flag_valid_word = false; // Generic settings d_sample_counter = 0; d_stat = 0; @@ -156,7 +118,6 @@ 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_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); if (d_dump_file.is_open() == true) @@ -167,8 +128,7 @@ beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs() } catch (const std::exception &ex) { - LOG(WARNING) << "Exception in destructor closing the dump file " - << ex.what(); + LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); } } } @@ -205,7 +165,8 @@ void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, void beidou_b3i_telemetry_decoder_gs::decode_word( - int32_t word_counter, const double *enc_word_symbols, + int32_t word_counter, + const float *enc_word_symbols, int32_t *dec_word_symbols) { int32_t bitsbch[30], first_branch[15], second_branch[15]; @@ -214,8 +175,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_word( { for (uint32_t j = 0; j < 30; j++) { - dec_word_symbols[j] = - static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); + dec_word_symbols[j] = static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); } } else @@ -224,8 +184,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_word( { for (uint32_t c = 0; c < 15; c++) { - bitsbch[r * 15 + c] = - static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); + bitsbch[r * 15 + c] = static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); } } @@ -247,7 +206,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_word( } -void beidou_b3i_telemetry_decoder_gs::decode_subframe(double *frame_symbols) +void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols) { // 1. Transform from symbols to bits std::string data_bits; @@ -356,50 +315,62 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite( { // Clear values from previous declaration volk_gnsssdr_free(d_preamble_samples); - volk_gnsssdr_free(d_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); - d_samples_per_symbol = - (BEIDOU_B3I_CODE_RATE_HZ / BEIDOU_B3I_CODE_LENGTH_CHIPS) / - BEIDOU_D2NAV_SYMBOL_RATE_SPS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = - BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; - d_secondary_code_symbols = nullptr; - d_preamble_samples = static_cast( - volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), - volk_gnsssdr_get_alignment())); - d_preamble_period_samples = - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of preamble code - int32_t n = 0; for (int32_t i = 0; i < d_symbols_per_preamble; i++) { if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = 1; - n++; - } + d_preamble_samples[i] = 1; } else { - for (uint32_t j = 0; j < d_samples_per_symbol; j++) - { - d_preamble_samples[n] = -1; - n++; - } + d_preamble_samples[i] = -1; + } + } + d_symbol_duration_ms = BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS; + d_subframe_symbols = static_cast(volk_gnsssdr_malloc( + BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), + volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); + } + else + { + // Clear values from previous declaration + volk_gnsssdr_free(d_preamble_samples); + volk_gnsssdr_free(d_subframe_symbols); + //back to normal satellites + d_symbol_duration_ms = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS; + d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; + d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); + d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; + + // Setting samples of preamble code + for (int32_t i = 0; i < d_symbols_per_preamble; i++) + { + if (BEIDOU_DNAV_PREAMBLE.at(i) == '1') + { + d_preamble_samples[i] = 1; + } + else + { + d_preamble_samples[i] = -1; } } - d_subframe_symbols = static_cast(volk_gnsssdr_malloc( - BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), - volk_gnsssdr_get_alignment())); - d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + - d_samples_per_preamble; - d_symbol_history.set_capacity(d_required_symbols + 1); + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment())); + d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols); } } @@ -434,6 +405,15 @@ void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel) } } +void beidou_b3i_telemetry_decoder_gs::reset() +{ + d_last_valid_preamble = d_sample_counter; + d_TOW_at_current_symbol_ms = 0; + d_sent_tlm_failed_msg = false; + d_flag_valid_word = false; + DLOG(INFO) << "Beidou B3I Telemetry decoder reset for satellite " << d_satellite; + return; +} int beidou_b3i_telemetry_decoder_gs::general_work( int noutput_items __attribute__((unused)), @@ -454,10 +434,9 @@ int beidou_b3i_telemetry_decoder_gs::general_work( d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue d_sample_counter++; // count for the processed samples consume_each(1); - d_flag_preamble = false; - if (d_symbol_history.size() > d_required_symbols) + if (d_symbol_history.size() >= d_required_symbols) { //******* preamble correlation ******** for (int32_t i = 0; i < d_samples_per_preamble; i++) @@ -472,7 +451,6 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } } } - //******* frame sync ****************** if (d_stat == 0) // no preamble information { @@ -480,8 +458,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work( { // Record the preamble sample stamp d_preamble_index = d_sample_counter; - LOG(INFO) << "Preamble detection for BEIDOU B3I SAT " - << this->d_satellite; + DLOG(INFO) << "Preamble detection for BEIDOU B3I SAT " << this->d_satellite; // Enter into frame pre-detection status d_stat = 1; } @@ -495,10 +472,55 @@ int beidou_b3i_telemetry_decoder_gs::general_work( if (abs(preamble_diff - d_preamble_period_samples) == 0) { // try to decode frame - LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B3I SAT " - << this->d_satellite; + DLOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B3I SAT " + << this->d_satellite; d_preamble_index = d_sample_counter; // record the preamble sample stamp d_stat = 2; + + // ******* SAMPLES TO SYMBOLS ******* + if (corr_value > 0) //normal PLL lock + { + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = d_symbol_history.at(i); + } + } + else // 180 deg. inverted carrier phase PLL lock + { + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) + { + d_subframe_symbols[i] = -d_symbol_history.at(i); + } + } + + // call the decoder + decode_subframe(d_subframe_symbols); + + if (d_nav.flag_crc_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << "BeiDou DNAV frame sync found for SAT " + << this->d_satellite; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; // record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + DLOG(INFO) << "BeiDou DNAV frame sync lost for SAT " + << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + flag_SOW_set = false; + } + } } else { @@ -513,62 +535,21 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } else if (d_stat == 2) // preamble acquired { - if (d_sample_counter == - d_preamble_index + static_cast(d_preamble_period_samples)) + if (d_sample_counter == d_preamble_index + static_cast(d_preamble_period_samples)) { - //******* SAMPLES TO SYMBOLS ******* - if (corr_value > 0) // normal PLL lock + // ******* SAMPLES TO SYMBOLS ******* + if (corr_value > 0) //normal PLL lock { - int32_t k = 0; for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) - { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += - d_symbol_history.at(i * d_samples_per_symbol + m); - } - else - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] += - static_cast(d_secondary_code_symbols[k]) * - d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } + d_subframe_symbols[i] = d_symbol_history.at(i); } } else // 180 deg. inverted carrier phase PLL lock { - int32_t k = 0; for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { - d_subframe_symbols[i] = 0; - // integrate samples into symbols - for (uint32_t m = 0; m < d_samples_per_symbol; m++) - { - if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= - d_symbol_history.at(i * d_samples_per_symbol + m); - } - else - { - // because last symbol of the preamble is just received now! - d_subframe_symbols[i] -= - static_cast(d_secondary_code_symbols[k]) * - d_symbol_history.at(i * d_samples_per_symbol + m); - k++; - k = k % BEIDOU_B3I_SECONDARY_CODE_LENGTH; - } - } + d_subframe_symbols[i] = -d_symbol_history.at(i); } } @@ -578,10 +559,8 @@ int beidou_b3i_telemetry_decoder_gs::general_work( if (d_nav.flag_crc_test == true) { d_CRC_error_counter = 0; - d_flag_preamble = true; // valid preamble indicator (initialized to - // false every work()) - d_preamble_index = - d_sample_counter; // record the preamble sample stamp (t_P) + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -595,8 +574,8 @@ int beidou_b3i_telemetry_decoder_gs::general_work( d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { - LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " - << this->d_satellite; + DLOG(INFO) << "BeiDou DNAV frame sync lost for SAT " + << this->d_satellite; d_flag_frame_sync = false; d_stat = 0; flag_SOW_set = false; @@ -604,63 +583,74 @@ int beidou_b3i_telemetry_decoder_gs::general_work( } } } - // UPDATE GNSS SYNCHRO DATA // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) // update TOW at the preamble instant { // Reporting sow as gps time of week - d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); - d_TOW_at_current_symbol_ms = - d_TOW_at_Preamble_ms + static_cast((d_required_symbols + 1) * - BEIDOU_B3I_CODE_PERIOD_MS); + d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET) * 1000.0); + //check TOW update consistency + uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + //compute new TOW + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + d_required_symbols * d_symbol_duration_ms; flag_SOW_set = true; d_nav.flag_new_SOW_available = false; - } - else // if there is not a new preamble, we define the TOW of the current - // symbol - { - d_TOW_at_current_symbol_ms += - static_cast(BEIDOU_B3I_CODE_PERIOD_MS); - } - if (d_flag_frame_sync == true and flag_SOW_set == true) - { - current_symbol.Flag_valid_word = true; + if (last_d_TOW_at_current_symbol_ms != 0 and abs(static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > d_symbol_duration_ms) + { + LOG(INFO) << "Warning: BEIDOU B3I TOW update in ch " << d_channel + << " does not match the TLM TOW counter " << static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms) << " ms \n"; + + d_TOW_at_current_symbol_ms = 0; + d_flag_valid_word = false; + } + else + { + d_last_valid_preamble = d_sample_counter; + d_flag_valid_word = true; + } } else { - current_symbol.Flag_valid_word = false; + if (d_flag_valid_word) + { + d_TOW_at_current_symbol_ms += d_symbol_duration_ms; + if (current_symbol.Flag_valid_symbol_output == false) + { + d_flag_valid_word = false; + } + } } - current_symbol.PRN = this->d_satellite.get_PRN(); - current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; - - if (d_dump == true) + if (d_flag_valid_word == true) { - // MULTIPLEXED FILE RECORDING - Record results to file - try + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_symbol.Flag_valid_word = d_flag_valid_word; + + if (d_dump == true) { - double tmp_double; - uint64_t tmp_ulong_int; - tmp_double = static_cast(d_TOW_at_current_symbol_ms); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); - tmp_double = d_nav.d_SOW; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = static_cast(d_required_symbols); - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + uint64_t tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); + } } + + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + return 1; } - - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; - - return 1; + return 0; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h index 54bac3adb..d08f8388e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h @@ -60,10 +60,8 @@ public: ~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 - inline void reset() - { - return; - } + void reset(); + /*! * \brief This is where all signal processing takes place */ @@ -77,27 +75,24 @@ private: 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, const double *enc_word_symbols, + void decode_subframe(float *symbols); + void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols); void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); // Preamble decoding int32_t *d_preamble_samples; - int32_t *d_secondary_code_symbols; - uint32_t d_samples_per_symbol; int32_t d_symbols_per_preamble; int32_t d_samples_per_preamble; int32_t d_preamble_period_samples; - double *d_subframe_symbols; + float *d_subframe_symbols; uint32_t d_required_symbols; // Storage for incoming data boost::circular_buffer d_symbol_history; // Variables for internal functionality - uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) - // indicating number of samples processed + uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed uint64_t d_preamble_index; // Index of sample number where preamble was found uint32_t d_stat; // Status of decoder bool d_flag_frame_sync; // Indicate when a frame sync is achieved @@ -109,8 +104,12 @@ private: Beidou_Dnav_Navigation_Message d_nav; // Values to populate gnss synchronization structure + uint32_t d_symbol_duration_ms; uint32_t d_TOW_at_Preamble_ms; uint32_t d_TOW_at_current_symbol_ms; + uint64_t d_last_valid_preamble; + bool d_flag_valid_word; + bool d_sent_tlm_failed_msg; bool Flag_valid_word; // Satellite Information and logging capacity diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index c57266ee8..36b81a656 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -286,17 +286,16 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_code_period = BEIDOU_B1I_CODE_PERIOD; d_code_chip_rate = BEIDOU_B1I_CODE_RATE_HZ; d_code_length_chips = static_cast(BEIDOU_B1I_CODE_LENGTH_CHIPS); - //d_symbols_per_bit = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_secondary = false; + d_secondary = true; trk_parameters.track_pilot = false; // synchronize and remove data secondary code d_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); - //d_data_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); - //d_data_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); + d_data_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); + d_data_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); } else if (signal_type == "B3") { @@ -305,16 +304,15 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_code_period = BEIDOU_B3I_CODE_PERIOD; d_code_chip_rate = BEIDOU_B3I_CODE_RATE_HZ; d_code_length_chips = static_cast(BEIDOU_B3I_CODE_LENGTH_CHIPS); - //d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; d_secondary = false; trk_parameters.track_pilot = false; d_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); - //d_data_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); - //d_data_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); + d_data_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); + d_data_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); } else { @@ -651,8 +649,7 @@ void dll_pll_veml_tracking::start_tracking() // GEO Satellites use different secondary code if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) { - //d_symbols_per_bit = BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT;//todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; d_secondary = false; @@ -665,8 +662,7 @@ void dll_pll_veml_tracking::start_tracking() } else { - //d_symbols_per_bit = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT;//todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; d_secondary = false; @@ -674,8 +670,8 @@ void dll_pll_veml_tracking::start_tracking() // synchronize and remove data secondary code d_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); - //d_data_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); - //d_data_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); + d_data_secondary_code_length = static_cast(BEIDOU_B1I_SECONDARY_CODE_LENGTH); + d_data_secondary_code_string = const_cast(&BEIDOU_B1I_SECONDARY_CODE_STR); d_Prompt_circular_buffer.set_capacity(d_secondary_code_length); } } @@ -686,11 +682,10 @@ void dll_pll_veml_tracking::start_tracking() // Update secondary code settings for geo satellites if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) { - //d_symbols_per_bit = BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT;//todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_secondary = false; + d_secondary = true; trk_parameters.track_pilot = false; // set the preamble in the secondary code acquisition d_secondary_code_length = static_cast(BEIDOU_B3I_GEO_PREAMBLE_LENGTH_SYMBOLS); @@ -700,17 +695,16 @@ void dll_pll_veml_tracking::start_tracking() } else { - //d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization - d_symbols_per_bit = 1; + d_symbols_per_bit = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; d_code_samples_per_chip = 1; - d_secondary = false; + d_secondary = true; trk_parameters.track_pilot = false; // synchronize and remove data secondary code d_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); - //d_data_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); - //d_data_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); + d_data_secondary_code_length = static_cast(BEIDOU_B3I_SECONDARY_CODE_LENGTH); + d_data_secondary_code_string = const_cast(&BEIDOU_B3I_SECONDARY_CODE_STR); d_Prompt_circular_buffer.set_capacity(d_secondary_code_length); } } diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h index eebba1de5..74b4b418f 100644 --- a/src/core/system_parameters/Beidou_B1I.h +++ b/src/core/system_parameters/Beidou_B1I.h @@ -36,45 +36,26 @@ #include #include -// Physical constants -const double BEIDOU_C_M_S = 299792458.0; //!< The speed of light, [m/s] -const double BEIDOU_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] -const double BEIDOU_PI = 3.1415926535898; //!< Pi -const double BEIDOU_TWO_PI = 6.283185307179586; //!< 2Pi -const double BEIDOU_OMEGA_EARTH_DOT = 7.2921150e-5; //!< Earth rotation rate, [rad/s] as defined in CGCS2000 -const double BEIDOU_GM = 3.986004418e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] as defined in CGCS2000 -const double BEIDOU_F = -4.442807309e-10; //!< Constant, [s/(m)^(1/2)] F=-2(GM)^.5/C^2 - - // carrier and code frequencies const double BEIDOU_B1I_FREQ_HZ = 1.561098e9; //!< B1I [Hz] const double BEIDOU_B1I_CODE_RATE_HZ = 2.046e6; //!< Beidou B1I code rate [chips/s] const double BEIDOU_B1I_CODE_LENGTH_CHIPS = 2046.0; //!< Beidou B1I code length [chips] const double BEIDOU_B1I_CODE_PERIOD = 0.001; //!< Beidou B1I code period [seconds] const uint32_t BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< Beidou B1I code period [ms] -const double BEIDOU_B1I_CHIP_PERIOD = 4.8875e-07; //!< Beidou B1I chip period [seconds] const int32_t BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; -const std::string BEIDOU_B1I_SECONDARY_CODE = "00000100110101001110"; const std::string BEIDOU_B1I_SECONDARY_CODE_STR = "00000100110101001110"; const std::string BEIDOU_B1I_GEO_PREAMBLE_SYMBOLS_STR = {"1111110000001100001100"}; const int32_t BEIDOU_B1I_GEO_PREAMBLE_LENGTH_SYMBOLS = 22; - const std::string BEIDOU_B1I_D2_SECONDARY_CODE_STR = "00"; -const int BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; -const int BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** +const uint32_t BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; +const uint32_t BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; const double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; -const int BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; -const int BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] -const int BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; -const int BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT = 2; -const int BEIDOU_B1I_TELEMETRY_SYMBOL_PERIOD_MS = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; -const int BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] -const int BEIDOU_WORD_LENGTH = 4; //**************!< CRC + BEIDOU WORD (-2 -1 0 ... 29) Bits = 4 bytes -const int BEIDOU_SUBFRAME_LENGTH = 40; //**************!< BEIDOU_WORD_LENGTH x 10 = 40 bytes -const int BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] -const int BEIDOU_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] -const int BEIDOU_SUBFRAME_MS = 6000; //!< Subframe duration [milliseconds] -const int BEIDOU_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] +const int32_t BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; +const int32_t BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; +const int32_t BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; +const int32_t BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT = 2; +const int32_t BEIDOU_B1I_TELEMETRY_SYMBOL_PERIOD_MS = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS; +const int32_t BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; #endif /* GNSS_SDR_BEIDOU_B1I_H_ */ diff --git a/src/core/system_parameters/Beidou_B3I.h b/src/core/system_parameters/Beidou_B3I.h index bf77457f5..b73fbbf0a 100644 --- a/src/core/system_parameters/Beidou_B3I.h +++ b/src/core/system_parameters/Beidou_B3I.h @@ -42,7 +42,6 @@ const double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code lengt const double BEIDOU_B3I_CODE_PERIOD = 0.001; //!< BeiDou B3I code period [seconds] const uint32_t BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< BeiDou B3I code period [ms] const int32_t BEIDOU_B3I_SECONDARY_CODE_LENGTH = 20; -const std::string BEIDOU_B3I_SECONDARY_CODE = "00000100110101001110"; const std::string BEIDOU_B3I_SECONDARY_CODE_STR = "00000100110101001110"; const std::string BEIDOU_B3I_GEO_PREAMBLE_SYMBOLS_STR = {"1111110000001100001100"}; const int32_t BEIDOU_B3I_GEO_PREAMBLE_LENGTH_SYMBOLS = 22; @@ -53,7 +52,9 @@ const double BEIDOU_B3I_PREAMBLE_DURATION_S = 0.220; const int32_t BEIDOU_B3I_PREAMBLE_DURATION_MS = 220; const int32_t BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] const int32_t BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT = 20; -const int32_t BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT = 2; // ************* -const int32_t BEIDOU_B3I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] +const int32_t BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT = 2; // ************* +const int32_t BEIDOU_B3I_TELEMETRY_SYMBOL_PERIOD_MS = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS; +const int32_t BEIDOU_B3I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B3I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT; + #endif /* GNSS_SDR_BEIDOU_B3I_H_ */ diff --git a/src/core/system_parameters/Beidou_DNAV.h b/src/core/system_parameters/Beidou_DNAV.h index fd2792493..fdbdf7dfd 100644 --- a/src/core/system_parameters/Beidou_DNAV.h +++ b/src/core/system_parameters/Beidou_DNAV.h @@ -36,21 +36,30 @@ #include #include -const double BEIDOU_DNAV_C_M_S = 299792458.0; //!< The speed of light, [m/s] -const double BEIDOU_DNAV_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] -const double BEIDOU_DNAV_PI = 3.1415926535898; //!< Pi -const double BEIDOU_DNAV_TWO_PI = 6.283185307179586; //!< 2Pi +const double BEIDOU_DNAV_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double BEIDOU_DNAV_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] +const double BEIDOU_DNAV_PI = 3.1415926535898; //!< BeiDou DNAV Pi +const double BEIDOU_DNAV_TWO_PI = 6.2831853071796; //!< BeiDou DNAV 2Pi +const double BEIDOU_DNAV_OMEGA_EARTH_DOT = 7.2921150e-5; //!< Earth rotation rate, [rad/s] as defined in CGCS2000 +const double BEIDOU_DNAV_GM = 3.986004418e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2] as defined in CGCS2000 +const double BEIDOU_DNAV_F = -4.442807309e-10; //!< Constant, [s/(m)^(1/2)] F=-2(GM)^.5/C^2 + const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11; const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // ************** const double BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300; const double BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300; -const double BEIDOU_DNAV_DATA_BITS = 300; +const int32_t BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] const double BEIDOU_DNAV_WORDS_SUBFRAME = 10; const double BEIDOU_DNAV_WORD_LENGTH_BITS = 30; const double BEIDOU_D1NAV_SYMBOL_RATE_SPS = 50; const double BEIDOU_D2NAV_SYMBOL_RATE_SPS = 500; const std::string BEIDOU_DNAV_PREAMBLE = "11100010010"; +// Number of leap seconds passed from the start of the GPS epoch up to the start of BeiDou epoch +const int32_t BEIDOU_DNAV_BDT2GPST_LEAP_SEC_OFFSET = 14; +// Number of weeks passed from the start of the GPS epoch up to the start of BeiDou epoch +const int32_t BEIDOU_DNAV_BDT2GPST_WEEK_NUM_OFFSET = 1356; + // BEIDOU D1 NAVIGATION MESSAGE STRUCTURE // GENERAL const std::vector > D1_PRE({{1, 11}}); diff --git a/src/core/system_parameters/beidou_dnav_ephemeris.cc b/src/core/system_parameters/beidou_dnav_ephemeris.cc index 5081daa6a..46f6faddb 100644 --- a/src/core/system_parameters/beidou_dnav_ephemeris.cc +++ b/src/core/system_parameters/beidou_dnav_ephemeris.cc @@ -29,7 +29,7 @@ */ #include "beidou_dnav_ephemeris.h" -#include "Beidou_B1I.h" +#include "Beidou_DNAV.h" #include "gnss_satellite.h" #include @@ -148,14 +148,14 @@ double Beidou_Dnav_Ephemeris::sv_clock_relativistic_term(double transmitTime) tk = check_t(transmitTime - d_Toe); // Computed mean motion - n0 = sqrt(BEIDOU_GM / (a * a * a)); + n0 = sqrt(BEIDOU_DNAV_GM / (a * a * a)); // Corrected mean motion n = n0 + d_Delta_n; // Mean anomaly M = d_M_0 + n * tk; // Reduce mean anomaly to between 0 and 2pi - M = fmod((M + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + M = fmod((M + 2.0 * BEIDOU_DNAV_PI), (2.0 * BEIDOU_DNAV_PI)); // Initial guess of eccentric anomaly E = M; @@ -165,7 +165,7 @@ double Beidou_Dnav_Ephemeris::sv_clock_relativistic_term(double transmitTime) { E_old = E; E = M + d_eccentricity * sin(E); - dE = fmod(E - E_old, 2.0 * BEIDOU_PI); + dE = fmod(E - E_old, 2.0 * BEIDOU_DNAV_PI); if (fabs(dE) < 1e-12) { //Necessary precision is reached, exit from the loop @@ -174,7 +174,7 @@ double Beidou_Dnav_Ephemeris::sv_clock_relativistic_term(double transmitTime) } // Compute relativistic correction term - d_dtr = BEIDOU_F * d_eccentricity * d_sqrt_A * sin(E); + d_dtr = BEIDOU_DNAV_F * d_eccentricity * d_sqrt_A * sin(E); return d_dtr; } @@ -205,7 +205,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) tk = check_t(transmitTime - d_Toe); // Computed mean motion - n0 = sqrt(BEIDOU_GM / (a * a * a)); + n0 = sqrt(BEIDOU_DNAV_GM / (a * a * a)); // Corrected mean motion n = n0 + d_Delta_n; @@ -214,7 +214,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) M = d_M_0 + n * tk; // Reduce mean anomaly to between 0 and 2pi - M = fmod((M + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + M = fmod((M + 2.0 * BEIDOU_DNAV_PI), (2.0 * BEIDOU_DNAV_PI)); // Initial guess of eccentric anomaly E = M; @@ -224,7 +224,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) { E_old = E; E = M + d_eccentricity * sin(E); - dE = fmod(E - E_old, 2.0 * BEIDOU_PI); + dE = fmod(E - E_old, 2.0 * BEIDOU_DNAV_PI); if (fabs(dE) < 1e-12) { //Necessary precision is reached, exit from the loop @@ -241,7 +241,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) phi = nu + d_OMEGA; // Reduce phi to between 0 and 2*pi rad - phi = fmod((phi), (2.0 * BEIDOU_PI)); + phi = fmod((phi), (2.0 * BEIDOU_DNAV_PI)); // Correct argument of latitude u = phi + d_Cuc * cos(2.0 * phi) + d_Cus * sin(2.0 * phi); @@ -253,10 +253,10 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) i = d_i_0 + d_IDOT * tk + d_Cic * cos(2.0 * phi) + d_Cis * sin(2.0 * phi); // Compute the angle between the ascending node and the Greenwich meridian - Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe; + Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_DNAV_OMEGA_EARTH_DOT) * tk - BEIDOU_DNAV_OMEGA_EARTH_DOT * d_Toe; // Reduce to between 0 and 2*pi rad - Omega = fmod((Omega + 2.0 * BEIDOU_PI), (2.0 * BEIDOU_PI)); + Omega = fmod((Omega + 2.0 * BEIDOU_DNAV_PI), (2.0 * BEIDOU_DNAV_PI)); // --- Compute satellite coordinates in Earth-fixed coordinates d_satpos_X = cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega); @@ -264,7 +264,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) d_satpos_Z = sin(u) * r * sin(i); // Satellite's velocity. Can be useful for Vector Tracking loops - double Omega_dot = d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT; + double Omega_dot = d_OMEGA_DOT - BEIDOU_DNAV_OMEGA_EARTH_DOT; d_satvel_X = -Omega_dot * (cos(u) * r + sin(u) * r * cos(i)) + d_satpos_X * cos(Omega) - d_satpos_Y * cos(i) * sin(Omega); d_satvel_Y = Omega_dot * (cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega)) + d_satpos_X * sin(Omega) + d_satpos_Y * cos(i) * cos(Omega); d_satvel_Z = d_satpos_Y * sin(i); @@ -275,7 +275,7 @@ double Beidou_Dnav_Ephemeris::satellitePosition(double transmitTime) double dtr_s = d_A_f0 + d_A_f1 * tk + d_A_f2 * tk * tk; /* relativity correction */ - dtr_s -= 2.0 * sqrt(BEIDOU_GM * a) * d_eccentricity * sin(E) / (BEIDOU_C_M_S * BEIDOU_C_M_S); + dtr_s -= 2.0 * sqrt(BEIDOU_DNAV_GM * a) * d_eccentricity * sin(E) / (BEIDOU_DNAV_C_M_S * BEIDOU_DNAV_C_M_S); return dtr_s; } diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index 3f1a8bd17..c93e07c4e 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -382,7 +382,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) tk = check_t(transmitTime - d_Toe_sf2); // Computed mean motion - n0 = sqrt(BEIDOU_GM / (a * a * a)); + n0 = sqrt(BEIDOU_DNAV_GM / (a * a * a)); // Corrected mean motion n = n0 + d_Delta_n; @@ -391,7 +391,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) M = d_M_0 + n * tk; // Reduce mean anomaly to between 0 and 2pi - M = fmod((M + 2 * BEIDOU_PI), (2 * BEIDOU_PI)); + M = fmod((M + 2 * BEIDOU_DNAV_PI), (2 * BEIDOU_DNAV_PI)); // Initial guess of eccentric anomaly E = M; @@ -401,7 +401,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) { E_old = E; E = M + d_eccentricity * sin(E); - dE = fmod(E - E_old, 2 * BEIDOU_PI); + dE = fmod(E - E_old, 2 * BEIDOU_DNAV_PI); if (fabs(dE) < 1e-12) { //Necessary precision is reached, exit from the loop @@ -410,7 +410,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) } // Compute relativistic correction term - d_dtr = BEIDOU_F * d_eccentricity * d_sqrt_A * sin(E); + d_dtr = BEIDOU_DNAV_F * d_eccentricity * d_sqrt_A * sin(E); // Compute the true anomaly double tmp_Y = sqrt(1.0 - d_eccentricity * d_eccentricity) * sin(E); @@ -421,7 +421,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) phi = nu + d_OMEGA; // Reduce phi to between 0 and 2*pi rad - phi = fmod((phi), (2 * BEIDOU_PI)); + phi = fmod((phi), (2 * BEIDOU_DNAV_PI)); // Correct argument of latitude u = phi + d_Cuc * cos(2 * phi) + d_Cus * sin(2 * phi); @@ -433,10 +433,10 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) i = d_i_0 + d_IDOT * tk + d_Cic * cos(2 * phi) + d_Cis * sin(2 * phi); // Compute the angle between the ascending node and the Greenwich meridian - Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT) * tk - BEIDOU_OMEGA_EARTH_DOT * d_Toe_sf2; + Omega = d_OMEGA0 + (d_OMEGA_DOT - BEIDOU_DNAV_OMEGA_EARTH_DOT) * tk - BEIDOU_DNAV_OMEGA_EARTH_DOT * d_Toe_sf2; // Reduce to between 0 and 2*pi rad - Omega = fmod((Omega + 2 * BEIDOU_PI), (2 * BEIDOU_PI)); + Omega = fmod((Omega + 2 * BEIDOU_DNAV_PI), (2 * BEIDOU_DNAV_PI)); // --- Compute satellite coordinates in Earth-fixed coordinates d_satpos_X = cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega); @@ -444,7 +444,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) d_satpos_Z = sin(u) * r * sin(i); // Satellite's velocity. Can be useful for Vector Tracking loops - double Omega_dot = d_OMEGA_DOT - BEIDOU_OMEGA_EARTH_DOT; + double Omega_dot = d_OMEGA_DOT - BEIDOU_DNAV_OMEGA_EARTH_DOT; d_satvel_X = -Omega_dot * (cos(u) * r + sin(u) * r * cos(i)) + d_satpos_X * cos(Omega) - d_satpos_Y * cos(i) * sin(Omega); d_satvel_Y = Omega_dot * (cos(u) * r * cos(Omega) - sin(u) * r * cos(i) * sin(Omega)) + d_satpos_X * sin(Omega) + d_satpos_Y * cos(i) * cos(Omega); d_satvel_Z = d_satpos_Y * sin(i); diff --git a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m index 5ba8a85ee..8755c493e 100644 --- a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m +++ b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m @@ -27,9 +27,9 @@ % close all;clear; -samplingFreq = 25000000; %[Hz] -channels=[0:9]; -path='/home/dmiralles/Documents/gnss-sdr/'; +samplingFreq = 10000000; %[Hz] +channels=[0:17]; +path='/home/dmiralles/Documents/gnss-sdr/build/'; addpath('libs/'); clear PRN_absolute_sample_start; for N=1:1:length(channels) @@ -39,12 +39,12 @@ end %% Plotting values %--- Configurations -chn_num_a = 6; -chn_num_b = 2; +chn_num_a = 11; +chn_num_b = 3; %--- Plot results figure; plot(GNSS_telemetry(chn_num_a).tracking_sample_counter, ... - GNSS_telemetry(chn_num_a).tow_current_symbol_ms, 'b+'); + GNSS_telemetry(chn_num_a).tow_current_symbol_ms/1000, 'b+'); hold on; grid on; plot(GNSS_telemetry(chn_num_b).tracking_sample_counter, ...