1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-10 20:10:05 +00:00

Improving observables binary dump

This commit is contained in:
Javier Arribas 2017-07-28 18:24:36 +02:00
parent 095e049558
commit ceef915de7
8 changed files with 67 additions and 103 deletions

View File

@ -337,6 +337,8 @@ int hybrid_observables_cc::general_work (int noutput_items,
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_gnss_synchro[i].PRN;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
}
catch (const std::ifstream::failure& e)

View File

@ -43,6 +43,7 @@ bool observables_dump_reader::read_binary_obs()
d_dump_file.read((char *) &Acc_carrier_phase_hz[i], sizeof(double));
d_dump_file.read((char *) &Pseudorange_m[i], sizeof(double));
d_dump_file.read((char *) &PRN[i], sizeof(double));
d_dump_file.read((char *) &valid[i], sizeof(double));
}
}
catch (const std::ifstream::failure &e)
@ -69,7 +70,7 @@ bool observables_dump_reader::restart()
long int observables_dump_reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch = n_channels*6;
int number_of_vars_in_epoch = n_channels*7;
int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch;
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
@ -117,6 +118,7 @@ observables_dump_reader::observables_dump_reader(int n_channels_)
Acc_carrier_phase_hz=new double[n_channels];
Pseudorange_m=new double[n_channels];
PRN=new double[n_channels];
valid=new double[n_channels];
}
observables_dump_reader::~observables_dump_reader()
{
@ -130,4 +132,5 @@ observables_dump_reader::~observables_dump_reader()
delete[] Acc_carrier_phase_hz;
delete[] Pseudorange_m;
delete[] PRN;
delete[] valid;
}

View File

@ -55,6 +55,7 @@ public:
double* Acc_carrier_phase_hz;
double* Pseudorange_m;
double* PRN;
double* valid;
private:
int n_channels;

View File

@ -1,22 +0,0 @@
% Read observables dump
clear all;
close all;
%IFEN NSR Sampler Fs=20480000
% GNSS-SDR decimation factor 8
samplingFreq = 20480000/8; %[Hz]
channels=4;
path='/home/gnss/workspace/gnss-sdr/trunk/install/';
observables_log_path=[path 'observables.dat'];
GNSS_observables= gps_l1_ca_read_observables_dump(channels,observables_log_path);
skip=9000;
ref_channel=1;
plot(GNSS_observables.d_TOW_at_current_symbol(ref_channel,skip:end),GNSS_observables.Pseudorange_m(:,skip:end).')
title('psudoranges');
figure
plot(GNSS_observables.d_TOW_at_current_symbol(ref_channel,skip:end),GNSS_observables.Prn_timestamp_ms(:,skip:end).')
title('Prn_timestamps');

View File

@ -1,9 +0,0 @@
% Read observables dump
%clear all;
samplingFreq = 64e6/16; %[Hz]
channels=4;
path='/home/gnss/workspace/gnss-sdr/trunk/install/';
observables_log_path=[path 'observables.dat'];
GNSS_observables= gps_l1_ca_read_observables_dump(channels,observables_log_path);

View File

@ -0,0 +1,39 @@
% Read observables dump
%clear all;
samplingFreq = 2600000; %[Hz]
channels=2;
path='/home/javier/git/gnss-sdr/build/';
observables_log_path=[path 'observables.dat'];
GNSS_observables= read_hybrid_observables_dump(channels,observables_log_path);
%optional:
%search all channels having good satellite simultaneously
min_idx=1;
for n=1:1:channels
idx=find(GNSS_observables.valid(n,:)>0,1,'first');
if min_idx<idx
min_idx=idx;
end
end
%plot observables from that index
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Pseudorange_m(:,min_idx+1:end)');
title('Pseudoranges [m]')
xlabel('TOW [s]')
ylabel('[m]');
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Carrier_phase_hz(:,min_idx+1:end)');
title('Accumulated carrier phase')
xlabel('TOW [s]')
ylabel('[cycles]');
figure;
plot(GNSS_observables.RX_time(1,min_idx+1:end),GNSS_observables.Carrier_Doppler_hz(:,min_idx+1:end)');
title('Doppler frequency')
xlabel('TOW [s]')
ylabel('[Hz]');

View File

@ -1,60 +0,0 @@
% Javier Arribas 2011
function [observables] = gps_l1_ca_dll_pll_read_observables_dump (channels, filename, count)
%% usage: read_tracking_dat (filename, [count])
%%
%% open GNSS-SDR tracking binary log file .dat and return the contents
%%
m = nargchk (1,2,nargin);
num_double_vars=5;
double_size_bytes=8;
skip_bytes_each_read=double_size_bytes*num_double_vars*channels;
bytes_shift=0;
if (m)
usage (m);
end
if (nargin < 3)
count = Inf;
end
%loops_counter = fread (f, count, 'uint32',4*12);
f = fopen (filename, 'rb');
if (f < 0)
else
for N=1:1:channels
observables.preamble_delay_ms(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.prn_delay_ms(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Pseudorange_m(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Pseudorange_symbol_shift(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.PRN(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
end
fclose (f);
%%%%%%%% output vars %%%%%%%%
% for (unsigned int i=0; i<d_nchannels ; i++)
% {
% tmp_double = current_gnss_synchro[i].Preamble_delay_ms;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Prn_delay_ms;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Pseudorange_m;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Pseudorange_symbol_shift;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].PRN;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% }
end

View File

@ -1,5 +1,5 @@
% Javier Arribas 2011
function [observables] = gps_l1_ca_read_observables_dump (channels, filename, count)
function [observables] = read_hybrid_observables_dump (channels, filename, count)
%% usage: read_tracking_dat (filename, [count])
%%
@ -7,7 +7,7 @@ function [observables] = gps_l1_ca_read_observables_dump (channels, filename, co
%%
m = nargchk (1,2,nargin);
num_double_vars=5;
num_double_vars=7;
double_size_bytes=8;
skip_bytes_each_read=double_size_bytes*num_double_vars*channels;
bytes_shift=0;
@ -23,19 +23,25 @@ function [observables] = gps_l1_ca_read_observables_dump (channels, filename, co
if (f < 0)
else
for N=1:1:channels
observables.RX_time(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.d_TOW_at_current_symbol(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Prn_timestamp_ms(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
observables.Carrier_Doppler_hz(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Carrier_phase_hz(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Pseudorange_m(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.Flag_valid_pseudorange(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
observables.PRN(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
observables.PRN(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
observables.valid(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
end
@ -44,18 +50,22 @@ function [observables] = gps_l1_ca_read_observables_dump (channels, filename, co
%%%%%%%% output vars %%%%%%%%
% double tmp_double;
% for (unsigned int i=0; i<d_nchannels ; i++)
% for (unsigned int i = 0; i < d_nchannels; i++)
% {
% tmp_double = current_gnss_synchro[i].d_TOW_at_current_symbol;
% tmp_double = current_gnss_synchro[i].RX_time;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Prn_timestamp_ms;
% tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Pseudorange_m;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = (double)(current_gnss_synchro[i].Flag_valid_pseudorange==true);
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].PRN;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% }
end