2017-12-04 16:07:54 +00:00
/*!
2018-04-28 10:33:46 +00:00
* \ file gps_l5_dll_pll_tracking . cc
2017-12-04 16:07:54 +00:00
* \ brief Interface of an adapter of a DLL + PLL tracking loop block
2018-04-28 10:33:46 +00:00
* for GPS L5 to a TrackingInterface
2017-12-04 16:07:54 +00:00
* \ author Javier Arribas , 2017. jarribas ( at ) cttc . es
*
* Code DLL + carrier PLL according to the algorithms described in :
* K . Borre , D . M . Akos , N . Bertelsen , P . Rinder , and S . H . Jensen ,
* A Software - Defined GPS and Galileo Receiver . A Single - Frequency
* Approach , Birkhauser , 2007
*
2020-07-28 14:57:15 +00:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2017-12-04 16:07:54 +00:00
*
2020-12-30 12:35:06 +00:00
* GNSS - SDR is a Global Navigation Satellite System software - defined receiver .
2017-12-04 16:07:54 +00:00
* This file is part of GNSS - SDR .
*
2020-12-30 12:35:06 +00:00
* Copyright ( C ) 2010 - 2020 ( see AUTHORS file for a list of contributors )
2020-02-08 00:20:02 +00:00
* SPDX - License - Identifier : GPL - 3.0 - or - later
2017-12-04 16:07:54 +00:00
*
2020-07-28 14:57:15 +00:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2017-12-04 16:07:54 +00:00
*/
2018-04-28 10:33:46 +00:00
# include "gps_l5_dll_pll_tracking.h"
2018-02-26 02:15:53 +00:00
# include "GPS_L5.h"
2018-12-09 21:00:09 +00:00
# include "configuration_interface.h"
2018-03-20 09:33:02 +00:00
# include "display.h"
2018-12-09 21:00:09 +00:00
# include "dll_pll_conf.h"
# include "gnss_sdr_flags.h"
2022-06-13 19:05:29 +00:00
# include <algorithm>
2019-07-14 12:09:12 +00:00
# include <array>
2017-12-04 16:07:54 +00:00
2024-04-29 06:27:33 +00:00
# if USE_GLOG_AND_GFLAGS
# include <glog/logging.h>
# else
# include <absl/log/log.h>
# endif
2018-04-28 10:33:46 +00:00
GpsL5DllPllTracking : : GpsL5DllPllTracking (
2022-12-08 16:39:16 +00:00
const ConfigurationInterface * configuration ,
const std : : string & role ,
unsigned int in_streams ,
unsigned int out_streams )
: role_ ( role ) ,
item_size_ ( sizeof ( gr_complex ) ) ,
channel_ ( 0 ) ,
in_streams_ ( in_streams ) ,
out_streams_ ( out_streams )
2017-12-04 16:07:54 +00:00
{
2020-02-19 23:07:03 +00:00
Dll_Pll_Conf trk_params = Dll_Pll_Conf ( ) ;
2022-12-08 16:39:16 +00:00
trk_params . SetFromConfiguration ( configuration , role_ ) ;
2019-03-21 18:21:39 +00:00
2020-07-17 08:48:37 +00:00
const auto vector_length = static_cast < int > ( std : : round ( static_cast < double > ( trk_params . fs_in ) / ( static_cast < double > ( GPS_L5I_CODE_RATE_CPS ) / static_cast < double > ( GPS_L5I_CODE_LENGTH_CHIPS ) ) ) ) ;
2020-02-19 23:07:03 +00:00
trk_params . vector_length = vector_length ;
if ( trk_params . extend_correlation_symbols < 1 )
2019-03-21 18:21:39 +00:00
{
2020-02-19 23:07:03 +00:00
trk_params . extend_correlation_symbols = 1 ;
2020-07-07 16:53:50 +00:00
std : : cout < < TEXT_RED < < " WARNING: GPS L5. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms) " < < TEXT_RESET < < ' \n ' ;
2018-03-20 09:33:02 +00:00
}
2020-02-19 23:07:03 +00:00
else if ( ! trk_params . track_pilot and trk_params . extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH )
2018-03-20 09:33:02 +00:00
{
2020-02-19 23:07:03 +00:00
trk_params . extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH ;
2020-07-07 16:53:50 +00:00
std : : cout < < TEXT_RED < < " WARNING: GPS L5. extend_correlation_symbols must be lower than 11 when tracking the data component. Coherent integration has been set to 10 symbols (10 ms) " < < TEXT_RESET < < ' \n ' ;
2018-03-20 09:33:02 +00:00
}
2020-02-19 23:07:03 +00:00
if ( ( trk_params . extend_correlation_symbols > 1 ) and ( trk_params . pll_bw_narrow_hz > trk_params . pll_bw_hz or trk_params . dll_bw_narrow_hz > trk_params . dll_bw_hz ) )
2018-03-20 11:30:20 +00:00
{
2020-07-07 16:53:50 +00:00
std : : cout < < TEXT_RED < < " WARNING: GPS L5. PLL or DLL narrow tracking bandwidth is higher than wide tracking one " < < TEXT_RESET < < ' \n ' ;
2018-03-20 11:30:20 +00:00
}
2020-02-19 23:07:03 +00:00
trk_params . system = ' G ' ;
2022-12-08 16:39:16 +00:00
const std : : array < char , 3 > sig { ' L ' , ' 5 ' , ' \0 ' } ;
std : : copy_n ( sig . data ( ) , 3 , trk_params . signal ) ;
2019-08-28 14:19:36 +00:00
2020-02-19 23:07:03 +00:00
// ################# Make a GNU Radio Tracking block object ################
2022-12-08 16:39:16 +00:00
DLOG ( INFO ) < < " role " < < role_ ;
2020-02-19 23:07:03 +00:00
if ( trk_params . item_type = = " gr_complex " )
2017-12-04 16:07:54 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ = dll_pll_veml_make_tracking ( trk_params ) ;
DLOG ( INFO ) < < " tracking( " < < tracking_sptr_ - > unique_id ( ) < < " ) " ;
2017-12-04 16:07:54 +00:00
}
else
{
2021-01-26 13:01:28 +00:00
item_size_ = 0 ;
2022-12-08 16:39:16 +00:00
tracking_sptr_ = nullptr ;
2020-02-19 23:07:03 +00:00
LOG ( WARNING ) < < trk_params . item_type < < " unknown tracking item type. " ;
2017-12-04 16:07:54 +00:00
}
2022-12-08 16:39:16 +00:00
2018-06-03 17:11:16 +00:00
if ( in_streams_ > 1 )
{
LOG ( ERROR ) < < " This implementation only supports one input stream " ;
}
if ( out_streams_ > 1 )
{
LOG ( ERROR ) < < " This implementation only supports one output stream " ;
}
2017-12-04 16:07:54 +00:00
}
2018-12-03 10:12:10 +00:00
void GpsL5DllPllTracking : : stop_tracking ( )
2018-03-03 01:03:39 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > stop_tracking ( ) ;
2018-03-03 01:03:39 +00:00
}
2017-12-04 16:07:54 +00:00
2018-04-28 10:33:46 +00:00
void GpsL5DllPllTracking : : start_tracking ( )
2017-12-04 16:07:54 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > start_tracking ( ) ;
2017-12-04 16:07:54 +00:00
}
2018-04-05 19:49:32 +00:00
2017-12-04 16:07:54 +00:00
/*
* Set tracking channel unique ID
*/
2018-04-28 10:33:46 +00:00
void GpsL5DllPllTracking : : set_channel ( unsigned int channel )
2017-12-04 16:07:54 +00:00
{
channel_ = channel ;
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > set_channel ( channel ) ;
2017-12-04 16:07:54 +00:00
}
2018-04-28 10:33:46 +00:00
void GpsL5DllPllTracking : : set_gnss_synchro ( Gnss_Synchro * p_gnss_synchro )
2017-12-04 16:07:54 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > set_gnss_synchro ( p_gnss_synchro ) ;
2017-12-04 16:07:54 +00:00
}
2018-04-05 19:49:32 +00:00
2018-04-28 10:33:46 +00:00
void GpsL5DllPllTracking : : connect ( gr : : top_block_sptr top_block )
2017-12-04 16:07:54 +00:00
{
2018-03-03 01:03:39 +00:00
if ( top_block )
{ /* top_block is not null */
} ;
2019-07-28 10:01:11 +00:00
// nothing to connect, now the tracking uses gr_sync_decimator
2017-12-04 16:07:54 +00:00
}
2018-04-05 19:49:32 +00:00
2018-04-28 10:33:46 +00:00
void GpsL5DllPllTracking : : disconnect ( gr : : top_block_sptr top_block )
2017-12-04 16:07:54 +00:00
{
2018-03-03 01:03:39 +00:00
if ( top_block )
{ /* top_block is not null */
} ;
2019-07-28 10:01:11 +00:00
// nothing to disconnect, now the tracking uses gr_sync_decimator
2017-12-04 16:07:54 +00:00
}
2018-04-05 19:49:32 +00:00
2018-04-28 10:33:46 +00:00
gr : : basic_block_sptr GpsL5DllPllTracking : : get_left_block ( )
2017-12-04 16:07:54 +00:00
{
2022-12-08 16:39:16 +00:00
return tracking_sptr_ ;
2017-12-04 16:07:54 +00:00
}
2018-04-05 19:49:32 +00:00
2018-04-28 10:33:46 +00:00
gr : : basic_block_sptr GpsL5DllPllTracking : : get_right_block ( )
2017-12-04 16:07:54 +00:00
{
2022-12-08 16:39:16 +00:00
return tracking_sptr_ ;
2017-12-04 16:07:54 +00:00
}