2020-09-21 19:34:39 +00:00
/*!
2022-08-30 10:03:41 +00:00
* \ file gps_l1_ca_kf_tracking . h
* \ brief Interface of an adapter of a code + carrier Kalman Filter tracking
* loop with VTL capabilities block
2020-09-21 19:34:39 +00:00
* for GPS L1 C / A to a TrackingInterface
* \ author Javier Arribas , 2020. jarribas ( at ) cttc . es
*
*
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
* Copyright ( C ) 2010 - 2020 ( see AUTHORS file for a list of contributors )
*
* GNSS - SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS - SDR .
*
* SPDX - License - Identifier : GPL - 3.0 - or - later
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
2022-08-30 10:03:41 +00:00
# include "gps_l1_ca_kf_tracking.h"
2020-09-21 19:34:39 +00:00
# include "GPS_L1_CA.h"
# include "configuration_interface.h"
# include "display.h"
# include "gnss_sdr_flags.h"
# include "kf_conf.h"
2022-06-13 19:05:29 +00:00
# include <algorithm>
2020-09-21 19:34:39 +00:00
# include <array>
2024-04-29 06:27:33 +00:00
# if USE_GLOG_AND_GFLAGS
# include <glog/logging.h>
# else
# include <absl/log/log.h>
# endif
2022-08-30 10:03:41 +00:00
GpsL1CaKfTracking : : GpsL1CaKfTracking (
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 )
2020-09-21 19:34:39 +00:00
{
Kf_Conf trk_params = Kf_Conf ( ) ;
2022-12-08 16:39:16 +00:00
trk_params . SetFromConfiguration ( configuration , role_ ) ;
2020-09-21 19:34:39 +00:00
const auto vector_length = static_cast < int > ( std : : round ( trk_params . fs_in / ( GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS ) ) ) ;
trk_params . vector_length = vector_length ;
if ( trk_params . extend_correlation_symbols < 1 )
{
trk_params . extend_correlation_symbols = 1 ;
std : : cout < < TEXT_RED < < " WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms) " < < TEXT_RESET < < ' \n ' ;
}
else if ( trk_params . extend_correlation_symbols > 20 )
{
trk_params . extend_correlation_symbols = 20 ;
std : : cout < < TEXT_RED < < " WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms) " < < TEXT_RESET < < ' \n ' ;
}
2022-12-08 16:39:16 +00:00
trk_params . track_pilot = configuration - > property ( role_ + " .track_pilot " , false ) ;
2020-09-21 19:34:39 +00:00
if ( trk_params . track_pilot )
{
trk_params . track_pilot = false ;
std : : cout < < TEXT_RED < < " WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled " < < TEXT_RESET < < ' \n ' ;
}
trk_params . system = ' G ' ;
2022-12-08 16:39:16 +00:00
const std : : array < char , 3 > sig { ' 1 ' , ' C ' , ' \0 ' } ;
std : : copy_n ( sig . data ( ) , 3 , trk_params . signal ) ;
2020-09-21 19:34:39 +00:00
// ################# Make a GNU Radio Tracking block object ################
2022-12-08 16:39:16 +00:00
DLOG ( INFO ) < < " role " < < role_ ;
2020-09-21 19:34:39 +00:00
if ( trk_params . item_type = = " gr_complex " )
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ = kf_make_tracking ( trk_params ) ;
DLOG ( INFO ) < < " tracking( " < < tracking_sptr_ - > unique_id ( ) < < " ) " ;
2020-09-21 19:34:39 +00:00
}
else
{
2022-12-08 16:39:16 +00:00
item_size_ = 0 ;
tracking_sptr_ = nullptr ;
2020-09-21 19:34:39 +00:00
LOG ( WARNING ) < < trk_params . item_type < < " unknown tracking item type. " ;
}
2022-12-08 16:39:16 +00:00
2020-09-21 19:34:39 +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 " ;
}
}
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : stop_tracking ( )
2020-09-21 19:34:39 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > stop_tracking ( ) ;
2020-09-21 19:34:39 +00:00
}
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : start_tracking ( )
2020-09-21 19:34:39 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > start_tracking ( ) ;
2020-09-21 19:34:39 +00:00
}
/*
* Set tracking channel unique ID
*/
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : set_channel ( unsigned int channel )
2020-09-21 19:34:39 +00:00
{
channel_ = channel ;
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > set_channel ( channel ) ;
2020-09-21 19:34:39 +00:00
}
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : set_gnss_synchro ( Gnss_Synchro * p_gnss_synchro )
2020-09-21 19:34:39 +00:00
{
2022-12-08 16:39:16 +00:00
tracking_sptr_ - > set_gnss_synchro ( p_gnss_synchro ) ;
2020-09-21 19:34:39 +00:00
}
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : connect ( gr : : top_block_sptr top_block )
2020-09-21 19:34:39 +00:00
{
if ( top_block )
{ /* top_block is not null */
} ;
// nothing to connect, now the tracking uses gr_sync_decimator
}
2022-08-30 10:03:41 +00:00
void GpsL1CaKfTracking : : disconnect ( gr : : top_block_sptr top_block )
2020-09-21 19:34:39 +00:00
{
if ( top_block )
{ /* top_block is not null */
} ;
// nothing to disconnect, now the tracking uses gr_sync_decimator
}
2022-08-30 10:03:41 +00:00
gr : : basic_block_sptr GpsL1CaKfTracking : : get_left_block ( )
2020-09-21 19:34:39 +00:00
{
2022-12-08 16:39:16 +00:00
return tracking_sptr_ ;
2020-09-21 19:34:39 +00:00
}
2022-08-30 10:03:41 +00:00
gr : : basic_block_sptr GpsL1CaKfTracking : : get_right_block ( )
2020-09-21 19:34:39 +00:00
{
2022-12-08 16:39:16 +00:00
return tracking_sptr_ ;
2020-09-21 19:34:39 +00:00
}