2011-11-28 10:19:41 +00:00
/*!
* \ file gps_l1_ca_ls_pvt . cc
2011-12-28 21:36:45 +00:00
* \ brief Implementation of a Least Squares Position , Velocity , and Time
* ( PVT ) solver , based on K . Borre ' s Matlab receiver .
2011-11-28 10:19:41 +00:00
* \ author Javier Arribas , 2011. jarribas ( at ) cttc . es
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
* Copyright ( C ) 2010 - 2011 ( 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 .
*
* GNSS - SDR is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* at your option ) any later version .
*
* GNSS - SDR is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with GNSS - SDR . If not , see < http : //www.gnu.org/licenses/>.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
2011-10-28 15:01:46 +00:00
2011-11-28 10:19:41 +00:00
# include "armadillo"
2011-10-28 15:01:46 +00:00
# include "gps_l1_ca_ls_pvt.h"
2011-12-28 03:05:37 +00:00
# include "GPS_L1_CA.h"
2011-10-28 15:01:46 +00:00
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
gps_l1_ca_ls_pvt : : gps_l1_ca_ls_pvt ( int nchannels , std : : string dump_filename , bool flag_dump_to_file )
2011-10-28 15:01:46 +00:00
{
// init empty ephemerids for all the available GNSS channels
d_nchannels = nchannels ;
d_ephemeris = new gps_navigation_message [ nchannels ] ;
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
d_dump_filename = dump_filename ;
d_flag_dump_enabled = flag_dump_to_file ;
d_averaging_depth = 0 ;
2011-12-28 21:36:45 +00:00
// ############# ENABLE DATA FILE LOG #################
if ( d_flag_dump_enabled = = true )
{
if ( d_dump_file . is_open ( ) = = false )
{
try {
d_dump_file . exceptions ( std : : ifstream : : failbit | std : : ifstream : : badbit ) ;
d_dump_file . open ( d_dump_filename . c_str ( ) , std : : ios : : out | std : : ios : : binary ) ;
std : : cout < < " PVT lib dump enabled Log file: " < < d_dump_filename . c_str ( ) < < std : : endl ;
}
catch ( std : : ifstream : : failure e ) {
std : : cout < < " Exception opening PVT lib dump file " < < e . what ( ) < < " \r \n " ;
}
}
}
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
2011-10-28 15:01:46 +00:00
}
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
void gps_l1_ca_ls_pvt : : set_averaging_depth ( int depth )
{
2011-12-28 21:36:45 +00:00
d_averaging_depth = depth ;
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
}
2011-10-28 15:01:46 +00:00
gps_l1_ca_ls_pvt : : ~ gps_l1_ca_ls_pvt ( )
{
2011-12-28 21:36:45 +00:00
d_dump_file . close ( ) ;
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
delete [ ] d_ephemeris ;
2011-10-28 15:01:46 +00:00
}
2011-11-28 10:52:52 +00:00
arma : : vec gps_l1_ca_ls_pvt : : e_r_corr ( double traveltime , arma : : vec X_sat ) {
2011-10-28 15:01:46 +00:00
/*
2011-12-28 03:05:37 +00:00
* Returns rotated satellite ECEF coordinates due to Earth
* rotation during signal travel time
*
* Inputs :
* travelTime - signal travel time
* X_sat - satellite ' s ECEF coordinates
*
* Returns :
* X_sat_rot - rotated satellite ' s coordinates ( ECEF )
2011-10-28 15:01:46 +00:00
*/
2011-12-28 03:05:37 +00:00
//const double Omegae_dot = 7.292115147e-5; // rad/sec
2011-10-28 15:01:46 +00:00
//--- Find rotation angle --------------------------------------------------
double omegatau ;
2011-12-28 03:05:37 +00:00
omegatau = OMEGA_EARTH_DOT * traveltime ;
2011-10-28 15:01:46 +00:00
//--- Make a rotation matrix -----------------------------------------------
2011-11-28 10:52:52 +00:00
arma : : mat R3 = arma : : zeros ( 3 , 3 ) ;
2011-10-28 15:01:46 +00:00
R3 ( 0 , 0 ) = cos ( omegatau ) ;
R3 ( 0 , 1 ) = sin ( omegatau ) ;
R3 ( 0 , 2 ) = 0.0 ;
R3 ( 1 , 0 ) = - sin ( omegatau ) ;
R3 ( 1 , 1 ) = cos ( omegatau ) ;
R3 ( 1 , 2 ) = 0.0 ;
R3 ( 2 , 0 ) = 0.0 ;
R3 ( 2 , 1 ) = 0.0 ;
R3 ( 2 , 2 ) = 1 ;
//--- Do the rotation ------------------------------------------------------
2011-11-28 10:52:52 +00:00
arma : : vec X_sat_rot ;
2011-10-28 15:01:46 +00:00
X_sat_rot = R3 * X_sat ;
return X_sat_rot ;
}
2011-11-28 10:52:52 +00:00
arma : : vec gps_l1_ca_ls_pvt : : leastSquarePos ( arma : : mat satpos , arma : : vec obs , arma : : mat w ) {
2011-12-28 03:05:37 +00:00
/*Function calculates the Least Square Solution.
* Inputs :
* satpos - Satellites positions in ECEF system : [ X ; Y ; Z ; ]
* obs - Observations - the pseudorange measurements to each
* satellite
* w - weigths vector
*
* Returns :
* pos - receiver position and receiver clock error
* ( in ECEF system : [ X , Y , Z , dt ] )
*/
2011-10-28 15:01:46 +00:00
//=== Initialization =======================================================
int nmbOfIterations = 10 ; // TODO: include in config
//double dtr = GPS_PI / 180.0;
int nmbOfSatellites ;
2011-11-28 10:19:41 +00:00
nmbOfSatellites = satpos . n_cols ; //Armadillo
2011-11-28 10:52:52 +00:00
arma : : vec pos = " 0.0 0.0 0.0 0.0 " ;
arma : : mat A ;
arma : : mat omc ;
arma : : mat az ;
arma : : mat el ;
A = arma : : zeros ( nmbOfSatellites , 4 ) ;
omc = arma : : zeros ( nmbOfSatellites , 1 ) ;
az = arma : : zeros ( 1 , nmbOfSatellites ) ;
el = arma : : zeros ( 1 , nmbOfSatellites ) ;
2011-10-28 15:01:46 +00:00
for ( int i = 0 ; i < nmbOfSatellites ; i + + ) {
2011-12-28 21:36:45 +00:00
for ( int j = 0 ; j < 4 ; j + + ) {
A ( i , j ) = 0.0 ; //Armadillo
}
omc ( i , 0 ) = 0.0 ;
az ( 0 , i ) = 0.0 ;
2011-10-28 15:01:46 +00:00
}
el = az ;
2011-11-28 10:52:52 +00:00
arma : : mat X = satpos ;
arma : : vec Rot_X ;
2011-10-28 15:01:46 +00:00
double rho2 ;
double traveltime ;
double trop ;
2011-11-28 10:52:52 +00:00
arma : : mat mat_tmp ;
arma : : vec x ;
2011-10-28 15:01:46 +00:00
//=== Iteratively find receiver position ===================================
for ( int iter = 0 ; iter < nmbOfIterations ; iter + + ) {
2011-12-28 21:36:45 +00:00
for ( int i = 0 ; i < nmbOfSatellites ; i + + ) {
if ( iter = = 0 ) {
//--- Initialize variables at the first iteration --------------
Rot_X = X . col ( i ) ; //Armadillo
trop = 0.0 ;
} else {
//--- Update equations -----------------------------------------
rho2 = ( X ( 0 , i ) - pos ( 0 ) ) * ( X ( 0 , i ) - pos ( 0 ) ) + ( X ( 1 , i ) - pos ( 1 ) ) * ( X ( 1 , i ) - pos ( 1 ) ) + ( X ( 2 , i ) - pos ( 2 ) ) * ( X ( 2 , i ) - pos ( 2 ) ) ;
traveltime = sqrt ( rho2 ) / GPS_C_m_s ;
//--- Correct satellite position (do to earth rotation) --------
Rot_X = e_r_corr ( traveltime , X . col ( i ) ) ; //armadillo
//--- Find the elevation angel of the satellite ----------------
//[az(i), el(i), dist] = topocent(pos(1:3, :), Rot_X - pos(1:3, :));
}
//--- Apply the corrections ----------------------------------------
omc ( i ) = ( obs ( i ) - norm ( Rot_X - pos . subvec ( 0 , 2 ) , 2 ) - pos ( 3 ) - trop ) ; // Armadillo
//--- Construct the A matrix ---------------------------------------
//Armadillo
A ( i , 0 ) = ( - ( Rot_X ( 0 ) - pos ( 0 ) ) ) / obs ( i ) ;
A ( i , 1 ) = ( - ( Rot_X ( 1 ) - pos ( 1 ) ) ) / obs ( i ) ;
A ( i , 2 ) = ( - ( Rot_X ( 2 ) - pos ( 2 ) ) ) / obs ( i ) ;
A ( i , 3 ) = 1.0 ;
2011-10-28 15:01:46 +00:00
}
2011-12-28 21:36:45 +00:00
// These lines allow the code to exit gracefully in case of any errors
//if (rank(A) != 4) {
// pos.clear();
// return pos;
//}
2011-10-28 15:01:46 +00:00
2011-12-28 21:36:45 +00:00
//--- Find position update ---------------------------------------------
x = arma : : solve ( w * A , w * omc ) ; // Armadillo
2011-10-28 15:01:46 +00:00
2011-12-28 21:36:45 +00:00
//--- Apply position update --------------------------------------------
pos = pos + x ;
2011-10-28 15:01:46 +00:00
}
return pos ;
}
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
bool gps_l1_ca_ls_pvt : : get_PVT ( std : : map < int , gnss_pseudorange > gnss_pseudoranges_map , double GPS_current_time , bool flag_averaging )
2011-10-28 15:01:46 +00:00
{
- Major changes:
- The executable file and the default configuration file is now changed from "./install/mercurio" and "./conf/mercurio.conf" to "./install/gnss-sdr" and "./conf/gnss-sdr.conf", respectively.
- Configuration file structure changed to define in a single entry the internal sampling frequency (after the signal conditioner). NOTICE that this change affects the all the adapters (acquisition, tracking, telemetry_decoder, observables, and PVT). All the adapters are now modified to work with this feature.
- Moved several in-line GPS L1 CA parameters (a.k.a magic numbers..) to ./src/core/system_parameters/GPS_L1_CA.h definition file.
- Tracking blocks now uses DOUBLE values in their outputs.
- Observables and PVT now are separated. PVT and their associated libraries are moved to ./src/algorithms/PVT
- Temporarily disabled the RINEX output (I am working on that!)
- GNSS-SDR screen output now gives extended debug information of the receiver status and events. In the future, this output will be redirected to a log file.
- Bug fixes:
- FILE_SIGNAL_SOURCE now works correctly when the user configures GNSS-SDR to process the entire file.
- GPS_L1_CA_DLL_PLL now computes correctly the PRN start values.
- GPS_L1_CA_DLL_FLL_PLL now computes correctly the PRN start values.
- Several modifications in GPS_L1_CA_Telemetry_Decoder, GPS_L1_CA_Observables, and GPS_L1_CA_PVT modules to fix the GPS position computation.
- New features
- Tracking blocks perform a signal integrity check against NaN outliers before the correlation process.
- Tracking and PVT binary dump options are now documented and we provide MATLAB libraries and sample files to read it. Available in ./utils/matlab" and "./utils/matlab/libs"
- Observables output rate can be configured. This option enables the GPS L1 CA PVT computation at a maximum rate of 1ms.
- GPS_L1_CA_PVT now can perform a moving average Latitude, Longitude, and Altitude output for each of the Observables output. It is configurable using the configuration file.
- Added Google Earth compatible Keyhole Markup Language (KML) output writer class (./src/algorithms/PVT/libs/kml_printer.h and ./src/algorithms/PVT/libs/kml_printer.cc ). You can see the receiver position directly using Google Earth.
- We provide a master configuration file which includes an in-line documentation with all the new (and old) options. It can be found in ./conf/master.conf
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@84 64b25241-fba3-4117-9849-534c7e92360d
2011-12-07 17:59:34 +00:00
std : : map < int , gnss_pseudorange > : : iterator gnss_pseudoranges_iter ;
2011-11-28 10:19:41 +00:00
2011-11-28 10:52:52 +00:00
arma : : mat W = arma : : eye ( d_nchannels , d_nchannels ) ; //channels weights matrix
arma : : vec obs = arma : : zeros ( d_nchannels ) ; // pseudoranges observation vector
arma : : mat satpos = arma : : zeros ( 3 , d_nchannels ) ; //satellite positions matrix
2011-11-28 10:19:41 +00:00
2011-10-28 15:01:46 +00:00
int valid_obs = 0 ; //valid observations counter
for ( int i = 0 ; i < d_nchannels ; i + + )
{
2011-12-28 21:36:45 +00:00
if ( d_ephemeris [ i ] . satellite_validation ( ) = = true )
{
gnss_pseudoranges_iter = gnss_pseudoranges_map . find ( d_ephemeris [ i ] . d_satellite_PRN ) ;
if ( gnss_pseudoranges_iter ! = gnss_pseudoranges_map . end ( ) )
{
/*!
* \ todo Place here the satellite CN0 ( power level , or weight factor )
*/
W ( i , i ) = 1 ;
// compute the GPS master clock
d_ephemeris [ i ] . master_clock ( GPS_current_time ) ;
// compute the satellite current ECEF position
d_ephemeris [ i ] . satpos ( ) ;
// compute the clock error including relativistic effects
d_ephemeris [ i ] . relativistic_clock_correction ( GPS_current_time ) ;
satpos ( 0 , i ) = d_ephemeris [ i ] . d_satpos_X ;
satpos ( 1 , i ) = d_ephemeris [ i ] . d_satpos_Y ;
satpos ( 2 , i ) = d_ephemeris [ i ] . d_satpos_Z ;
std : : cout < < " ECEF satellite SV ID= " < < d_ephemeris [ i ] . d_satellite_PRN < < " X= " < < d_ephemeris [ i ] . d_satpos_X
< < " [m] Y= " < < d_ephemeris [ i ] . d_satpos_Y < < " [m] Z= " < < d_ephemeris [ i ] . d_satpos_Z < < " [m] \r \n " ;
obs ( i ) = gnss_pseudoranges_iter - > second . pseudorange_m + d_ephemeris [ i ] . d_satClkCorr * GPS_C_m_s ;
valid_obs + + ;
} else {
// no valid pseudorange for the current channel
W ( i , i ) = 0 ; // channel de-activated
obs ( i ) = 1 ; // to avoid algorithm problems (divide by zero)
}
} else {
// no valid ephemeris for the current channel
W ( i , i ) = 0 ; // channel de-activated
obs ( i ) = 1 ; // to avoid algorithm problems (divide by zero)
}
2011-10-28 15:01:46 +00:00
}
std : : cout < < " PVT: valid observations= " < < valid_obs < < std : : endl ;
if ( valid_obs > = 4 )
2011-12-28 21:36:45 +00:00
{
arma : : vec mypos ;
mypos = leastSquarePos ( satpos , obs , W ) ;
std : : cout < < " Position at TOW= " < < GPS_current_time < < " is ECEF (X,Y,Z) = " < < mypos < < std : : endl ;
cart2geo ( mypos ( 0 ) , mypos ( 1 ) , mypos ( 2 ) , 4 ) ;
std : : cout < < " Position at TOW= " < < GPS_current_time < < " is Lat = " < < d_latitude_d < < " [<5B> ] Long = " < < d_longitude_d < < " [<5B> ] Height= " < < d_height_m < < " [m] " < < std : : endl ;
// ######## LOG FILE #########
if ( d_flag_dump_enabled = = true ) {
// MULTIPLEXED FILE RECORDING - Record results to file
try {
double tmp_double ;
// PVT GPS time
tmp_double = GPS_current_time ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// ECEF User Position East [m]
tmp_double = mypos ( 0 ) ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// ECEF User Position North [m]
tmp_double = mypos ( 1 ) ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// ECEF User Position Up [m]
tmp_double = mypos ( 2 ) ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// User clock offset [s]
tmp_double = mypos ( 3 ) ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// GEO user position Latitude [deg]
tmp_double = d_latitude_d ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// GEO user position Longitude [deg]
tmp_double = d_longitude_d ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
// GEO user position Height [m]
tmp_double = d_height_m ;
d_dump_file . write ( ( char * ) & tmp_double , sizeof ( double ) ) ;
}
catch ( std : : ifstream : : failure e ) {
std : : cout < < " Exception writing PVT lib dump file " < < e . what ( ) < < " \r \n " ;
}
}
// MOVING AVERAGE PVT
if ( flag_averaging = = true )
{
if ( d_hist_longitude_d . size ( ) = = ( unsigned int ) d_averaging_depth )
{
// Pop oldest value
d_hist_longitude_d . pop_back ( ) ;
d_hist_latitude_d . pop_back ( ) ;
d_hist_height_m . pop_back ( ) ;
// Push new values
d_hist_longitude_d . push_front ( d_longitude_d ) ;
d_hist_latitude_d . push_front ( d_latitude_d ) ;
d_hist_height_m . push_front ( d_height_m ) ;
d_avg_latitude_d = 0 ;
d_avg_longitude_d = 0 ;
d_avg_height_m = 0 ;
for ( unsigned int i = 0 ; i < d_hist_longitude_d . size ( ) ; i + + )
{
d_avg_latitude_d = d_avg_latitude_d + d_hist_latitude_d . at ( i ) ;
d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d . at ( i ) ;
d_avg_height_m = d_avg_height_m + d_hist_height_m . at ( i ) ;
}
d_avg_latitude_d = d_avg_latitude_d / ( double ) d_averaging_depth ;
d_avg_longitude_d = d_avg_longitude_d / ( double ) d_averaging_depth ;
d_avg_height_m = d_avg_height_m / ( double ) d_averaging_depth ;
return true ; //indicates that the returned position is valid
} else {
//int current_depth=d_hist_longitude_d.size();
// Push new values
d_hist_longitude_d . push_front ( d_longitude_d ) ;
d_hist_latitude_d . push_front ( d_latitude_d ) ;
d_hist_height_m . push_front ( d_height_m ) ;
d_avg_latitude_d = d_latitude_d ;
d_avg_longitude_d = d_longitude_d ;
d_avg_height_m = d_height_m ;
return false ; //indicates that the returned position is not valid yet
// output the average, although it will not have the full historic available
// d_avg_latitude_d=0;
// d_avg_longitude_d=0;
// d_avg_height_m=0;
// for (unsigned int i=0;i<d_hist_longitude_d.size();i++)
// {
// d_avg_latitude_d=d_avg_latitude_d+d_hist_latitude_d.at(i);
// d_avg_longitude_d=d_avg_longitude_d+d_hist_longitude_d.at(i);
// d_avg_height_m=d_avg_height_m+d_hist_height_m.at(i);
// }
// d_avg_latitude_d=d_avg_latitude_d/(double)current_depth;
// d_avg_longitude_d=d_avg_longitude_d/(double)current_depth;
// d_avg_height_m=d_avg_height_m/(double)current_depth;
}
} else {
return true ; //indicates that the returned position is valid
}
} else {
return false ;
}
2011-10-28 15:01:46 +00:00
}
void gps_l1_ca_ls_pvt : : cart2geo ( double X , double Y , double Z , int elipsoid_selection )
{
2011-12-28 03:05:37 +00:00
// Conversion of Cartesian coordinates (X,Y,Z) to geographical
// coordinates (latitude, longitude, h) on a selected reference ellipsoid.
2011-10-28 15:01:46 +00:00
//
//
2011-12-28 03:05:37 +00:00
// Choices of Reference Ellipsoid for Geographical Coordinates
2011-10-28 15:01:46 +00:00
// 0. International Ellipsoid 1924
// 1. International Ellipsoid 1967
// 2. World Geodetic System 1972
// 3. Geodetic Reference System 1980
// 4. World Geodetic System 1984
2011-12-28 03:05:37 +00:00
const double a [ 5 ] = { 6378388 , 6378160 , 6378135 , 6378137 , 6378137 } ;
const double f [ 5 ] = { 1 / 297 , 1 / 298.247 , 1 / 298.26 , 1 / 298.257222101 , 1 / 298.257223563 } ;
2011-10-28 15:01:46 +00:00
double lambda ;
lambda = atan2 ( Y , X ) ;
double ex2 ;
ex2 = ( 2 - f [ elipsoid_selection ] ) * f [ elipsoid_selection ] / ( ( 1 - f [ elipsoid_selection ] ) * ( 1 - f [ elipsoid_selection ] ) ) ;
double c ;
c = a [ elipsoid_selection ] * sqrt ( 1 + ex2 ) ;
double phi ;
phi = atan ( Z / ( ( sqrt ( X * X + Y * Y ) * ( 1 - ( 2 - f [ elipsoid_selection ] ) ) * f [ elipsoid_selection ] ) ) ) ;
double h = 0.1 ;
double oldh = 0 ;
double N ;
int iterations = 0 ;
do {
2011-12-28 21:36:45 +00:00
oldh = h ;
N = c / sqrt ( 1 + ex2 * ( cos ( phi ) * cos ( phi ) ) ) ;
phi = atan ( Z / ( ( sqrt ( X * X + Y * Y ) * ( 1 - ( 2 - f [ elipsoid_selection ] ) * f [ elipsoid_selection ] * N / ( N + h ) ) ) ) ) ;
h = sqrt ( X * X + Y * Y ) / cos ( phi ) - N ;
iterations = iterations + 1 ;
if ( iterations > 100 )
{
std : : cout < < " Failed to approximate h with desired precision. h-oldh= " < < h - oldh < < std : : endl ;
break ;
}
2011-10-28 15:01:46 +00:00
} while ( abs ( h - oldh ) > 1.0e-12 ) ;
d_latitude_d = phi * 180.0 / GPS_PI ;
2011-11-28 10:19:41 +00:00
d_longitude_d = lambda * 180 / GPS_PI ;
2011-10-28 15:01:46 +00:00
d_height_m = h ;
}
//void gps_l1_ca_ls_pvt::topocent(traveltime, X_sat)
//{
2011-12-28 21:36:45 +00:00
/*
2011-10-28 15:01:46 +00:00
% function [ Az , El , D ] = topocent ( X , dx )
% TOPOCENT Transformation of vector dx into topocentric coordinate
% system with origin at X .
% Both parameters are 3 by 1 vectors .
%
% [ Az , El , D ] = topocent ( X , dx ) ;
%
% Inputs :
% X - vector origin corrdinates ( in ECEF system [ X ; Y ; Z ; ] )
% dx - vector ( [ dX ; dY ; dZ ; ] ) .
%
% Outputs :
% D - vector length . Units like units of the input
% Az - azimuth from north positive clockwise , degrees
% El - elevation angle , degrees
dtr = pi / 180 ;
[ phi , lambda , h ] = togeod ( 6378137 , 298.257223563 , X ( 1 ) , X ( 2 ) , X ( 3 ) ) ;
cl = cos ( lambda * dtr ) ;
sl = sin ( lambda * dtr ) ;
cb = cos ( phi * dtr ) ;
sb = sin ( phi * dtr ) ;
F = [ - sl - sb * cl cb * cl ;
cl - sb * sl cb * sl ;
0 cb sb ] ;
local_vector = F ' * dx ;
E = local_vector ( 1 ) ;
N = local_vector ( 2 ) ;
U = local_vector ( 3 ) ;
hor_dis = sqrt ( E ^ 2 + N ^ 2 ) ;
if hor_dis < 1.e-20
Az = 0 ;
El = 90 ;
else
Az = atan2 ( E , N ) / dtr ;
El = atan2 ( U , hor_dis ) / dtr ;
end
if Az < 0
Az = Az + 360 ;
end
D = sqrt ( dx ( 1 ) ^ 2 + dx ( 2 ) ^ 2 + dx ( 3 ) ^ 2 ) ;
% % % % % % % % % end topocent . m % % % % % % % % %
2011-12-28 21:36:45 +00:00
*/
2011-10-28 15:01:46 +00:00
//}