mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-10-27 05:27:40 +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:
@@ -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,8 +56,6 @@ 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;
|
||||
@@ -82,23 +79,31 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels, gr_msg_queue_sptr que
|
||||
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
|
||||
@@ -111,16 +116,15 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
|
||||
}
|
||||
}
|
||||
|
||||
//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)
|
||||
@@ -129,20 +133,19 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
|
||||
gps_navigation_message nav_msg;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// ############ 2. COMPUTE THE PVT ################################
|
||||
@@ -150,7 +153,6 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
|
||||
// 1- need a valid clock
|
||||
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,
|
||||
@@ -160,11 +162,15 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "rinex_printer.h"
|
||||
#include "gps_navigation_message.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <stdlib.h> // for getenv()
|
||||
@@ -49,8 +50,7 @@
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
DEFINE_string(RINEX_version, "3.01",
|
||||
"Specifies the RINEX version (2.11 or 3.01)");
|
||||
DEFINE_string(RINEX_version, "3.01", "Specifies the RINEX version (2.11 or 3.01)");
|
||||
|
||||
|
||||
Rinex_Printer::Rinex_Printer()
|
||||
@@ -146,7 +146,7 @@ Rinex_Printer::Rinex_Printer()
|
||||
LOG_AT_LEVEL(ERROR) << "Unknown RINEX version " << FLAGS_RINEX_version << " (must be 2.11 or 3.01)" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
numberTypesObservations=2; // Number of available types of observable in the system
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,9 @@ void Rinex_Printer::lengthCheck(std::string line)
|
||||
}
|
||||
|
||||
|
||||
std::string Rinex_Printer::createFilename(std::string type){
|
||||
|
||||
std::string Rinex_Printer::createFilename(std::string type)
|
||||
{
|
||||
const std::string stationName = "GSDR"; // 4-character station name designator
|
||||
boost::gregorian::date today = boost::gregorian::day_clock::local_day();
|
||||
const int dayOfTheYear = today.day_of_year();
|
||||
@@ -220,7 +222,7 @@ std::string Rinex_Printer::createFilename(std::string type){
|
||||
Hmap.insert(std::pair<std::string, std::string>("15", "p"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("16", "q"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("17", "r"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("8","s"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("18", "s"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("19", "t"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("20", "u"));
|
||||
Hmap.insert(std::pair<std::string, std::string>("21", "v"));
|
||||
@@ -316,12 +318,11 @@ std::string Rinex_Printer::getLocalTime()
|
||||
line += std::string("UTC");
|
||||
line += std::string(1, ' ');
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
void Rinex_Printer::rinex_nav_header(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
{
|
||||
|
||||
std::string line;
|
||||
@@ -336,6 +337,7 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
line += std::string("N: GPS NAV DATA");
|
||||
line += std::string(25, ' ');
|
||||
}
|
||||
|
||||
if (version == 3 )
|
||||
{
|
||||
line += std::string("N: GNSS NAV DATA");
|
||||
@@ -358,6 +360,7 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
line += std::string(1, ' ');
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line 3
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("GPS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60);
|
||||
@@ -365,11 +368,13 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line COMMENT
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("See http://gnss-sdr.org", 60);
|
||||
line += Rinex_Printer::leftJustify("COMMENT",20);
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line ionospheric info 1
|
||||
line.clear();
|
||||
if (version == 2)
|
||||
@@ -396,7 +401,7 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line ionospheric info 1
|
||||
// -------- Line ionospheric info 2
|
||||
line.clear();
|
||||
if (version == 2)
|
||||
{
|
||||
@@ -462,7 +467,6 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line 6 leap seconds
|
||||
|
||||
// For leap second information, see http://www.endruntechnologies.com/leap.htm
|
||||
line.clear();
|
||||
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(nav_msg.d_DeltaT_LS), 6);
|
||||
@@ -494,17 +498,12 @@ void Rinex_Printer::RinexNavHeader(std::ofstream& out, gps_navigation_message na
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
void Rinex_Printer::log_rinex_nav(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
{
|
||||
|
||||
// this has to be done for all satellites!
|
||||
std::string line;
|
||||
|
||||
boost::posix_time::ptime p_utc_time = Rinex_Printer::computeTime(nav_msg);
|
||||
boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_time(nav_msg);
|
||||
std::string timestring=boost::posix_time::to_iso_string(p_utc_time);
|
||||
std::string month (timestring, 4, 2);
|
||||
std::string day (timestring, 6, 2);
|
||||
@@ -606,7 +605,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -632,7 +630,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -660,7 +657,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -686,7 +682,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -711,7 +706,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
out << line << std::endl;
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -736,7 +730,6 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
|
||||
line.clear();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += std::string(4, ' ');
|
||||
@@ -759,12 +752,13 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
if ( ( (nav_msg.d_IODC > 751) && (nav_msg.d_IODC < 757) ) || (nav_msg.d_IODC == 511) ) curve_fit_interval = 74;
|
||||
if ( (nav_msg.d_IODC == 757)) curve_fit_interval = 98;
|
||||
}
|
||||
// Block IIR/IIR-M/IIF/IIIA (Table 20-XII IS-GPS-200E )
|
||||
|
||||
if ((nav_msg.satelliteBlock[nav_msg.i_satellite_PRN].compare("IIR") == 0) ||
|
||||
(nav_msg.satelliteBlock[nav_msg.i_satellite_PRN].compare("IIR-M") == 0) ||
|
||||
(nav_msg.satelliteBlock[nav_msg.i_satellite_PRN].compare("IIF") == 0) ||
|
||||
(nav_msg.satelliteBlock[nav_msg.i_satellite_PRN].compare("IIIA") == 0) )
|
||||
{
|
||||
// Block IIR/IIR-M/IIF/IIIA (Table 20-XII IS-GPS-200E )
|
||||
if ( (nav_msg.d_IODC > 239) && (nav_msg.d_IODC < 248)) curve_fit_interval = 8;
|
||||
if ( ( (nav_msg.d_IODC > 247) && (nav_msg.d_IODC < 256)) || (nav_msg.d_IODC == 496) ) curve_fit_interval = 14;
|
||||
if ( ( (nav_msg.d_IODC > 496) && (nav_msg.d_IODC < 504)) || ( (nav_msg.d_IODC > 1020) && (nav_msg.d_IODC < 1024) ) ) curve_fit_interval = 26;
|
||||
@@ -783,7 +777,8 @@ void Rinex_Printer::LogRinexNav(std::ofstream& out, gps_navigation_message nav_m
|
||||
|
||||
}
|
||||
|
||||
void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
|
||||
void Rinex_Printer::rinex_obs_header(std::ofstream& out, gps_navigation_message nav_msg)
|
||||
{
|
||||
|
||||
std::string line;
|
||||
@@ -801,7 +796,14 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
|
||||
// -------- Line 2
|
||||
line.clear();
|
||||
if (version == 2)
|
||||
{
|
||||
line += Rinex_Printer::leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60);
|
||||
}
|
||||
if (version == 3)
|
||||
{
|
||||
line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60);
|
||||
}
|
||||
line += Rinex_Printer::leftJustify("COMMENT", 20);
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
@@ -814,13 +816,14 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line 4
|
||||
// -------- Line COMMENT
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60);
|
||||
line += Rinex_Printer::leftJustify("COMMENT", 20);
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line COMMENT
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("See http://gnss-sdr.org", 60);
|
||||
line += Rinex_Printer::leftJustify("COMMENT", 20);
|
||||
@@ -834,6 +837,7 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
// -------- Line MARKER TYPE
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property
|
||||
line += std::string(40, ' ');
|
||||
@@ -841,7 +845,6 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
|
||||
// -------- Line OBSERVER / AGENCY
|
||||
line.clear();
|
||||
std::string username=getenv("USER");
|
||||
@@ -851,8 +854,6 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
|
||||
|
||||
// -------- Line REC / TYPE VERS
|
||||
line.clear();
|
||||
line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property
|
||||
@@ -881,7 +882,7 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
double antena_e = 0.0;
|
||||
double antena_n = 0.0;
|
||||
line.clear();
|
||||
line = Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14);
|
||||
line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14);
|
||||
line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14);
|
||||
line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14);
|
||||
line += std::string(18, ' ');
|
||||
@@ -896,9 +897,9 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
line.clear();
|
||||
line += satelliteSystem["GPS"];
|
||||
line += std::string(2, ' ');
|
||||
int numberObservations=2; // Count the number of available types of observable in the system
|
||||
//int numberTypesObservations=2; // Count the number of available types of observable in the system
|
||||
std::stringstream strm;
|
||||
strm << numberObservations;
|
||||
strm << numberTypesObservations;
|
||||
line += Rinex_Printer::rightJustify(strm.str(), 3);
|
||||
// per type of observation
|
||||
line += std::string(1, ' ');
|
||||
@@ -923,7 +924,7 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
|
||||
// -------- TIME OF FIRST OBS
|
||||
line.clear();
|
||||
boost::posix_time::ptime p_utc_time = Rinex_Printer::computeTime(nav_msg);
|
||||
boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_time(nav_msg);
|
||||
std::string timestring=boost::posix_time::to_iso_string(p_utc_time);
|
||||
std::string year (timestring, 0, 4);
|
||||
std::string month (timestring, 4, 2);
|
||||
@@ -932,13 +933,13 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
std::string minutes (timestring, 11, 2);
|
||||
double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(nav_msg.d_TOW));
|
||||
double seconds = fmod(utc_t,60);
|
||||
line += rightJustify(year, 6);
|
||||
line += rightJustify(month, 6);
|
||||
line += rightJustify(day, 6);
|
||||
line += rightJustify(hour, 6);
|
||||
line += rightJustify(minutes, 6);
|
||||
line += rightJustify(asString(seconds,7), 13);
|
||||
line += rightJustify(std::string("GPS"), 8);
|
||||
line += Rinex_Printer::rightJustify(year, 6);
|
||||
line += Rinex_Printer::rightJustify(month, 6);
|
||||
line += Rinex_Printer::rightJustify(day, 6);
|
||||
line += Rinex_Printer::rightJustify(hour, 6);
|
||||
line += Rinex_Printer::rightJustify(minutes, 6);
|
||||
line += Rinex_Printer::rightJustify(asString(seconds,7), 13);
|
||||
line += Rinex_Printer::rightJustify(std::string("GPS"), 8);
|
||||
line += std::string(9, ' ');
|
||||
line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20);
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
@@ -957,126 +958,119 @@ void Rinex_Printer::RinexObsHeader(std::ofstream& out, gps_navigation_message na
|
||||
|
||||
|
||||
|
||||
void Rinex_Printer::LogRinexObs(gps_navigation_message nav_msg,double pseudoranges_clock, std::map<int,float> pseudoranges)
|
||||
void Rinex_Printer::log_rinex_obs(std::ofstream& out, gps_navigation_message nav_msg, std::map<int,float> pseudoranges)
|
||||
{
|
||||
/* int ss;
|
||||
char sat_vis[36];
|
||||
for(int i=0;i<36;i++) sat_vis[i]=' ';
|
||||
char packet[80];
|
||||
int index=0;
|
||||
char cad[2];
|
||||
double setmanes;
|
||||
std::string line;
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
line += "OBSERVATION DATA FILE FOR VERSION 2.11 STILL NOT IMPLEMENTED";
|
||||
line += std::string(80-line.size(), ' ');
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
}
|
||||
|
||||
if (version == 3)
|
||||
{
|
||||
boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_time(nav_msg);
|
||||
std::string timestring=boost::posix_time::to_iso_string(p_utc_time);
|
||||
std::string year (timestring, 0, 4);
|
||||
std::string month (timestring, 4, 2);
|
||||
std::string day (timestring, 6, 2);
|
||||
std::string hour (timestring, 9, 2);
|
||||
std::string minutes (timestring, 11, 2);
|
||||
|
||||
// Should look at the pseudoranges timestamp gnss_pseudorange.timestamp_ms!!!
|
||||
line += std::string(1, '>');
|
||||
line += std::string(1, ' ');
|
||||
line += year;
|
||||
line += std::string(1, ' ');
|
||||
line += month;
|
||||
line += std::string(1, ' ');
|
||||
line += day;
|
||||
line += std::string(1, ' ');
|
||||
line += hour;
|
||||
line += std::string(1, ' ');
|
||||
line += minutes;
|
||||
|
||||
line += std::string(1, ' ');
|
||||
double utc_t = nav_msg.utc_time(nav_msg.sv_clock_correction(nav_msg.d_TOW));
|
||||
line += Rinex_Printer::asString(fmod(utc_t,60), 7);
|
||||
line += std::string(2, ' ');
|
||||
// Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event
|
||||
line += std::string(1, '0');
|
||||
|
||||
//Number of satellites observed in current epoch
|
||||
int numSatellitesObserved = 0;
|
||||
std::map<int,float>::iterator pseudoranges_iter;
|
||||
|
||||
//necessito
|
||||
//1-Data i hora<--- de struct Clock_S
|
||||
//2-#sat visibles, identificador dat visibles-----> de Com fa a LogNav() // (Chan_Packet_S *) &tChan[lcv]->sv
|
||||
//3-pseudodistancia de cada satèl·lit ----> Com fa a LogPseudo(), tb es pot treure la carrier_phase. Serveix per algo??
|
||||
//4- El punt 1 i 2 s'han d'escriure a la mateixa línia. El punt 3 una línia per a cada satèl·lit.
|
||||
if(fp_rin != NULL)
|
||||
{
|
||||
setmanes=nav_msg.d_GPS_week + 1024;
|
||||
//1-Calcul data i hora gps
|
||||
//Calculo el any,mes i dia a partir de l'hora UTC
|
||||
//calculate UTC_TIME
|
||||
time_t temps;
|
||||
char cad1[80];
|
||||
char cad2[80];
|
||||
char cad3[80];
|
||||
char cad4[80];
|
||||
struct tm *tmPtr;
|
||||
//Calculo hora, minut, segons a partir de pClocK.time =hora GPS
|
||||
double decimalday,daydecimalhour,decimalhour,decimalmin,decimalsec;
|
||||
double day,hour,minutes,seconds,enterseconds,a;
|
||||
double gpstime;
|
||||
gpstime=pseudoranges_clock; //[s]
|
||||
//calculate date of gps time:
|
||||
//Days & weeks between 00h 1 Jan 1970 and 00h 6 Jan 1980
|
||||
//520 weeks and 12 days.
|
||||
|
||||
temps=(520+setmanes)*7*24*3600+gpstime+17*24*3600;
|
||||
tmPtr = gmtime(&temps);
|
||||
strftime( cad1, 20, " %y %m %d", tmPtr );
|
||||
strftime( cad2, 20, " %Y %m %d", tmPtr );
|
||||
decimalday=(gpstime/(24*3600));//Dies dins de la semana
|
||||
daydecimalhour=modf(decimalday,&day);//day=#dies sencers, daydecimalhour=porcio de dia
|
||||
daydecimalhour=daydecimalhour*24;//porcio de dia en hores
|
||||
decimalhour=modf(daydecimalhour,&hour);//hour=hora del dia; decimalhour=porcio d'hora
|
||||
decimalmin=decimalhour*60;//decimalmin=minuts del dia amb decimal
|
||||
decimalsec=modf(decimalmin,&minutes);//minutes=minuts del dia enters,decimalsec=porcio de minuts
|
||||
seconds=decimalsec*60;//seconds=segons del dia en decimal
|
||||
|
||||
a=modf(seconds,&enterseconds);
|
||||
sprintf(cad4,"%6.0f%6.0f%13.7f",hour,minutes,seconds);
|
||||
sprintf(cad3," %2.0f %2.0f%11.7f",hour,minutes,seconds);
|
||||
|
||||
//TODO: Include receiver clock offset
|
||||
if(temps_primera_obs==1){
|
||||
//Escriure Hora Primera Observació
|
||||
fseek(fp_rin, fp_rin_end, SEEK_SET);
|
||||
fprintf(fp_rin,"%s%s GPS TIME OF FIRST OBS\n",cad2,cad4);
|
||||
fprintf(fp_rin,"00000CTTC MARKER NUMBER\n");
|
||||
//fprintf(fp_rin,"Edited by .... COMMENT\n");
|
||||
fprintf(fp_rin," END OF HEADER\n");
|
||||
fp_rin_end = ftell(fp_rin);
|
||||
temps_primera_obs=0;
|
||||
}
|
||||
|
||||
//2-Num sat visibles i identificador
|
||||
signed long int nsvs = 0;
|
||||
|
||||
//3-Escriure pseudodistancia
|
||||
for(pseudoranges_iter = pseudoranges.begin();
|
||||
pseudoranges_iter != pseudoranges.end();
|
||||
pseudoranges_iter++)
|
||||
{
|
||||
//PER FORMAT RINEX2
|
||||
nsvs++;
|
||||
sprintf(cad,"%2.0f",(double)pseudoranges_iter->first); //satellite PRN ID
|
||||
int k=3*index;
|
||||
sat_vis[k]='G';
|
||||
sat_vis[k+1]=cad[0];
|
||||
sat_vis[k+2]=cad[1];
|
||||
index++;
|
||||
numSatellitesObserved++;
|
||||
}
|
||||
//sat_vis tinc vector de identif de sat visibles
|
||||
//Per format RINEX2
|
||||
//sprintf(packet,"%s%s 0%3d%s%12.9f",cad1,cad3,nsvs,sat_vis,offset);
|
||||
sprintf(packet,"%s%s 0%3d%s",cad1,cad3,nsvs,sat_vis);
|
||||
packet[69]=packet[68];
|
||||
packet[68]=' ';
|
||||
fseek(fp_rin, fp_rin_end, SEEK_SET);
|
||||
fprintf(fp_rin,"%s\n",packet);
|
||||
fp_rin_end = ftell(fp_rin);
|
||||
|
||||
//3-Escriure pseudodistancia
|
||||
line += Rinex_Printer::rightJustify(boost::lexical_cast<std::string>(numSatellitesObserved), 3);
|
||||
|
||||
|
||||
// Receiver clock offset (optional)
|
||||
//line += rightJustify(asString(clockOffset, 12), 15);
|
||||
|
||||
line += std::string(80 - line.size(), ' ');
|
||||
Rinex_Printer::lengthCheck(line);
|
||||
out << line << std::endl;
|
||||
|
||||
for(pseudoranges_iter = pseudoranges.begin();
|
||||
pseudoranges_iter != pseudoranges.end();
|
||||
pseudoranges_iter++)
|
||||
{
|
||||
ss=signalstrength(54.00); // TODO: include estimated signal strength
|
||||
fseek(fp_rin, fp_rin_end, SEEK_SET);
|
||||
fprintf(fp_rin,"%14.3f %14.3f %d\n",pseudoranges_iter->second,0.0,ss); //TODO: include the carrier phase
|
||||
fp_rin_end = ftell(fp_rin);
|
||||
}
|
||||
}*/
|
||||
std::string lineObs;
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem["GPS"];
|
||||
if ((int)pseudoranges_iter->first < 10) lineObs += std::string(1, '0');
|
||||
lineObs += boost::lexical_cast<std::string>((int)pseudoranges_iter->first);
|
||||
//lineObs += std::string(2, ' ');
|
||||
lineObs += Rinex_Printer::rightJustify(asString((double)pseudoranges_iter->second, 3), 14);
|
||||
|
||||
//Loss of lock indicator (LLI)
|
||||
int lli = 0; // Include in the observation!!
|
||||
if (lli == 0)
|
||||
{
|
||||
lineObs += std::string(1, ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(lli), 1);
|
||||
}
|
||||
int ssi=signalStrength(54.0); // TODO: include estimated signal strength
|
||||
if (ssi == 0)
|
||||
{
|
||||
lineObs += std::string(1, ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString<short>(ssi), 1);
|
||||
}
|
||||
if (lineObs.size()<80) lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
out << lineObs << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int Rinex_Printer::signalStrength(double snr)
|
||||
{
|
||||
|
||||
int ss;
|
||||
ss = int ( std::min( std::max( int (floor(snr/6)) , 1), 9) );
|
||||
return (ss);
|
||||
return ss;
|
||||
}
|
||||
|
||||
|
||||
boost::posix_time::ptime Rinex_Printer::computeTime(gps_navigation_message nav_msg)
|
||||
|
||||
|
||||
boost::posix_time::ptime Rinex_Printer::compute_time(gps_navigation_message nav_msg)
|
||||
{
|
||||
// if we are processing a file -> wait to leap second to resolve the ambiguity else take the week from the local system time
|
||||
//: idea resolve the ambiguity with the leap second http://www.colorado.edu/geography/gcraft/notes/gps/gpseow.htm
|
||||
@@ -1088,18 +1082,6 @@ boost::posix_time::ptime Rinex_Printer::computeTime(gps_navigation_message nav_m
|
||||
|
||||
/*
|
||||
|
||||
enum RINEX_enumObservationType
|
||||
{
|
||||
RINEX_OBS_TYPE_PSEUDORANGE = 'C', //!< 'C' Pseudorange observation
|
||||
RINEX_OBS_TYPE_CARRIER_PHASE = 'L', //!< 'L' Carrier Phase observation
|
||||
RINEX_OBS_TYPE_DOPPLER = 'D', //!< 'L' Doppler observation
|
||||
RINEX_OBS_TYPE_SIGNAL_STRENGTH = 'S' //!< 'S' Signal strength observation
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum RINEX_enumMarkerType {
|
||||
GEODETIC, //!< GEODETIC Earth-fixed, high-precision monumentation
|
||||
NON_GEODETIC, //!< NON_GEODETIC Earth-fixed, low-precision monumentation
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user