1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-13 06:13:17 +00:00

Minor documentation fixes

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@118 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-01-10 09:49:09 +00:00
parent ca960b96e9
commit 31faaa7722
11 changed files with 419 additions and 369 deletions

View File

@ -46,7 +46,8 @@ using google::LogMessage;
gps_l1_ca_pvt_cc_sptr
gps_l1_ca_make_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging) {
gps_l1_ca_make_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging)
{
return gps_l1_ca_pvt_cc_sptr(new gps_l1_ca_pvt_cc(nchannels, queue, dump, dump_filename, averaging_depth, flag_averaging));
}
@ -54,7 +55,8 @@ gps_l1_ca_make_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump
gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging) :
gr_block ("gps_l1_ca_pvt_cc", gr_make_io_signature (nchannels, nchannels, sizeof(gnss_pseudorange)),
gr_make_io_signature(1, 1, sizeof(gr_complex))) {
gr_make_io_signature(1, 1, sizeof(gr_complex)))
{
// initialize internal vars
d_queue = queue;

View File

@ -60,12 +60,9 @@ private:
gps_l1_ca_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging);
// class private vars
gr_msg_queue_sptr d_queue;
bool d_dump;
bool b_rinex_header_writen;
//std::ofstream Rinex_Nav_File;
//std::ofstream Rinex_Obs_File;
Rinex_Printer *rp;
unsigned int d_nchannels;
@ -81,7 +78,7 @@ private:
kml_printer d_kml_dump;
concurrent_queue<gps_navigation_message> *d_nav_queue; // Navigation ephemeris queue
gps_navigation_message d_last_nav_msg; //last navigation message
gps_navigation_message d_last_nav_msg; // Last navigation message
double d_ephemeris_clock_s;
double d_ephemeris_timestamp_ms;

View File

@ -51,31 +51,36 @@ gps_l1_ca_ls_pvt::gps_l1_ca_ls_pvt(int nchannels,std::string dump_filename, bool
{
if (d_dump_file.is_open()==false)
{
try {
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) {
catch (std::ifstream::failure e)
{
std::cout << "Exception opening PVT lib dump file "<<e.what()<<"\r\n";
}
}
}
}
void gps_l1_ca_ls_pvt::set_averaging_depth(int depth)
{
d_averaging_depth=depth;
}
gps_l1_ca_ls_pvt::~gps_l1_ca_ls_pvt()
{
d_dump_file.close();
delete[] d_ephemeris;
}
arma::vec gps_l1_ca_ls_pvt::e_r_corr(double traveltime, arma::vec X_sat) {
arma::vec gps_l1_ca_ls_pvt::e_r_corr(double traveltime, arma::vec X_sat)
{
/*
* Returns rotated satellite ECEF coordinates due to Earth
* rotation during signal travel time
@ -109,9 +114,11 @@ arma::vec gps_l1_ca_ls_pvt::e_r_corr(double traveltime, arma::vec X_sat) {
arma::vec X_sat_rot;
X_sat_rot = R3 * X_sat;
return X_sat_rot;
}
arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma::mat w) {
arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma::mat w)
{
/*Function calculates the Least Square Solution.
* Inputs:
* satpos - Satellites positions in ECEF system: [X; Y; Z;]
@ -141,13 +148,15 @@ arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma
omc=arma::zeros(nmbOfSatellites,1);
az=arma::zeros(1,nmbOfSatellites);
el=arma::zeros(1,nmbOfSatellites);
for (int i = 0; i < nmbOfSatellites; i++) {
for (int j = 0; j < 4; j++) {
for (int i = 0; i < nmbOfSatellites; i++)
{
for (int j = 0; j < 4; j++)
{
A(i,j)=0.0; //Armadillo
}
}
omc(i, 0)=0.0;
az(0, i)=0.0;
}
}
el = az;
arma::mat X = satpos;
@ -158,13 +167,18 @@ arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma
arma::mat mat_tmp;
arma::vec x;
//=== Iteratively find receiver position ===================================
for (int iter = 0; iter < nmbOfIterations; iter++) {
for (int i = 0; i < nmbOfSatellites; i++) {
if (iter == 0) {
for (int iter = 0; iter < nmbOfIterations; iter++)
{
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 {
}
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;
@ -174,7 +188,7 @@ arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma
//--- 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
@ -184,7 +198,7 @@ arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma
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;
}
}
// These lines allow the code to exit gracefully in case of any errors
@ -198,11 +212,11 @@ arma::vec gps_l1_ca_ls_pvt::leastSquarePos(arma::mat satpos, arma::vec obs, arma
//--- Apply position update --------------------------------------------
pos = pos + x;
}
}
return pos;
}
bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_map,double GPS_current_time,bool flag_averaging)
{
std::map<int,gnss_pseudorange>::iterator gnss_pseudoranges_iter;
@ -230,7 +244,7 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_
// compute the GPS master clock
// d_ephemeris[i].master_clock(GPS_current_time); ?????
// compute the clock error including relativistic effects
// compute the clock error including relativistic effects
GPS_corrected_time = d_ephemeris[i].sv_clock_correction(GPS_current_time);
GPS_week = d_ephemeris[i].i_GPS_week;
@ -246,15 +260,19 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_
<<" [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)
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)
}
}
std::cout<<"PVT: valid observations="<<valid_obs<<std::endl;
@ -270,9 +288,11 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_
boost::posix_time::ptime p_time(boost::gregorian::date(1999,8,22),t);
std::cout << "Position at "<<boost::posix_time::to_simple_string(p_time)<<" is Lat = " << d_latitude_d << " [deg] Long = "<< d_longitude_d <<" [deg] Height= "<<d_height_m<<" [m]" <<std::endl;
// ######## LOG FILE #########
if(d_flag_dump_enabled==true) {
if(d_flag_dump_enabled==true)
{
// MULTIPLEXED FILE RECORDING - Record results to file
try {
try
{
double tmp_double;
// PVT GPS time
tmp_double=GPS_current_time;
@ -299,10 +319,11 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_
tmp_double=d_height_m;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
catch (std::ifstream::failure e) {
catch (std::ifstream::failure e)
{
std::cout << "Exception writing PVT LS dump file "<<e.what()<<"\r\n";
}
}
}
// MOVING AVERAGE PVT
if (flag_averaging==true)
@ -331,36 +352,42 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map<int,gnss_pseudorange> gnss_pseudoranges_
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
{
//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 false;
else
{
return true;//indicates that the returned position is valid
}
}
else
{
return false;
}
}
@ -394,7 +421,8 @@ void gps_l1_ca_ls_pvt::cart2geo(double X, double Y, double Z, int elipsoid_selec
double oldh = 0;
double N;
int iterations = 0;
do{
do
{
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)))));
@ -405,7 +433,8 @@ void gps_l1_ca_ls_pvt::cart2geo(double X, double Y, double Z, int elipsoid_selec
std::cout<<"Failed to approximate h with desired precision. h-oldh= "<<h-oldh<<std::endl;
break;
}
}while (abs(h-oldh) > 1.0e-12);
}
while (abs(h-oldh) > 1.0e-12);
d_latitude_d = phi*180.0/GPS_PI;
d_longitude_d = lambda*180/GPS_PI;
d_height_m = h;

View File

@ -5,7 +5,7 @@
* \author Javier Arribas, 2011. jarribas(at)cttc.es
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@ -53,7 +53,6 @@ class gps_l1_ca_ls_pvt
private:
arma::vec leastSquarePos(arma::mat satpos, arma::vec obs, arma::mat w);
arma::vec e_r_corr(double traveltime, arma::vec X_sat);
//void cart2geo();
//void topocent();
public:
int d_nchannels; //! Number of available channels for positioning
@ -94,12 +93,12 @@ public:
* \param[in] X [m] Cartesian coordinate
* \param[in] Y [m] Cartesian coordinate
* \param[in] Z [m] Cartesian coordinate
* \param[in] elipsoid_selection Choices of Reference Ellipsoid for Geographical Coordinates
* 0 - International Ellipsoid 1924
* 1 - International Ellipsoid 1967
* 2 - World Geodetic System 1972
* 3 - Geodetic Reference System 1980
* 4 - World Geodetic System 1984
* \param[in] elipsoid_selection Choices of Reference Ellipsoid for Geographical Coordinates:
* 0 - International Ellipsoid 1924.
* 1 - International Ellipsoid 1967.
* 2 - World Geodetic System 1972.
* 3 - Geodetic Reference System 1980.
* 4 - World Geodetic System 1984.
*
*/
void cart2geo(double X, double Y, double Z, int elipsoid_selection);

View File

@ -65,52 +65,52 @@ Rinex_Printer::Rinex_Printer()
satelliteSystem["Galileo"]="E";
satelliteSystem["Compass"]="C";
observationCode["GPS_L1_CA"] = "1C"; //!< "1C" GPS L1 C/A
observationCode["GPS_L1_P"] = "1P"; //!< "1P" GPS L1 P
observationCode["GPS_L1_Z_TRACKING"] = "1W"; //!< "1W" GPS L1 Z-tracking and similar (AS on)
observationCode["GPS_L1_Y"] = "1Y"; //!< "1Y" GPS L1 Y
observationCode["GPS_L1_M "]= "1M"; //!< "1M" GPS L1 M
observationCode["GPS_L1_CODELESS"] = "1N"; //!< "1N" GPS L1 codeless
observationCode["GPS_L2_CA"]= "2C"; //!< "2C" GPS L2 C/A
observationCode["L2_SEMI_CODELESS"] = "2D"; //!< "2D" GPS L2 L1(C/A)+(P2-P1) semi-codeless
observationCode["GPS_L2_L2CM"] = "2S"; //!< "2S" GPS L2 L2C (M)
observationCode["GPS_L2_L2CL"] = "2L"; //!< "2L" GPS L2 L2C (L)
observationCode["GPS_L2_L2CML"] = "2X"; //!< "2X" GPS L2 L2C (M+L)
observationCode["GPS_L2_P"] = "2P"; //!< "2P" GPS L2 P
observationCode["GPS_L2_Z_TRACKING"] = "2W"; //!< "2W" GPS L2 Z-tracking and similar (AS on)
observationCode["GPS_L2_Y"] = "2Y"; //!< "2Y" GPS L2 Y
observationCode["GPS_L2_M"] = "2M"; //!< "2M" GPS GPS L2 M
observationCode["GPS_L2_codeless"] = "2N"; //!< "2N" GPS L2 codeless
observationCode["GPS_L5_I"] = "5I"; //!< "5I" GPS L5 I
observationCode["GPS_L5_Q"] = "5Q"; //!< "5Q" GPS L5 Q
observationCode["GPS_L5_IQ"] = "5X"; //!< "5X" GPS L5 I+Q
observationCode["GLONASS_G1_CA"] = "1C"; //!< "1C" GLONASS G1 C/A
observationCode["GLONASS_G1_P"]= "1P"; //!< "1P" GLONASS G1 P
observationCode["GLONASS_G2_CA"]= "2C"; //!< "2C" GLONASS G2 C/A (Glonass M)
observationCode["GLONASS_G2_P"]= "2P"; //!< "2P" GLONASS G2 P
observationCode["GALILEO_E1_A"]= "1A"; //!< "1A" GALILEO E1 A (PRS)
observationCode["GALILEO_E1_B"]= "1B"; //!< "1B" GALILEO E1 B (I/NAV OS/CS/SoL)
observationCode["GALILEO_E1_C"]= "1C"; //!< "1C" GALILEO E1 C (no data)
observationCode["GALILEO_E1_BC"]= "1X"; //!< "1X" GALILEO E1 B+C
observationCode["GALILEO_E1_ABC"]= "1Z"; //!< "1Z" GALILEO E1 A+B+C
observationCode["GALILEO_E5a_I"]= "5I"; //!< "5I" GALILEO E5a I (F/NAV OS)
observationCode["GALILEO_E5a_Q"]= "5Q"; //!< "5Q" GALILEO E5a Q (no data)
observationCode["GALILEO_E5aIQ"]= "5X"; //!< "5X" GALILEO E5a I+Q
observationCode["GALILEO_E5b_I"]= "7I"; //!< "7I" GALILEO E5b I
observationCode["GALILEO_E5b_Q"]= "7Q"; //!< "7Q" GALILEO E5b Q
observationCode["GALILEO_E5b_IQ"]= "7X"; //!< "7X" GALILEO E5b I+Q
observationCode["GALILEO_E5_I"]= "8I"; //!< "8I" GALILEO E5 I
observationCode["GALILEO_E5_Q"]= "8Q"; //!< "8Q" GALILEO E5 Q
observationCode["GALILEO_E5_IQ"]= "8X"; //!< "8X" GALILEO E5 I+Q
observationCode["GALILEO_E56_A"]= "6A"; //!< "6A" GALILEO E6 A
observationCode["GALILEO_E56_B"] = "6B"; //!< "6B" GALILEO E6 B
observationCode["GALILEO_E56_B"] = "6C"; //!< "6C" GALILEO E6 C
observationCode["GALILEO_E56_BC"] = "6X"; //!< "6X" GALILEO E6 B+C
observationCode["GALILEO_E56_ABC"] = "6Z"; //!< "6Z" GALILEO E6 A+B+C
observationCode["SBAS_L1_CA"] = "1C"; //!< "1C" SBAS L1 C/A
observationCode["SBAS_L5_I"] = "5I"; //!< "5I" SBAS L5 I
observationCode["SBAS_L5_Q"] = "5Q"; //!< "5Q" SBAS L5 Q
observationCode["SBAS_L5_IQ"] = "5X"; //!< "5X" SBAS L5 I+Q
observationCode["GPS_L1_CA"] = "1C"; // "1C" GPS L1 C/A
observationCode["GPS_L1_P"] = "1P"; // "1P" GPS L1 P
observationCode["GPS_L1_Z_TRACKING"] = "1W"; // "1W" GPS L1 Z-tracking and similar (AS on)
observationCode["GPS_L1_Y"] = "1Y"; // "1Y" GPS L1 Y
observationCode["GPS_L1_M "]= "1M"; // "1M" GPS L1 M
observationCode["GPS_L1_CODELESS"] = "1N"; // "1N" GPS L1 codeless
observationCode["GPS_L2_CA"]= "2C"; // "2C" GPS L2 C/A
observationCode["L2_SEMI_CODELESS"] = "2D"; // "2D" GPS L2 L1(C/A)+(P2-P1) semi-codeless
observationCode["GPS_L2_L2CM"] = "2S"; // "2S" GPS L2 L2C (M)
observationCode["GPS_L2_L2CL"] = "2L"; // "2L" GPS L2 L2C (L)
observationCode["GPS_L2_L2CML"] = "2X"; // "2X" GPS L2 L2C (M+L)
observationCode["GPS_L2_P"] = "2P"; // "2P" GPS L2 P
observationCode["GPS_L2_Z_TRACKING"] = "2W"; // "2W" GPS L2 Z-tracking and similar (AS on)
observationCode["GPS_L2_Y"] = "2Y"; // "2Y" GPS L2 Y
observationCode["GPS_L2_M"] = "2M"; // "2M" GPS GPS L2 M
observationCode["GPS_L2_codeless"] = "2N"; // "2N" GPS L2 codeless
observationCode["GPS_L5_I"] = "5I"; // "5I" GPS L5 I
observationCode["GPS_L5_Q"] = "5Q"; // "5Q" GPS L5 Q
observationCode["GPS_L5_IQ"] = "5X"; // "5X" GPS L5 I+Q
observationCode["GLONASS_G1_CA"] = "1C"; // "1C" GLONASS G1 C/A
observationCode["GLONASS_G1_P"]= "1P"; // "1P" GLONASS G1 P
observationCode["GLONASS_G2_CA"]= "2C"; // "2C" GLONASS G2 C/A (Glonass M)
observationCode["GLONASS_G2_P"]= "2P"; // "2P" GLONASS G2 P
observationCode["GALILEO_E1_A"]= "1A"; // "1A" GALILEO E1 A (PRS)
observationCode["GALILEO_E1_B"]= "1B"; // "1B" GALILEO E1 B (I/NAV OS/CS/SoL)
observationCode["GALILEO_E1_C"]= "1C"; // "1C" GALILEO E1 C (no data)
observationCode["GALILEO_E1_BC"]= "1X"; // "1X" GALILEO E1 B+C
observationCode["GALILEO_E1_ABC"]= "1Z"; // "1Z" GALILEO E1 A+B+C
observationCode["GALILEO_E5a_I"]= "5I"; // "5I" GALILEO E5a I (F/NAV OS)
observationCode["GALILEO_E5a_Q"]= "5Q"; // "5Q" GALILEO E5a Q (no data)
observationCode["GALILEO_E5aIQ"]= "5X"; // "5X" GALILEO E5a I+Q
observationCode["GALILEO_E5b_I"]= "7I"; // "7I" GALILEO E5b I
observationCode["GALILEO_E5b_Q"]= "7Q"; // "7Q" GALILEO E5b Q
observationCode["GALILEO_E5b_IQ"]= "7X"; // "7X" GALILEO E5b I+Q
observationCode["GALILEO_E5_I"]= "8I"; // "8I" GALILEO E5 I
observationCode["GALILEO_E5_Q"]= "8Q"; // "8Q" GALILEO E5 Q
observationCode["GALILEO_E5_IQ"]= "8X"; // "8X" GALILEO E5 I+Q
observationCode["GALILEO_E56_A"]= "6A"; // "6A" GALILEO E6 A
observationCode["GALILEO_E56_B"] = "6B"; // "6B" GALILEO E6 B
observationCode["GALILEO_E56_B"] = "6C"; // "6C" GALILEO E6 C
observationCode["GALILEO_E56_BC"] = "6X"; // "6X" GALILEO E6 B+C
observationCode["GALILEO_E56_ABC"] = "6Z"; // "6Z" GALILEO E6 A+B+C
observationCode["SBAS_L1_CA"] = "1C"; // "1C" SBAS L1 C/A
observationCode["SBAS_L5_I"] = "5I"; // "5I" SBAS L5 I
observationCode["SBAS_L5_Q"] = "5Q"; // "5Q" SBAS L5 Q
observationCode["SBAS_L5_IQ"] = "5X"; // "5X" SBAS L5 I+Q
observationCode["COMPASS_E2_I"] = "2I";
observationCode["COMPASS_E2_Q"] = "2Q";
observationCode["COMPASS_E2_IQ"] = "2X";

View File

@ -78,8 +78,8 @@ public:
*/
~Rinex_Printer();
std::ofstream obsFile ;
std::ofstream navFile ;
std::ofstream obsFile ; //<! Output file stream for RINEX observation file
std::ofstream navFile ; //<! Output file stream for RINEX navigation data file
/*!
* \brief Generates the Navigation Data header
@ -91,14 +91,24 @@ public:
*/
void RinexObsHeader(std::ofstream& out, gps_navigation_message nav);
/*!
* \brief Computes the UTC time and returns a boost::posix_time::ptime object
*/
boost::posix_time::ptime computeTime(gps_navigation_message nav_msg);
/*!
* \brief Writes data from the navigation message into the RINEX file
*/
void LogRinexNav(std::ofstream& out, gps_navigation_message nav_msg);
/*!
* \brief Writes observables into the RINEX file
*/
void LogRinexObs(gps_navigation_message nav_msg, double interframe_seconds, std::map<int,float> pseudoranges);
std::map<std::string,std::string> satelliteSystem;
std::map<std::string,std::string> observationType;
std::map<std::string,std::string> observationCode;
std::map<std::string,std::string> satelliteSystem; //<! GPS, GLONASS, SBAS payload, Galileo or Compass
std::map<std::string,std::string> observationType; //<! PSEUDORANGE, CARRIER_PHASE, DOPPLER, SIGNAL_STRENGTH
std::map<std::string,std::string> observationCode; //<! GNSS observation descriptors
std::string stringVersion; //<! RINEX version (2.11 or 3.01)

View File

@ -85,20 +85,20 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel,
connected_ = false;
message_ = 0;
}
// Destructor
Channel::~Channel()
{
delete acq_;
delete trk_;
delete nav_;
delete pass_through_;
}
void Channel::connect(gr_top_block_sptr top_block)
{
@ -130,19 +130,17 @@ void Channel::connect(gr_top_block_sptr top_block)
connected_ = true;
}
void Channel::disconnect(gr_top_block_sptr top_block)
{
if (!connected_)
{
LOG_AT_LEVEL(WARNING) << "Channel already disconnected internally";
return;
}
top_block->disconnect(acq_->get_right_block(), 0, trk_->get_left_block(),
0);
top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(),
0);
top_block->disconnect(acq_->get_right_block(), 0, trk_->get_left_block(),0);
top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(),0);
acq_->disconnect(top_block);
trk_->disconnect(top_block);
@ -151,17 +149,23 @@ void Channel::disconnect(gr_top_block_sptr top_block)
connected_ = false;
}
gr_basic_block_sptr Channel::get_left_block()
{
return pass_through_->get_left_block();
}
gr_basic_block_sptr Channel::get_right_block()
{
return nav_->get_right_block();
}
void Channel::set_satellite(unsigned int satellite)
{
satellite_ = satellite;
@ -170,16 +174,22 @@ void Channel::set_satellite(unsigned int satellite)
nav_->set_satellite(satellite);
}
void Channel::start_acquisition()
{
channel_fsm_.Event_gps_start_acquisition();
}
void Channel::start()
{
ch_thread_ = boost::thread(&Channel::run, this);
}
void Channel::run()
{
start_acquisition();
@ -221,7 +231,6 @@ void Channel::process_channel_messages()
case 0:
LOG_AT_LEVEL(INFO) << "Stop channel " << channel_;
break;
case 1:
@ -229,7 +238,6 @@ void Channel::process_channel_messages()
LOG_AT_LEVEL(INFO) << "Channel " << channel_
<< " ACQ SUCCESS satellite " << satellite_;
channel_fsm_.Event_gps_valid_acquisition();
break;
case 2:
@ -251,11 +259,9 @@ void Channel::process_channel_messages()
<< " TRACKING FAILED satellite " << satellite_
<< ", reacquisition.";
channel_fsm_.Event_gps_failed_tracking();
break;
default:
LOG_AT_LEVEL(WARNING) << "Default case, invalid message.";
break;
}

View File

@ -4,7 +4,7 @@
* \author Javier Arribas, 2011. jarribas(at)cttc.es
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@ -27,6 +27,7 @@
* -------------------------------------------------------------------------
*/
#include "gps_l1_ca_observables_cc.h"
#include <iostream>
#include <sstream>
#include <vector>
@ -35,7 +36,6 @@
#include <bitset>
#include <cmath>
#include "math.h"
#include "gps_l1_ca_observables_cc.h"
#include "control_message_factory.h"
#include <gnuradio/gr_io_signature.h>
#include <glog/log_severity.h>
@ -43,241 +43,247 @@
using google::LogMessage;
using namespace std;
gps_l1_ca_observables_cc_sptr
gps_l1_ca_make_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) {
gps_l1_ca_make_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging)
{
return gps_l1_ca_observables_cc_sptr(new gps_l1_ca_observables_cc(nchannels, queue, dump, dump_filename, output_rate_ms, flag_averaging));
return gps_l1_ca_observables_cc_sptr(new gps_l1_ca_observables_cc(nchannels, queue, dump, dump_filename, output_rate_ms, flag_averaging));
}
gps_l1_ca_observables_cc::gps_l1_ca_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) :
gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(gnss_synchro)),
gr_make_io_signature(nchannels, nchannels, sizeof(gnss_pseudorange))) {
// initialize internal vars
d_queue = queue;
d_dump = dump;
d_nchannels = nchannels;
d_output_rate_ms=output_rate_ms;
d_history_prn_delay_ms= new std::deque<double>[d_nchannels];
d_dump_filename=dump_filename;
d_flag_averaging=flag_averaging;
// ############# ENABLE DATA FILE LOG #################
if (d_dump==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<<"Observables dump enabled Log file: "<<d_dump_filename.c_str()<<std::endl;
}
catch (std::ifstream::failure e) {
std::cout << "Exception opening observables dump file "<<e.what()<<"\r\n";
}
}
}
}
gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc() {
d_dump_file.close();
delete[] d_history_prn_delay_ms;
}
bool pairCompare_gnss_synchro( pair<int,gnss_synchro> a, pair<int,gnss_synchro> b)
gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(gnss_synchro)),
gr_make_io_signature(nchannels, nchannels, sizeof(gnss_pseudorange)))
{
return (a.second.preamble_delay_ms) < (b.second.preamble_delay_ms);
// initialize internal vars
d_queue = queue;
d_dump = dump;
d_nchannels = nchannels;
d_output_rate_ms=output_rate_ms;
d_history_prn_delay_ms= new std::deque<double>[d_nchannels];
d_dump_filename=dump_filename;
d_flag_averaging=flag_averaging;
// ############# ENABLE DATA FILE LOG #################
if (d_dump==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<<"Observables dump enabled Log file: "<<d_dump_filename.c_str()<<std::endl;
}
catch (std::ifstream::failure e) {
std::cout << "Exception opening observables dump file "<<e.what()<<"\r\n";
}
}
}
}
bool pairCompare_double( pair<int,double> a, pair<int,double> b)
gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc()
{
return (a.second) < (b.second);
d_dump_file.close();
delete[] d_history_prn_delay_ms;
}
bool pairCompare_gnss_synchro( std::pair<int,gnss_synchro> a, std::pair<int,gnss_synchro> b)
{
return (a.second.preamble_delay_ms) < (b.second.preamble_delay_ms);
}
bool pairCompare_double( std::pair<int,double> a, std::pair<int,double> b)
{
return (a.second) < (b.second);
}
void clearQueue( std::deque<double> &q )
{
std::deque<double> empty;
std::swap( q, empty );
std::deque<double> empty;
std::swap( q, empty );
}
int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
gnss_synchro **in = (gnss_synchro **) &input_items[0]; //Get the input pointer
gnss_pseudorange **out = (gnss_pseudorange **) &output_items[0]; //Get the output pointer
gnss_synchro **in = (gnss_synchro **) &input_items[0]; //Get the input pointer
gnss_pseudorange **out = (gnss_pseudorange **) &output_items[0]; //Get the output pointer
gnss_pseudorange current_gnss_pseudorange;
gnss_pseudorange current_gnss_pseudorange;
map<int,gnss_synchro> gps_words;
map<int,gnss_synchro>::iterator gps_words_iter;
std::map<int,gnss_synchro> gps_words;
std::map<int,gnss_synchro>::iterator gps_words_iter;
map<int,double>::iterator current_prn_timestamps_ms_iter;
map<int,double> current_prn_timestamps_ms;
std::map<int,double>::iterator current_prn_timestamps_ms_iter;
std::map<int,double> current_prn_timestamps_ms;
double min_preamble_delay_ms;
double max_preamble_delay_ms;
double min_preamble_delay_ms;
double max_preamble_delay_ms;
double pseudoranges_timestamp_ms;
double traveltime_ms;
double pseudorange_m;
int history_shift=0;
double delta_timestamp_ms;
double min_delta_timestamp_ms;
double actual_min_prn_delay_ms;
double current_prn_delay_ms;
double pseudoranges_timestamp_ms;
double traveltime_ms;
double pseudorange_m;
int history_shift=0;
double delta_timestamp_ms;
double min_delta_timestamp_ms;
double actual_min_prn_delay_ms;
double current_prn_delay_ms;
int pseudoranges_reference_sat_ID=0;
unsigned int pseudoranges_reference_sat_channel_ID=0;
int pseudoranges_reference_sat_ID=0;
unsigned int pseudoranges_reference_sat_channel_ID=0;
d_sample_counter++; //count for the processed samples
d_sample_counter++; //count for the processed samples
bool flag_history_ok=true; //flag to indicate that all the queues have filled their timestamp history
/*!
* 1. Read the GNSS SYNCHRO objects from available channels to obtain the preamble timestamp, current PRN start time and accumulated carrier phase
*/
for (unsigned int i=0; i<d_nchannels ; i++)
{
if (in[i][0].valid_word) //if this channel have valid word
{
gps_words.insert(pair<int,gnss_synchro>(in[i][0].channel_ID,in[i][0])); //record the word structure in a map for pseudoranges
// RECORD PRN start timestamps history
if (d_history_prn_delay_ms[i].size()<MAX_TOA_DELAY_MS)
{
d_history_prn_delay_ms[i].push_front(in[i][0].prn_delay_ms);
flag_history_ok=false; // at least one channel need more samples
}else{
//clearQueue(d_history_prn_delay_ms[i]); //clear the queue as the preamble arrives
d_history_prn_delay_ms[i].pop_back();
d_history_prn_delay_ms[i].push_front(in[i][0].prn_delay_ms);
}
}
bool flag_history_ok=true; //flag to indicate that all the queues have filled their timestamp history
/*
* 1. Read the GNSS SYNCHRO objects from available channels to obtain the preamble timestamp, current PRN start time and accumulated carrier phase
*/
for (unsigned int i=0; i<d_nchannels ; i++)
{
if (in[i][0].valid_word) //if this channel have valid word
{
gps_words.insert(std::pair<int,gnss_synchro>(in[i][0].channel_ID,in[i][0])); //record the word structure in a map for pseudoranges
// RECORD PRN start timestamps history
if (d_history_prn_delay_ms[i].size()<MAX_TOA_DELAY_MS)
{
d_history_prn_delay_ms[i].push_front(in[i][0].prn_delay_ms);
flag_history_ok=false; // at least one channel need more samples
}
else
{
//clearQueue(d_history_prn_delay_ms[i]); //clear the queue as the preamble arrives
d_history_prn_delay_ms[i].pop_back();
d_history_prn_delay_ms[i].push_front(in[i][0].prn_delay_ms);
}
}
}
/*
* 1.2 Assume no satellites in tracking
*/
for (unsigned int i=0; i<d_nchannels ; i++)
{
current_gnss_pseudorange.valid=false;
current_gnss_pseudorange.SV_ID=0;
current_gnss_pseudorange.pseudorange_m=0;
current_gnss_pseudorange.timestamp_ms=0;
*out[i]=current_gnss_pseudorange;
}
/*
* 2. Compute RAW pseudorranges: Use only the valid channels (channels that are tracking a satellite)
*/
if(gps_words.size()>0 and flag_history_ok==true)
{
/*
* 2.1 find the minimum preamble timestamp (nearest satellite, will be the reference)
*/
// The nearest satellite, first preamble to arrive
gps_words_iter=min_element(gps_words.begin(),gps_words.end(),pairCompare_gnss_synchro);
min_preamble_delay_ms=gps_words_iter->second.preamble_delay_ms; //[ms]
pseudoranges_reference_sat_ID=gps_words_iter->second.satellite_PRN; // it is the reference!
pseudoranges_reference_sat_channel_ID=gps_words_iter->second.channel_ID;
// The farthest satellite, last preamble to arrive
gps_words_iter=max_element(gps_words.begin(),gps_words.end(),pairCompare_gnss_synchro);
max_preamble_delay_ms=gps_words_iter->second.preamble_delay_ms;
min_delta_timestamp_ms=gps_words_iter->second.prn_delay_ms-max_preamble_delay_ms; //[ms]
// check if this is a valid set of observations
if ((max_preamble_delay_ms-min_preamble_delay_ms)<MAX_TOA_DELAY_MS)
{
// Now we have to determine were we are in time, compared with the last preamble! -> we select the corresponding history
/*!
* \todo Explain this better!
*/
//bool flag_preamble_navigation_now=true;
// find again the minimum CURRENT minimum preamble time, taking into account the preamble timeshift
for(gps_words_iter = gps_words.begin(); gps_words_iter != gps_words.end(); gps_words_iter++)
{
delta_timestamp_ms=(gps_words_iter->second.prn_delay_ms-gps_words_iter->second.preamble_delay_ms)-min_delta_timestamp_ms;
history_shift=round(delta_timestamp_ms);
//std::cout<<"history_shift="<<history_shift<<"\r\n";
current_prn_timestamps_ms.insert(std::pair<int,double>(gps_words_iter->second.channel_ID,d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]));
// debug: preamble position test
//if ((d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]-gps_words_iter->second.preamble_delay_ms)<0.1)
//{std::cout<<"ch "<<gps_words_iter->second.channel_ID<<" current_prn_time-last_preamble_prn_time="<<
// d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]-gps_words_iter->second.preamble_delay_ms<<"\r\n";
//}else{
// flag_preamble_navigation_now=false;
//}
}
//if (flag_preamble_navigation_now==true)
//{
//std::cout<<"PREAMBLE NAVIGATION NOW!\r\n";
//d_sample_counter=0;
//}
current_prn_timestamps_ms_iter=min_element(current_prn_timestamps_ms.begin(),current_prn_timestamps_ms.end(),pairCompare_double);
actual_min_prn_delay_ms=current_prn_timestamps_ms_iter->second;
pseudoranges_timestamp_ms=actual_min_prn_delay_ms; //save the shortest pseudorange timestamp to compute the current GNSS timestamp
/*
* 2.2 compute the pseudoranges
*/
for(gps_words_iter = gps_words.begin(); gps_words_iter != gps_words.end(); gps_words_iter++)
{
// #### compute the pseudorange for this satellite ###
current_prn_delay_ms=current_prn_timestamps_ms.at(gps_words_iter->second.channel_ID);
traveltime_ms=current_prn_delay_ms-actual_min_prn_delay_ms+GPS_STARTOFFSET_ms; //[ms]
//std::cout<<"delta_time_ms="<<current_prn_delay_ms-actual_min_prn_delay_ms<<"\r\n";
pseudorange_m=traveltime_ms*GPS_C_m_ms; // [m]
// update the pseudorange object
current_gnss_pseudorange.pseudorange_m=pseudorange_m;
current_gnss_pseudorange.timestamp_ms=pseudoranges_timestamp_ms;
current_gnss_pseudorange.SV_ID=gps_words_iter->second.satellite_PRN;
current_gnss_pseudorange.valid=true;
// #### write the pseudorrange block output for this satellite ###
*out[gps_words_iter->second.channel_ID]=current_gnss_pseudorange;
}
}
}
if(d_dump==true) {
// MULTIPLEXED FILE RECORDING - Record results to file
try {
double tmp_double;
for (unsigned int i=0; i<d_nchannels ; i++)
{
tmp_double=in[i][0].preamble_delay_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=in[i][0].prn_delay_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].pseudorange_m;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].SV_ID;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
}
catch (std::ifstream::failure e) {
std::cout << "Exception writing observables dump file "<<e.what()<<"\r\n";
}
}
consume_each(1); //one by one
/*!
* 1.2 Assume no satellites in tracking
*/
for (unsigned int i=0; i<d_nchannels ; i++)
{
current_gnss_pseudorange.valid=false;
current_gnss_pseudorange.SV_ID=0;
current_gnss_pseudorange.pseudorange_m=0;
current_gnss_pseudorange.timestamp_ms=0;
*out[i]=current_gnss_pseudorange;
}
/*!
* 2. Compute RAW pseudorranges: Use only the valid channels (channels that are tracking a satellite)
*/
if(gps_words.size()>0 and flag_history_ok==true)
{
/*!
* 2.1 find the minimum preamble timestamp (nearest satellite, will be the reference)
*/
// The nearest satellite, first preamble to arrive
gps_words_iter=min_element(gps_words.begin(),gps_words.end(),pairCompare_gnss_synchro);
min_preamble_delay_ms=gps_words_iter->second.preamble_delay_ms; //[ms]
pseudoranges_reference_sat_ID=gps_words_iter->second.satellite_PRN; // it is the reference!
pseudoranges_reference_sat_channel_ID=gps_words_iter->second.channel_ID;
// The farthest satellite, last preamble to arrive
gps_words_iter=max_element(gps_words.begin(),gps_words.end(),pairCompare_gnss_synchro);
max_preamble_delay_ms=gps_words_iter->second.preamble_delay_ms;
min_delta_timestamp_ms=gps_words_iter->second.prn_delay_ms-max_preamble_delay_ms; //[ms]
// check if this is a valid set of observations
if ((max_preamble_delay_ms-min_preamble_delay_ms)<MAX_TOA_DELAY_MS)
{
// Now we have to determine were we are in time, compared with the last preamble! -> we select the corresponding history
/*!
* \todo Explain this better!
*/
//bool flag_preamble_navigation_now=true;
// find again the minimum CURRENT minimum preamble time, taking into account the preamble timeshift
for(gps_words_iter = gps_words.begin(); gps_words_iter != gps_words.end(); gps_words_iter++)
{
delta_timestamp_ms=(gps_words_iter->second.prn_delay_ms-gps_words_iter->second.preamble_delay_ms)-min_delta_timestamp_ms;
history_shift=round(delta_timestamp_ms);
//std::cout<<"history_shift="<<history_shift<<"\r\n";
current_prn_timestamps_ms.insert(pair<int,double>(gps_words_iter->second.channel_ID,d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]));
// debug: preamble position test
//if ((d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]-gps_words_iter->second.preamble_delay_ms)<0.1)
//{std::cout<<"ch "<<gps_words_iter->second.channel_ID<<" current_prn_time-last_preamble_prn_time="<<
// d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]-gps_words_iter->second.preamble_delay_ms<<"\r\n";
//}else{
// flag_preamble_navigation_now=false;
//}
}
//if (flag_preamble_navigation_now==true)
//{
//std::cout<<"PREAMBLE NAVIGATION NOW!\r\n";
//d_sample_counter=0;
//}
current_prn_timestamps_ms_iter=min_element(current_prn_timestamps_ms.begin(),current_prn_timestamps_ms.end(),pairCompare_double);
actual_min_prn_delay_ms=current_prn_timestamps_ms_iter->second;
pseudoranges_timestamp_ms=actual_min_prn_delay_ms; //save the shortest pseudorange timestamp to compute the current GNSS timestamp
/*!
* 2.2 compute the pseudoranges
*/
for(gps_words_iter = gps_words.begin(); gps_words_iter != gps_words.end(); gps_words_iter++)
{
// #### compute the pseudorange for this satellite ###
current_prn_delay_ms=current_prn_timestamps_ms.at(gps_words_iter->second.channel_ID);
traveltime_ms=current_prn_delay_ms-actual_min_prn_delay_ms+GPS_STARTOFFSET_ms; //[ms]
//std::cout<<"delta_time_ms="<<current_prn_delay_ms-actual_min_prn_delay_ms<<"\r\n";
pseudorange_m=traveltime_ms*GPS_C_m_ms; // [m]
// update the pseudorange object
current_gnss_pseudorange.pseudorange_m=pseudorange_m;
current_gnss_pseudorange.timestamp_ms=pseudoranges_timestamp_ms;
current_gnss_pseudorange.SV_ID=gps_words_iter->second.satellite_PRN;
current_gnss_pseudorange.valid=true;
// #### write the pseudorrange block output for this satellite ###
*out[gps_words_iter->second.channel_ID]=current_gnss_pseudorange;
}
}
}
if(d_dump==true) {
// MULTIPLEXED FILE RECORDING - Record results to file
try {
double tmp_double;
for (unsigned int i=0; i<d_nchannels ; i++)
{
tmp_double=in[i][0].preamble_delay_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=in[i][0].prn_delay_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].pseudorange_m;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double=out[i][0].SV_ID;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
}
catch (std::ifstream::failure e) {
std::cout << "Exception writing observables dump file "<<e.what()<<"\r\n";
}
}
consume_each(1); //one by one
if ((d_sample_counter%d_output_rate_ms)==0)
{
return 1; //Output the observables
}else{
return 0;//hold on
}
if ((d_sample_counter%d_output_rate_ms)==0)
{
return 1; //Output the observables
}
else
{
return 0;//hold on
}
}

View File

@ -37,9 +37,10 @@ struct Ev_gps_word_valid : sc::event<Ev_gps_word_valid> {};
struct Ev_gps_word_invalid : sc::event<Ev_gps_word_invalid>{};
struct Ev_gps_word_preamble : sc::event<Ev_gps_word_preamble>{};
struct gps_subframe_fsm_S0: public sc::state<gps_subframe_fsm_S0, GpsL1CaSubframeFsm > {
public:
// sc::transition(evento,estado_destino)
// sc::transition(event,next_status)
typedef sc::transition< Ev_gps_word_preamble, gps_subframe_fsm_S1 > reactions;
gps_subframe_fsm_S0(my_context ctx): my_base( ctx ){
//std::cout<<"Enter S0 "<<std::endl;
@ -222,27 +223,28 @@ void GpsL1CaSubframeFsm::gps_word_to_subframe(int position)
void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg()
{
int subframe_ID;
// NEW GPS SUBFRAME HAS ARRIVED!
subframe_ID=d_nav.subframe_decoder(this->d_subframe); //decode the subframe
std::cout<<"NAVIGATION FSM: received subframe "<<subframe_ID<<" for satellite "<<d_nav.i_satellite_PRN<<std::endl;
d_nav.i_satellite_PRN=i_satellite_PRN;
d_nav.i_channel_ID=i_channel_ID;
if (subframe_ID==1) {
d_nav.d_subframe1_timestamp_ms=this->d_preamble_time_ms;
//std::cout<<"NAVIGATION FSM: set subframe 1 preamble timestamp for satellite "<<d_nav.i_satellite_PRN<<std::endl;
}
/*!
* \todo change satellite validation to subframe 5 because it will have a complete set of ephemeris parameters
*/
if (subframe_ID==3) { // if the subframe is the 5th, then
if (d_nav.satellite_validation()) // if all the satellite ephemeris parameters are good, then
{
// Send the procesed satellite ephemeris packet
d_nav_queue->push(d_nav);
}
}
int subframe_ID;
// NEW GPS SUBFRAME HAS ARRIVED!
subframe_ID=d_nav.subframe_decoder(this->d_subframe); //decode the subframe
std::cout<<"NAVIGATION FSM: received subframe "<<subframe_ID<<" for satellite "<<d_nav.i_satellite_PRN<<std::endl;
d_nav.i_satellite_PRN=i_satellite_PRN;
d_nav.i_channel_ID=i_channel_ID;
if (subframe_ID==1)
{
d_nav.d_subframe1_timestamp_ms=this->d_preamble_time_ms;
//std::cout<<"NAVIGATION FSM: set subframe 1 preamble timestamp for satellite "<<d_nav.i_satellite_PRN<<std::endl;
}
/*!
* \todo change satellite validation to subframe 5 because it will have a complete set of ephemeris parameters
*/
if (subframe_ID==3)
{ // if the subframe is the 5th, then
if (d_nav.satellite_validation()) // if all the satellite ephemeris parameters are good, then
{
// Send the procesed satellite ephemeris packet
d_nav_queue->push(d_nav);
}
}
}

View File

@ -63,7 +63,8 @@ struct gps_subframe_fsm_S9;
struct gps_subframe_fsm_S10;
struct gps_subframe_fsm_S11;
class GpsL1CaSubframeFsm : public sc::state_machine< GpsL1CaSubframeFsm, gps_subframe_fsm_S0 >{
class GpsL1CaSubframeFsm : public sc::state_machine< GpsL1CaSubframeFsm, gps_subframe_fsm_S0 >
{
private:
public:
@ -91,7 +92,6 @@ public:
void Event_gps_word_preamble();
GpsL1CaSubframeFsm();
};
#endif

View File

@ -42,7 +42,6 @@
#include <math.h>
#include "GPS_L1_CA.h"
//using namespace boost::assign;