1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 03:30:33 +00:00

Advances with the rinex printer.

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@119 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-01-11 07:05:09 +00:00
parent 31faaa7722
commit dab517aff0
5 changed files with 497 additions and 501 deletions

View File

@ -48,7 +48,6 @@ 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)
{
return gps_l1_ca_pvt_cc_sptr(new gps_l1_ca_pvt_cc(nchannels, queue, dump, dump_filename, averaging_depth, flag_averaging));
}
@ -57,114 +56,121 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr que
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)))
{
// initialize internal vars
d_queue = queue;
d_dump = dump;
d_nchannels = nchannels;
d_dump_filename=dump_filename;
d_dump_filename = dump_filename;
std::string kml_dump_filename;
kml_dump_filename=d_dump_filename;
kml_dump_filename = d_dump_filename;
kml_dump_filename.append(".kml");
d_kml_dump.set_headers(kml_dump_filename);
d_dump_filename.append(".dat");
d_averaging_depth=averaging_depth;
d_flag_averaging=flag_averaging;
d_averaging_depth = averaging_depth;
d_flag_averaging = flag_averaging;
d_ls_pvt=new gps_l1_ca_ls_pvt(nchannels,d_dump_filename,d_dump);
d_ls_pvt = new gps_l1_ca_ls_pvt(nchannels,d_dump_filename,d_dump);
d_ls_pvt->set_averaging_depth(d_averaging_depth);
d_ephemeris_clock_s=0.0;
d_ephemeris_clock_s = 0.0;
d_sample_counter=0;
d_sample_counter = 0;
b_rinex_header_writen = false;
rp = new Rinex_Printer();
}
gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc() {
gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc()
{
d_kml_dump.close_file();
delete d_ls_pvt;
delete rp;
}
bool pseudoranges_pairCompare_min( std::pair<int,gnss_pseudorange> a, std::pair<int,gnss_pseudorange> b)
{
return (a.second.pseudorange_m) < (b.second.pseudorange_m);
}
int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
d_sample_counter++;
std::map<int,gnss_pseudorange> gnss_pseudoranges_map;
std::map<int,float> pseudoranges;
std::map<int,gnss_pseudorange>::iterator gnss_pseudoranges_iter;
gnss_pseudorange **in = (gnss_pseudorange **) &input_items[0]; //Get the input pointer
for (unsigned int i=0;i<d_nchannels;i++)
for (unsigned int i=0; i<d_nchannels; i++)
{
if (in[i][0].valid==true)
if (in[i][0].valid == true)
{
gnss_pseudoranges_map.insert(std::pair<int,gnss_pseudorange>(in[i][0].SV_ID,in[i][0])); //record the valid pseudorange in a map
gnss_pseudoranges_map.insert(std::pair<int,gnss_pseudorange>(in[i][0].SV_ID, in[i][0])); //record the valid pseudorange in a map
}
}
//debug print
/*std::cout << std::setprecision(16);
for(gnss_pseudoranges_iter = gnss_pseudoranges_map.begin();
gnss_pseudoranges_iter != gnss_pseudoranges_map.end();
gnss_pseudoranges_iter++)
{
std::cout << "Pseudoranges(SV ID,pseudorange [m]) =(" << gnss_pseudoranges_iter->first << ","
<< gnss_pseudoranges_iter->second.pseudorange_m << ")" <<std::endl;
} */
float pr = (float)gnss_pseudoranges_iter->second.pseudorange_m;
pseudoranges[gnss_pseudoranges_iter->first] = pr;
// std::cout << "Pseudoranges(SV ID,pseudorange [m]) =(" << gnss_pseudoranges_iter->first << ","
// << gnss_pseudoranges_iter->second.pseudorange_m << ")" <<std::endl;
}
// ############ 1. READ EPHEMERIS FROM QUEUE ######################
// find the minimum index (nearest satellite, will be the reference)
gnss_pseudoranges_iter=std::min_element(gnss_pseudoranges_map.begin(),gnss_pseudoranges_map.end(),pseudoranges_pairCompare_min);
gnss_pseudoranges_iter = std::min_element(gnss_pseudoranges_map.begin(), gnss_pseudoranges_map.end(), pseudoranges_pairCompare_min);
gps_navigation_message nav_msg;
while (d_nav_queue->try_pop(nav_msg)==true)
while (d_nav_queue->try_pop(nav_msg) == true)
{
std::cout<<"New ephemeris record has arrived from SAT ID "<<nav_msg.i_satellite_PRN<< " (Block " << nav_msg.satelliteBlock[nav_msg.i_satellite_PRN] << ")" << std::endl;
d_last_nav_msg=nav_msg;
d_ls_pvt->d_ephemeris[nav_msg.i_channel_ID]=nav_msg;
std::cout<<"New ephemeris record has arrived from SAT ID "
<< nav_msg.i_satellite_PRN << " (Block "
<< nav_msg.satelliteBlock[nav_msg.i_satellite_PRN]
<< ")" << std::endl;
d_last_nav_msg = nav_msg;
d_ls_pvt->d_ephemeris[nav_msg.i_channel_ID] = nav_msg;
// **** update pseudoranges clock ****
if (nav_msg.i_satellite_PRN==gnss_pseudoranges_iter->second.SV_ID)
if (nav_msg.i_satellite_PRN == gnss_pseudoranges_iter->second.SV_ID)
{
d_ephemeris_clock_s=d_last_nav_msg.d_TOW;
d_ephemeris_timestamp_ms=d_last_nav_msg.d_subframe1_timestamp_ms;
}
// write ephemeris to RINES NAV file, if created. Put here another condition to separate anotations
if(b_rinex_header_writen)
{
rp->LogRinexNav(rp->navFile, d_last_nav_msg);
d_ephemeris_clock_s = d_last_nav_msg.d_TOW;
d_ephemeris_timestamp_ms = d_last_nav_msg.d_subframe1_timestamp_ms;
}
}
// ############ 2. COMPUTE THE PVT ################################
// write the pseudoranges to RINEX OBS file
// 1- need a valid clock
if (d_ephemeris_clock_s>0 and d_last_nav_msg.i_satellite_PRN>0)
if (d_ephemeris_clock_s > 0 and d_last_nav_msg.i_satellite_PRN > 0)
{
//d_Rinex_Printer.LogRinex2Obs(d_last_nav_msg,d_ephemeris_clock_s+((double)pseudoranges_timestamp_ms-d_ephemeris_timestamp_ms)/1000.0,pseudoranges);
// compute on the fly PVT solution
//std::cout<<"diff_clock_ephemeris="<<(gnss_pseudoranges_iter->second.timestamp_ms-d_ephemeris_timestamp_ms)/1000.0<<"\r\n";
if (d_ls_pvt->get_PVT(gnss_pseudoranges_map,
d_ephemeris_clock_s+(gnss_pseudoranges_iter->second.timestamp_ms-d_ephemeris_timestamp_ms)/1000.0,
d_flag_averaging)==true)
d_ephemeris_clock_s + (gnss_pseudoranges_iter->second.timestamp_ms - d_ephemeris_timestamp_ms)/1000.0,
d_flag_averaging) == true)
{
d_kml_dump.print_position(d_ls_pvt,d_flag_averaging);
d_kml_dump.print_position(d_ls_pvt, d_flag_averaging);
if (!b_rinex_header_writen) // & we have utc data in nav message!
{
rp->RinexNavHeader(rp->navFile, d_last_nav_msg);
rp->RinexObsHeader(rp->obsFile, d_last_nav_msg);
b_rinex_header_writen=true; // do not write header anymore
rp->rinex_nav_header(rp->navFile, d_last_nav_msg);
rp->rinex_obs_header(rp->obsFile, d_last_nav_msg);
b_rinex_header_writen = true; // do not write header anymore
}
if(b_rinex_header_writen) // Put here another condition to separate annotations
{
rp->log_rinex_nav(rp->navFile, d_last_nav_msg);
rp->log_rinex_obs(rp->obsFile, d_last_nav_msg, pseudoranges);
}
}
}

View File

@ -44,14 +44,17 @@
#include "GPS_L1_CA.h"
class gps_l1_ca_pvt_cc;
typedef boost::shared_ptr<gps_l1_ca_pvt_cc> gps_l1_ca_pvt_cc_sptr;
gps_l1_ca_pvt_cc_sptr
gps_l1_ca_make_pvt_cc(unsigned int n_channels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging);
/*!
* \brief This class implements a block that computes the PVT solution
*/
class gps_l1_ca_pvt_cc : public gr_block {
class gps_l1_ca_pvt_cc : public gr_block
{
private:
@ -87,12 +90,15 @@ private:
public:
~gps_l1_ca_pvt_cc ();
~gps_l1_ca_pvt_cc (); //!< Default destructor
/*!
* \brief Set the queue for getting navigation messages from the GpsL1CaTelemetryDecoder
*/
void set_navigation_queue(concurrent_queue<gps_navigation_message> *nav_queue){d_nav_queue=nav_queue;}
int 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); //!< PVT Signal Processing
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -55,9 +55,10 @@
#include <fstream>
#include <iostream>
#include <sstream> // for stringstream
#include <iomanip> // for setprecision
#include <iomanip> // for setprecision
#include "gps_navigation_message.h"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "GPS_L1_CA.h"
/*!
* \brief Class that handles the generation of Receiver
@ -84,27 +85,27 @@ public:
/*!
* \brief Generates the Navigation Data header
*/
void RinexNavHeader(std::ofstream& out, gps_navigation_message nav);
void rinex_nav_header(std::ofstream& out, gps_navigation_message nav);
/*!
* \brief Generates the Observation data header
*/
void RinexObsHeader(std::ofstream& out, gps_navigation_message nav);
void rinex_obs_header(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);
boost::posix_time::ptime compute_time(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);
void log_rinex_nav(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);
void log_rinex_obs(std::ofstream& out, gps_navigation_message nav_msg, std::map<int,float> pseudoranges);
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
@ -120,6 +121,8 @@ private:
int version ; // RINEX version (2 for 2.11 and 3 for 3.01)
int numberTypesObservations; // Number of available types of observable in the system. Should be public?
/*
* Generation of RINEX signal strength indicators
@ -320,7 +323,6 @@ private:
*/
template <class X>
inline std::string asString(const X x);
};
@ -434,7 +436,6 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
if ((idx == 0) || (idx >= (startPos + length - expLen - 1)))
{
//StringException e("sci2for: no decimal point in string");
//GPSTK_THROW(e);
}
// Here, account for the possibility that there are
@ -463,6 +464,7 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
//GPSTK_THROW(e);
}
}
// Change the exponent character to D normally, or E of checkSwitch is false.
if (checkSwitch)
aStr[idx] = 'D';
@ -485,7 +487,6 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr,
else
aStr += "+";
aStr += Rinex_Printer::rightJustify(asString(iexp),expLen,'0');
}
// if the number is positive, append a space
@ -525,6 +526,7 @@ inline std::string Rinex_Printer::asString(const double x, const std::string::si
return ss.str();
}
template<class X>
inline std::string Rinex_Printer::asString(const X x)
{

View File

@ -33,8 +33,8 @@
#define GNSS_SDR_GPS_L1_CA_H_
// Physical constants
const float GPS_C_m_s = 299792458.0; //!< The speed of light, [m/s]
const float GPS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms]
const double GPS_C_m_s = 299792458.0; //!< The speed of light, [m/s]
const double GPS_C_m_ms = 299792.4580; //!< The speed of light, [m/ms]
const double GPS_PI = 3.1415926535898; //!< Pi as defined in IS-GPS-200E
const double OMEGA_EARTH_DOT = 7.2921151467e-5; //!< Earth rotation rate, [rad/s]
const double GM = 3.986005e14; //!< Universal gravitational constant times the mass of the Earth, [m^3/s^2]