1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-04 17:16:26 +00:00

Merge branch 'next' of https://github.com/carlesfernandez/gnss-sdr into acq_performance

This commit is contained in:
Carles Fernandez 2018-06-21 09:54:40 +02:00
commit 2bd5d47398
6 changed files with 110 additions and 73 deletions

View File

@ -121,6 +121,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
} }
grid_ = arma::fmat(); grid_ = arma::fmat();
d_step_two = false; d_step_two = false;
d_dump_number = 0;
} }
@ -335,6 +336,51 @@ void pcps_acquisition::send_negative_acquisition()
} }
void pcps_acquisition::dump_results(int effective_fft_size)
{
d_dump_number++;
std::string filename = acq_parameters.dump_filename;
filename.append("_");
filename.append(1, d_gnss_synchro->System);
filename.append("_");
filename.append(1, d_gnss_synchro->Signal[0]);
filename.append(1, d_gnss_synchro->Signal[1]);
filename.append("_ch_");
filename.append(std::to_string(d_channel));
filename.append("_");
filename.append(std::to_string(d_dump_number));
filename.append("_sat_");
filename.append(std::to_string(d_gnss_synchro->PRN));
filename.append(".mat");
mat_t* matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if (matfp == NULL)
{
std::cout << "Unable to create or open Acquisition dump file" << std::endl;
acq_parameters.dump = false;
}
else
{
size_t dims[2] = {static_cast<size_t>(effective_fft_size), static_cast<size_t>(d_num_doppler_bins)};
matvar_t* matvar = Mat_VarCreate("grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
dims[0] = static_cast<size_t>(1);
dims[1] = static_cast<size_t>(1);
matvar = Mat_VarCreate("doppler_max", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &acq_parameters.doppler_max, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("doppler_step", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_doppler_step, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
Mat_Close(matfp);
}
}
void pcps_acquisition::acquisition_core(unsigned long int samp_count) void pcps_acquisition::acquisition_core(unsigned long int samp_count)
{ {
gr::thread::scoped_lock lk(d_setlock); gr::thread::scoped_lock lk(d_setlock);
@ -342,7 +388,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
// initialize acquisition algorithm // initialize acquisition algorithm
uint32_t indext = 0; uint32_t indext = 0;
float magt = 0.0; float magt = 0.0;
const gr_complex* in = d_data_buffer; //Get the input samples pointer const gr_complex* in = d_data_buffer; // Get the input samples pointer
int effective_fft_size = (acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size); int effective_fft_size = (acq_parameters.bit_transition_flag ? d_fft_size / 2 : d_fft_size);
if (d_cshort) if (d_cshort)
{ {
@ -436,43 +482,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
if (acq_parameters.dump) if (acq_parameters.dump)
{ {
memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size); memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size);
if (doppler_index == (d_num_doppler_bins - 1))
{
std::string filename = acq_parameters.dump_filename;
filename.append("_");
filename.append(1, d_gnss_synchro->System);
filename.append("_");
filename.append(1, d_gnss_synchro->Signal[0]);
filename.append(1, d_gnss_synchro->Signal[1]);
filename.append("_sat_");
filename.append(std::to_string(d_gnss_synchro->PRN));
filename.append(".mat");
mat_t* matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if (matfp == NULL)
{
std::cout << "Unable to create or open Acquisition dump file" << std::endl;
acq_parameters.dump = false;
}
else
{
size_t dims[2] = {static_cast<size_t>(effective_fft_size), static_cast<size_t>(d_num_doppler_bins)};
matvar_t* matvar = Mat_VarCreate("grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
dims[0] = static_cast<size_t>(1);
dims[1] = static_cast<size_t>(1);
matvar = Mat_VarCreate("doppler_max", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &acq_parameters.doppler_max, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("doppler_step", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &d_doppler_step, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
Mat_Close(matfp);
}
}
} }
} }
} }
@ -538,8 +547,18 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
d_test_statistics = d_mag / d_input_power; d_test_statistics = d_mag / d_input_power;
} }
} }
// Record results to file if required
if (acq_parameters.dump)
{
memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size);
}
} }
} }
// Record results to file if required
if (acq_parameters.dump)
{
pcps_acquisition::dump_results(effective_fft_size);
}
lk.lock(); lk.lock();
if (!acq_parameters.bit_transition_flag) if (!acq_parameters.bit_transition_flag)
{ {

View File

@ -93,6 +93,8 @@ private:
void send_positive_acquisition(); void send_positive_acquisition();
void dump_results(int effective_fft_size);
Acq_Conf acq_parameters; Acq_Conf acq_parameters;
bool d_active; bool d_active;
bool d_worker_active; bool d_worker_active;
@ -121,6 +123,7 @@ private:
gr::fft::fft_complex* d_ifft; gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro; Gnss_Synchro* d_gnss_synchro;
arma::fmat grid_; arma::fmat grid_;
long int d_dump_number;
public: public:
~pcps_acquisition(); ~pcps_acquisition();

View File

@ -69,7 +69,7 @@
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
//all UNIX-like OSs (Linux, *BSD, MacOSX, Solaris, ...) //all UNIX-like OSs (Linux, *BSD, MacOSX, Solaris, ...)
#include <unistd.h> // for access(), mkstemp() #include <unistd.h> // for access(), mkstemp()
#define GP_MAX_TMP_FILES 64 #define GP_MAX_TMP_FILES 1024
#else #else
#error unsupported or unknown operating system #error unsupported or unknown operating system
#endif #endif
@ -302,9 +302,9 @@ public:
/// ///
/// \return <-- reference to the gnuplot object /// \return <-- reference to the gnuplot object
// ----------------------------------------------- // -----------------------------------------------
inline Gnuplot &set_multiplot() inline Gnuplot &set_multiplot(int rows, int cols)
{ {
cmd("set multiplot"); cmd("set multiplot layout " + std::to_string(rows) + "," + std::to_string(cols)); //+ " rowfirst");
return *this; return *this;
}; };
@ -1906,11 +1906,11 @@ void Gnuplot::init()
std::string tmp = Gnuplot::m_sGNUPlotPath + "/" + std::string tmp = Gnuplot::m_sGNUPlotPath + "/" +
Gnuplot::m_sGNUPlotFileName; Gnuplot::m_sGNUPlotFileName;
// FILE *popen(const char *command, const char *mode); // FILE *popen(const char *command, const char *mode);
// The popen() function shall execute the command specified by the string // The popen() function shall execute the command specified by the string
// command, create a pipe between the calling program and the executed // command, create a pipe between the calling program and the executed
// command, and return a pointer to a stream that can be used to either read // command, and return a pointer to a stream that can be used to either read
// from or write to the pipe. // from or write to the pipe.
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
gnucmd = _popen(tmp.c_str(), "w"); gnucmd = _popen(tmp.c_str(), "w");
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
@ -1974,7 +1974,7 @@ bool Gnuplot::get_program_path()
std::list<std::string> ls; std::list<std::string> ls;
//split path (one long string) into list ls of strings //split path (one long string) into list ls of strings
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
stringtok(ls, path_str, ";"); stringtok(ls, path_str, ";");
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
@ -2018,16 +2018,16 @@ bool Gnuplot::file_exists(const std::string &filename, int mode)
return false; return false;
} }
// int _access(const char *path, int mode); // int _access(const char *path, int mode);
// returns 0 if the file has the given mode, // returns 0 if the file has the given mode,
// it returns -1 if the named file does not exist or is not accessible in // it returns -1 if the named file does not exist or is not accessible in
// the given mode // the given mode
// mode = 0 (F_OK) (default): checks file for existence only // mode = 0 (F_OK) (default): checks file for existence only
// mode = 1 (X_OK): execution permission // mode = 1 (X_OK): execution permission
// mode = 2 (W_OK): write permission // mode = 2 (W_OK): write permission
// mode = 4 (R_OK): read permission // mode = 4 (R_OK): read permission
// mode = 6 : read and write permission // mode = 6 : read and write permission
// mode = 7 : read, write and execution permission // mode = 7 : read, write and execution permission
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
if (_access(filename.c_str(), mode) == 0) if (_access(filename.c_str(), mode) == 0)
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
@ -2089,19 +2089,19 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp)
throw GnuplotException(except.str()); throw GnuplotException(except.str());
} }
// int mkstemp(char *name); // int mkstemp(char *name);
// shall replace the contents of the string pointed to by "name" by a unique // shall replace the contents of the string pointed to by "name" by a unique
// filename, and return a file descriptor for the file open for reading and // filename, and return a file descriptor for the file open for reading and
// writing. Otherwise, -1 shall be returned if no suitable file could be // writing. Otherwise, -1 shall be returned if no suitable file could be
// created. The string in template should look like a filename with six // created. The string in template should look like a filename with six
// trailing 'X' s; mkstemp() replaces each 'X' with a character from the // trailing 'X' s; mkstemp() replaces each 'X' with a character from the
// portable filename character set. The characters are chosen such that the // portable filename character set. The characters are chosen such that the
// resulting name does not duplicate the name of an existing file at the // resulting name does not duplicate the name of an existing file at the
// time of a call to mkstemp() // time of a call to mkstemp()
// //
// open temporary files for output // open temporary files for output
// //
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
if (_mktemp(name) == NULL) if (_mktemp(name) == NULL)

View File

@ -73,6 +73,7 @@ bool acquisition_dump_reader::read_binary_acq()
Mat_Close(matfile); Mat_Close(matfile);
return false; return false;
} }
std::vector<std::vector<float> >::iterator it1; std::vector<std::vector<float> >::iterator it1;
std::vector<float>::iterator it2; std::vector<float>::iterator it2;
float* aux = static_cast<float*>(var_->data); float* aux = static_cast<float*>(var_->data);
@ -93,7 +94,13 @@ bool acquisition_dump_reader::read_binary_acq()
} }
acquisition_dump_reader::acquisition_dump_reader(const std::string& basename, unsigned int sat, unsigned int doppler_max, unsigned int doppler_step, unsigned int samples_per_code) acquisition_dump_reader::acquisition_dump_reader(const std::string& basename,
unsigned int sat,
unsigned int doppler_max,
unsigned int doppler_step,
unsigned int samples_per_code,
int channel,
int execution)
{ {
d_basename = basename; d_basename = basename;
d_sat = sat; d_sat = sat;
@ -103,7 +110,7 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string& basename, un
d_num_doppler_bins = static_cast<unsigned int>(ceil(static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step))); d_num_doppler_bins = static_cast<unsigned int>(ceil(static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step)));
std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code)); std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code));
mag = mag_aux; mag = mag_aux;
d_dump_filename = d_basename + "_sat_" + std::to_string(d_sat) + ".mat"; d_dump_filename = d_basename + "_ch_" + std::to_string(channel) + "_" + std::to_string(execution) + "_sat_" + std::to_string(d_sat) + ".mat";
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{ {
doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index); doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index);

View File

@ -38,7 +38,13 @@
class acquisition_dump_reader class acquisition_dump_reader
{ {
public: public:
acquisition_dump_reader(const std::string& basename, unsigned int sat, unsigned int doppler_max, unsigned int doppler_step, unsigned int samples_per_code); acquisition_dump_reader(const std::string& basename,
unsigned int sat,
unsigned int doppler_max,
unsigned int doppler_step,
unsigned int samples_per_code,
int channel = 0,
int execution = 1);
~acquisition_dump_reader(); ~acquisition_dump_reader();
bool read_binary_acq(); bool read_binary_acq();

View File

@ -33,6 +33,8 @@ file = 'acq';
sat = 7; sat = 7;
channel = 0;
execution = 1;
% Signal: % Signal:
% 1 GPS L1 % 1 GPS L1
% 2 GPS L2M % 2 GPS L2M
@ -77,7 +79,7 @@ switch(signal_type)
system = 'R'; system = 'R';
signal = '1G'; signal = '1G';
end end
filename = [path file '_' system '_' signal '_sat_' num2str(sat) '.mat']; filename = [path file '_' system '_' signal '_ch_' num2str(channel) '_' num2str(execution) '_sat_' num2str(sat) '.mat'];
load(filename); load(filename);
[n_fft n_dop_bins] = size(grid); [n_fft n_dop_bins] = size(grid);
[d_max f_max] = find(grid == max(max(grid))); [d_max f_max] = find(grid == max(max(grid)));