mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	Merge branch 'next' into arribas_next
Conflicts: src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc
This commit is contained in:
		| @@ -32,8 +32,8 @@ set(GNSS_SPLIBS_SOURCES | ||||
|     short_x2_to_cshort.cc | ||||
|     complex_float_to_complex_byte.cc | ||||
| ) | ||||
|      | ||||
|      | ||||
|  | ||||
|  | ||||
| if(OPENCL_FOUND) | ||||
|     set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES} | ||||
|          fft_execute.cc # Needs OpenCL | ||||
| @@ -70,12 +70,12 @@ add_library(gnss_sp_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS}) | ||||
| source_group(Headers FILES ${GNSS_SPLIBS_HEADERS}) | ||||
|  | ||||
| target_link_libraries(gnss_sp_libs ${GNURADIO_RUNTIME_LIBRARIES} | ||||
|                                    ${VOLK_LIBRARIES}  | ||||
|                                    ${VOLK_GNSSSDR_LIBRARIES}  | ||||
|                                    ${GNURADIO_BLOCKS_LIBRARIES}  | ||||
|                                    ${GNURADIO_FFT_LIBRARIES}  | ||||
|                                    ${GNURADIO_FILTER_LIBRARIES}  | ||||
|                                    ${OPT_LIBRARIES}  | ||||
|                                    ${VOLK_LIBRARIES} ${ORC_LIBRARIES} | ||||
|                                    ${VOLK_GNSSSDR_LIBRARIES}  ${ORC_LIBRARIES} | ||||
|                                    ${GNURADIO_BLOCKS_LIBRARIES} | ||||
|                                    ${GNURADIO_FFT_LIBRARIES} | ||||
|                                    ${GNURADIO_FILTER_LIBRARIES} | ||||
|                                    ${OPT_LIBRARIES} | ||||
|                                    gnss_rx | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -32,43 +32,26 @@ | ||||
|  */ | ||||
|  | ||||
| #include "gnss_signal_processing.h" | ||||
| #include <gnuradio/fxpt.h>  // fixed point sine and cosine | ||||
| #include <gnuradio/fxpt_nco.h> | ||||
|  | ||||
|  | ||||
| auto auxCeil2 = [](float x){ return static_cast<int>(static_cast<long>((x)+1)); }; | ||||
|  | ||||
| void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps) | ||||
| { | ||||
|     int phase_i = 0; | ||||
|     int phase_step_i; | ||||
|     float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs); | ||||
|     phase_step_i = gr::fxpt::float_to_fixed(phase_step_f); | ||||
|     float sin_f, cos_f; | ||||
|  | ||||
|     for(unsigned int i = 0; i < _samps; i++) | ||||
|         { | ||||
|             gr::fxpt::sincos(phase_i, &sin_f, &cos_f); | ||||
|             _dest[i] = std::complex<float>(cos_f, sin_f); | ||||
|             phase_i += phase_step_i; | ||||
|         } | ||||
|     gr::fxpt_nco d_nco; | ||||
|     d_nco.set_freq((GPS_TWO_PI * _f) / _fs); | ||||
|     d_nco.sincos(_dest, _samps, 1);  | ||||
| } | ||||
|  | ||||
|  | ||||
| void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps) | ||||
| { | ||||
|     int phase_i = 0; | ||||
|     int phase_step_i; | ||||
|     float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs); | ||||
|     phase_step_i = gr::fxpt::float_to_fixed(phase_step_f); | ||||
|     float sin_f, cos_f; | ||||
|  | ||||
|     for(unsigned int i = 0; i < _samps; i++) | ||||
|         { | ||||
|             gr::fxpt::sincos(phase_i, &sin_f, &cos_f); | ||||
|             _dest[i] = std::complex<float>(cos_f, -sin_f); | ||||
|             phase_i += phase_step_i; | ||||
|         } | ||||
|     gr::fxpt_nco d_nco; | ||||
|     d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs); | ||||
|     d_nco.sincos(_dest, _samps, 1);  | ||||
| } | ||||
|  | ||||
|  | ||||
| void hex_to_binary_converter(int * _dest, char _from) | ||||
| { | ||||
| 	switch(_from) | ||||
| @@ -177,6 +160,7 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs | ||||
|         float _fs_out, unsigned int _length_in, unsigned int _length_out) | ||||
| { | ||||
|     unsigned int _codeValueIndex; | ||||
|     float aux; | ||||
|     //--- Find time constants -------------------------------------------------- | ||||
|     const float _t_in = 1 / _fs_in;  // Incoming sampling  period in sec | ||||
|     const float _t_out = 1 / _fs_out;   // Out sampling period in sec | ||||
| @@ -184,7 +168,10 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs | ||||
|         { | ||||
|             //=== Digitizing ======================================================= | ||||
|             //--- compute index array to read sampled values ------------------------- | ||||
|             _codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; | ||||
|             //_codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; | ||||
|             aux = (_t_out * (i + 1)) / _t_in; | ||||
|             _codeValueIndex = auxCeil2(aux) - 1; | ||||
|  | ||||
|             //if repeat the chip -> upsample by nearest neighborhood interpolation | ||||
|             _dest[i] = _from[_codeValueIndex]; | ||||
|         } | ||||
|   | ||||
| @@ -34,19 +34,24 @@ | ||||
| #include <stdlib.h> | ||||
| #include <cmath> | ||||
|  | ||||
| auto auxCeil = [](float x){ return static_cast<int>(static_cast<long>((x)+1)); }; | ||||
|  | ||||
| void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift) | ||||
| { | ||||
|     unsigned int G1[1023]; | ||||
|     unsigned int G2[1023]; | ||||
|     unsigned int G1_register[10], G2_register[10]; | ||||
|     unsigned int feedback1, feedback2; | ||||
|  | ||||
|  | ||||
|     const unsigned int _code_length = 1023; | ||||
|     bool G1[_code_length]; | ||||
|     bool G2[_code_length]; | ||||
|     bool G1_register[10], G2_register[10]; | ||||
|     bool feedback1, feedback2; | ||||
|     bool aux; | ||||
|     unsigned int lcv, lcv2; | ||||
|     unsigned int delay; | ||||
|     signed int prn_idx; | ||||
|  | ||||
|     /* G2 Delays as defined in GPS-ISD-200D */ | ||||
|     signed int delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254 ,255, 256, 257, 258, 469, 470, 471, 472, | ||||
|     const signed int delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254 ,255, 256, 257, 258, 469, 470, 471, 472, | ||||
|             473, 474, 509, 512, 513, 514, 515, 516, 859, 860, 861, 862 /*PRN32*/, | ||||
|             145 /*PRN120*/, 175, 52, 21, 237, 235, 886, 657, 634, 762, | ||||
|             355, 1012, 176, 603, 130, 359, 595, 68, 386 /*PRN138*/}; | ||||
| @@ -59,7 +64,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|     	prn_idx = _prn-1; | ||||
|     	prn_idx = _prn - 1; | ||||
|     } | ||||
|  | ||||
|     /* A simple error check */ | ||||
| @@ -73,7 +78,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns | ||||
|         } | ||||
|  | ||||
|     /* Generate G1 & G2 Register */ | ||||
|     for(lcv = 0; lcv < 1023; lcv++) | ||||
|     for(lcv = 0; lcv < _code_length; lcv++) | ||||
|         { | ||||
|             G1[lcv] = G1_register[0]; | ||||
|             G2[lcv] = G2_register[0]; | ||||
| @@ -92,23 +97,29 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns | ||||
|         } | ||||
|  | ||||
|     /* Set the delay */ | ||||
|     delay = 1023 - delays[prn_idx]; | ||||
|     delay = _code_length - delays[prn_idx]; | ||||
|     delay += _chip_shift; | ||||
|     delay %= 1023; | ||||
|     delay %= _code_length; | ||||
|  | ||||
|     /* Generate PRN from G1 and G2 Registers */ | ||||
|     for(lcv = 0; lcv < 1023; lcv++) | ||||
|     for(lcv = 0; lcv < _code_length; lcv++) | ||||
|         { | ||||
|             _dest[lcv] = std::complex<float>(G1[(lcv +  _chip_shift)%1023]^G2[delay], 0); | ||||
|             if(_dest[lcv].real() == 0.0) //javi | ||||
|             aux = G1[(lcv + _chip_shift) % _code_length]^G2[delay]; | ||||
|             if(aux == true) | ||||
|                 { | ||||
|                     _dest[lcv].real(-1.0); | ||||
|                     _dest[lcv] = std::complex<float>(1, 0); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     _dest[lcv] = std::complex<float>(-1, 0); | ||||
|                 } | ||||
|             delay++; | ||||
|             delay %= 1023; | ||||
|             delay %= _code_length; | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| /* | ||||
|  *  Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency | ||||
|  */ | ||||
| @@ -119,6 +130,7 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int | ||||
|     signed int _samplesPerCode, _codeValueIndex; | ||||
|     float _ts; | ||||
|     float _tc; | ||||
|     float aux; | ||||
|     const signed int _codeFreqBasis = 1023000; //Hz | ||||
|     const signed int _codeLength = 1023; | ||||
|  | ||||
| @@ -139,7 +151,9 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int | ||||
|             // number of samples per millisecond (because one C/A code period is one | ||||
|             // millisecond). | ||||
|  | ||||
|             _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; | ||||
|             // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; | ||||
|             aux = (_ts * (i + 1)) / _tc;    | ||||
|             _codeValueIndex = auxCeil( aux ) - 1; | ||||
|  | ||||
|             //--- Make the digitized version of the C/A code ----------------------- | ||||
|             // The "upsampled" code is made by selecting values form the CA code | ||||
| @@ -157,6 +171,3 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -18,7 +18,7 @@ | ||||
|  */ | ||||
|  | ||||
| #include "volk_gnsssdr/volk_gnsssdr_malloc.h" | ||||
| #include <pthread.h> | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
|  | ||||
| @@ -27,29 +27,6 @@ | ||||
|  * see: http://linux.die.net/man/3/aligned_alloc | ||||
|  */ | ||||
|  | ||||
| // Disabling use of aligned_alloc. This function requires that size be | ||||
| // a multiple of alignment, which is too restrictive for many uses of | ||||
| // VOLK. | ||||
|  | ||||
| //// If we are using C11 standard, use the aligned_alloc | ||||
| //#ifdef _ISOC11_SOURCE | ||||
| // | ||||
| //void *volk_gnsssdr_malloc(size_t size, size_t alignment) | ||||
| //{ | ||||
| //  void *ptr = aligned_alloc(alignment, size); | ||||
| //  if(ptr == NULL) { | ||||
| //    fprintf(stderr, "VOLK: Error allocating memory (aligned_alloc)\n"); | ||||
| //  } | ||||
| //  return ptr; | ||||
| //} | ||||
| // | ||||
| //void volk_gnsssdr_free(void *ptr) | ||||
| //{ | ||||
| //  free(ptr); | ||||
| //} | ||||
| // | ||||
| //#else // _ISOC11_SOURCE | ||||
|  | ||||
| // Otherwise, test if we are a POSIX or X/Open system | ||||
| // This only has a restriction that alignment be a power of 2and a | ||||
| // multiple of sizeof(void *). | ||||
| @@ -59,11 +36,11 @@ void *volk_gnsssdr_malloc(size_t size, size_t alignment) | ||||
| { | ||||
|     void *ptr; | ||||
|  | ||||
|   // quoting posix_memalign() man page: | ||||
|   // "alignment must be a power of two and a multiple of sizeof(void *)" | ||||
|   // volk_get_alignment() could return 1 for some machines (e.g. generic_orc) | ||||
|   if (alignment == 1) | ||||
|     return malloc(size); | ||||
|     // quoting posix_memalign() man page: | ||||
|     // "alignment must be a power of two and a multiple of sizeof(void *)" | ||||
|     // volk_get_alignment() could return 1 for some machines (e.g. generic_orc) | ||||
|     if (alignment == 1) | ||||
|         return malloc(size); | ||||
|  | ||||
|     int err = posix_memalign(&ptr, alignment, size); | ||||
|     if(err == 0) | ||||
|   | ||||
| @@ -21,19 +21,17 @@ | ||||
| #include <string.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr_prefs.h> | ||||
|  | ||||
| //#if defined(_WIN32) | ||||
| //#include <Windows.h> | ||||
| //#endif | ||||
|  | ||||
| void volk_gnsssdr_get_config_path(char *path) | ||||
| { | ||||
|     if (!path) return; | ||||
|     const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config"; | ||||
|     char *home = NULL; | ||||
|     if (home == NULL) home = getenv("HOME"); | ||||
|     if (home == NULL) home = getenv("APPDATA"); | ||||
|     if (home == NULL) | ||||
|         { | ||||
|             path = NULL; | ||||
|             path[0] = 0; | ||||
|             return; | ||||
|         } | ||||
|     strcpy(path, home); | ||||
| @@ -49,7 +47,7 @@ size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res) | ||||
|  | ||||
|     //get the config path | ||||
|     volk_gnsssdr_get_config_path(path); | ||||
|     if (path == NULL) return n_arch_prefs; //no prefs found | ||||
|     if (!path[0]) return n_arch_prefs; //no prefs found | ||||
|     config_file = fopen(path, "r"); | ||||
|     if(!config_file) return n_arch_prefs; //no prefs found | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Javier
					Javier