1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00

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

This commit is contained in:
Carles Fernandez 2019-06-30 19:46:30 +02:00
commit a2a676fbe3
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
177 changed files with 4820 additions and 2298 deletions

View File

@ -97,9 +97,16 @@ option(ENABLE_SYSTEM_TESTING "Build system tests" OFF)
option(ENABLE_SYSTEM_TESTING_EXTRA "Download external tools and build extra system tests" OFF)
option(ENABLE_GNSS_SIM_INSTALL "Enable the installation of gnss_sim on the fly" ON)
if(NOT (ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA))
set(ENABLE_GNSS_SIM_INSTALL OFF)
endif()
if(ENABLE_SYSTEM_TESTING_EXTRA)
set(ENABLE_SYSTEM_TESTING ON)
endif()
option(ENABLE_OWN_GPSTK "Force to download, build and link GPSTk for system tests, even if it is already installed" OFF)
option(ENABLE_INSTALL_TESTS "Install QA code system-wide" OFF)
@ -2026,7 +2033,7 @@ if(DOXYGEN_FOUND)
else()
message(STATUS " Doxygen has not been found in your system.")
message(STATUS " You can get nice code documentation by using it!")
message(STATUS " Get it from http://www.stack.nl/~dimitri/doxygen/index.html")
message(STATUS " Get it from http://www.doxygen.nl/download.html")
if(OS_IS_LINUX)
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " or simply by doing 'sudo yum install doxygen-latex'.")
@ -2466,6 +2473,7 @@ add_feature_info(ENABLE_UNIT_TESTING_EXTRA ENABLE_UNIT_TESTING_EXTRA "Enables bu
add_feature_info(ENABLE_SYSTEM_TESTING ENABLE_SYSTEM_TESTING "Enables building of System Tests.")
add_feature_info(ENABLE_SYSTEM_TESTING_EXTRA ENABLE_SYSTEM_TESTING_EXTRA "Enables building of Extra System Tests and downloading of external tools.")
add_feature_info(ENABLE_OWN_GPSTK ENABLE_OWN_GPSTK "Forces the downloading and building of GPSTk for system tests.")
add_feature_info(ENABLE_GNSS_SIM_INSTALL ENABLE_GNSS_SIM_INSTALL "Enables downloading and building of gnss-sim.")
add_feature_info(ENABLE_INSTALL_TESTS ENABLE_INSTALL_TESTS "Install test binaries when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME} install'.")
message(STATUS "")

View File

@ -1,98 +0,0 @@
# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
# Tries to find libosmosdr.
#
# Usage of this module as follows:
#
# find_package(LIBOSMOSDR)
#
#
# Variables defined by this module:
#
# LIBOSMOSDR_FOUND System has libosmosdr libs/headers
# LIBOSMOSDR_LIBRARIES The libosmosdr libraries
# LIBOSMOSDR_INCLUDE_DIR The location of libosmosdr headers
#
# Provides the following imported target:
# Osmosdr::osmosdr
#
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
include(FindPkgConfig)
pkg_check_modules(LIBOSMOSDR_PKG libosmosdr)
find_path(LIBOSMOSDR_INCLUDE_DIR NAMES osmosdr.h
PATHS
${LIBOSMOSDR_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
${LIBOSMOSDR_ROOT}/include
$ENV{LIBOSMOSDR_ROOT}/include
${LIBOSMOSDR_PKG_INCLUDEDIR}
)
find_library(LIBOSMOSDR_LIBRARIES NAMES osmosdr
PATHS
${LIBOSMOSDR_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/i386-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabi
/usr/lib/aarch64-linux-gnu
/usr/lib/mipsel-linux-gnu
/usr/lib/mips-linux-gnu
/usr/lib/mips64el-linux-gnuabi64
/usr/lib/powerpc-linux-gnu
/usr/lib/powerpc64-linux-gnu
/usr/lib/powerpc64le-linux-gnu
/usr/lib/powerpc-linux-gnuspe
/usr/lib/hppa-linux-gnu
/usr/lib/s390x-linux-gnu
/usr/lib/i386-gnu
/usr/lib/hppa-linux-gnu
/usr/lib/x86_64-kfreebsd-gnu
/usr/lib/i386-kfreebsd-gnu
/usr/lib/m68k-linux-gnu
/usr/lib/sh4-linux-gnu
/usr/lib/sparc64-linux-gnu
/usr/lib/x86_64-linux-gnux32
/usr/lib/alpha-linux-gnu
/usr/lib64
${LIBOSMOSDR_ROOT}/lib
$ENV{LIBOSMOSDR_ROOT}/lib
${LIBOSMOSDR_ROOT}/lib64
$ENV{LIBOSMOSDR_ROOT}/lib64
${LIBOSMOSDR_PKG_LIBDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBOSMOSDR DEFAULT_MSG LIBOSMOSDR_INCLUDE_DIR LIBOSMOSDR_LIBRARIES)
if(LIBOSMOSDR_FOUND AND NOT TARGET Osmosdr::osmosdr)
add_library(Osmosdr::osmosdr SHARED IMPORTED)
set_target_properties(Osmosdr::osmosdr PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${LIBOSMOSDR_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBOSMOSDR_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${LIBOSMOSDR_LIBRARIES}"
)
endif()
mark_as_advanced(LIBOSMOSDR_INCLUDE_DIR LIBOSMOSDR_LIBRARIES)

View File

@ -1,49 +0,0 @@
# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
# - Try to find OpenBLAS library (not headers!)
#
# The following environment variable is optionally searched
# OPENBLAS_HOME: Base directory where all OpenBlas components are found
set(OPEN_BLAS_SEARCH_PATHS
/lib
/lib64/
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/OpenBLAS/lib
/opt/local/lib
/usr/lib/openblas-base
$ENV{OPENBLAS_HOME}/lib
${OPENBLAS_ROOT}/lib
$ENV{OPENBLAS_ROOT}/lib
${OPENBLAS_ROOT}/lib64
$ENV{OPENBLAS_ROOT}/lib64
)
find_library(OPENBLAS NAMES openblas PATHS ${OPEN_BLAS_SEARCH_PATHS})
if(OPENBLAS)
set(OPENBLAS_FOUND ON)
message(STATUS "Found OpenBLAS")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OPENBLAS DEFAULT_MSG OPENBLAS)
mark_as_advanced(OPENBLAS)

View File

@ -1,55 +0,0 @@
# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
###############################################################################
# Test for availability of SSE
#
# - Anthony Arnold
###############################################################################
function(test_for_sse h_file result_var name)
if(NOT DEFINED ${result_var})
execute_process(COMMAND echo "#include <${h_file}>"
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -c -x c++ -
RESULT_VARIABLE COMPILE_RESULT
OUTPUT_QUIET ERROR_QUIET)
set(detected 0)
if(COMPILE_RESULT EQUAL 0)
message(STATUS "Detected ${name}")
set(detected 1)
endif()
set(${result_var} ${detected} CACHE INTERNAL "${name} Available")
endif()
endfunction()
message(STATUS "Testing for SIMD extensions")
enable_language(C)
test_for_sse("ammintrin.h" SSE4A_AVAILABLE "SSE4A")
test_for_sse("nmmintrin.h" SSE4_2_AVAILABLE "SSE4.2")
test_for_sse("smmintrin.h" SSE4_1_AVAILABLE "SSE4.1")
test_for_sse("tmmintrin.h" SSSE3_AVAILABLE "SSSE3")
test_for_sse("pmmintrin.h" SSE3_AVAILABLE "SSE3")
test_for_sse("emmintrin.h" SSE2_AVAILABLE "SSE2")
test_for_sse("xmmintrin.h" SSE_AVAILABLE "SSE1")
test_for_sse("mmintrin.h" MMX_AVAILABLE "MMX")
test_for_sse("wmmintrin.h" AES_AVAILABLE "AES")
test_for_sse("immintrin.h" AVX_AVAILABLE "AVX")
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/-.o")

View File

@ -56,6 +56,7 @@
### Improvements in Reliability
- Included the Guidelines Support Library. General improvement of memory management, replacement of raw pointers by containers or smart pointers.
- Applied clang-tidy checks and fixes related to High Integrity C++: performance-move-const-arg, modernize-use-auto, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-noexcept, modernize-use-nullptr, cert-dcl21-cpp, misc-new-delete-overloads, cert-dcl58-cpp, cert-err52-cpp, cert-err60-cpp.

View File

@ -35,7 +35,7 @@
#include <sstream>
Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(std::vector<std::string> addresses, const uint16_t& port, bool protobuf_enabled) : socket{io_context}
Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(const std::vector<std::string>& addresses, const uint16_t& port, bool protobuf_enabled) : socket{io_context}
{
for (const auto& address : addresses)
{

View File

@ -45,7 +45,7 @@ using b_io_context = boost::asio::io_service;
class Monitor_Pvt_Udp_Sink
{
public:
Monitor_Pvt_Udp_Sink(std::vector<std::string> addresses, const uint16_t &port, bool protobuf_enabled);
Monitor_Pvt_Udp_Sink(const std::vector<std::string>& addresses, const uint16_t &port, bool protobuf_enabled);
bool write_monitor_pvt(const Monitor_Pvt &monitor_pvt);
private:

View File

@ -283,7 +283,7 @@ bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr<Rtklib_Solver>& pvt_dat
}
char Nmea_Printer::checkSum(std::string sentence)
char Nmea_Printer::checkSum(const std::string& sentence)
{
char check = 0;
// iterate over the string, XOR each byte with the total sum:
@ -441,7 +441,7 @@ std::string Nmea_Printer::get_GPGSA()
// GSA-GNSS DOP and Active Satellites
std::stringstream sentence_str;
unsigned char buff[1024] = {0};
outnmea_gsa(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat);
outnmea_gsa(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat.data());
sentence_str << buff;
return sentence_str.str();
}
@ -454,7 +454,7 @@ std::string Nmea_Printer::get_GPGSV()
// Notice that NMEA 2.1 only supports 12 channels
std::stringstream sentence_str;
unsigned char buff[1024] = {0};
outnmea_gsv(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat);
outnmea_gsv(buff, &d_PVT_data->pvt_sol, d_PVT_data->pvt_ssat.data());
sentence_str << buff;
return sentence_str.str();
}

View File

@ -83,7 +83,7 @@ private:
std::string get_UTC_NMEA_time(boost::posix_time::ptime d_position_UTC_time);
std::string longitude_to_hm(double longitude);
std::string latitude_to_hm(double lat);
char checkSum(std::string sentence);
char checkSum(const std::string& sentence);
bool print_avg_pos;
bool d_flag_nmea_output_file;
};

View File

@ -140,7 +140,7 @@ bool Rtcm::is_server_running() const
std::string Rtcm::add_CRC(const std::string& message_without_crc) const
{
// ****** Computes Qualcomm CRC-24Q ******
boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_RTCM;
boost::crc_optimal<24, 0x1864CFBU, 0x0, 0x0, false, false> CRC_RTCM;
// 1) Converts the string to a vector of uint8_t:
boost::dynamic_bitset<uint8_t> frame_bits(message_without_crc);
std::vector<uint8_t> bytes;
@ -159,7 +159,7 @@ std::string Rtcm::add_CRC(const std::string& message_without_crc) const
bool Rtcm::check_CRC(const std::string& message) const
{
boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_RTCM_CHECK;
boost::crc_optimal<24, 0x1864CFBU, 0x0, 0x0, false, false> CRC_RTCM_CHECK;
// Convert message to binary
std::string message_bin = Rtcm::binary_data_to_bin(message);
// Check CRC
@ -2419,7 +2419,7 @@ std::string Rtcm::get_MSM_1_content_sat_data(const std::map<int32_t, Gnss_Synchr
if (it == pos.end())
{
pos.push_back(65 - gnss_synchro_iter->second.PRN);
observables_vector.push_back(*gnss_synchro_iter);
observables_vector.emplace_back(*gnss_synchro_iter);
}
}
@ -2448,7 +2448,7 @@ std::string Rtcm::get_MSM_1_content_signal_data(const std::map<int32_t, Gnss_Syn
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -2556,7 +2556,7 @@ std::string Rtcm::get_MSM_2_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -2670,7 +2670,7 @@ std::string Rtcm::get_MSM_3_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -2786,7 +2786,7 @@ std::string Rtcm::get_MSM_4_content_sat_data(const std::map<int32_t, Gnss_Synchr
if (it == pos.end())
{
pos.push_back(65 - gnss_synchro_iter->second.PRN);
observables_vector.push_back(*gnss_synchro_iter);
observables_vector.emplace_back(*gnss_synchro_iter);
}
}
@ -2827,7 +2827,7 @@ std::string Rtcm::get_MSM_4_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -2947,7 +2947,7 @@ std::string Rtcm::get_MSM_5_content_sat_data(const std::map<int32_t, Gnss_Synchr
if (it == pos.end())
{
pos.push_back(65 - gnss_synchro_iter->second.PRN);
observables_vector.push_back(*gnss_synchro_iter);
observables_vector.emplace_back(*gnss_synchro_iter);
}
}
@ -2993,7 +2993,7 @@ std::string Rtcm::get_MSM_5_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -3114,7 +3114,7 @@ std::string Rtcm::get_MSM_6_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -3234,7 +3234,7 @@ std::string Rtcm::get_MSM_7_content_signal_data(const Gps_Ephemeris& ephNAV,
map_iter != observables.cend();
map_iter++)
{
observables_vector.push_back(*map_iter);
observables_vector.emplace_back(*map_iter);
}
std::vector<std::pair<int32_t, Gnss_Synchro> > ordered_by_signal = Rtcm::sort_by_signal(observables_vector);
@ -3685,7 +3685,7 @@ uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s)
if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 );
if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576);
if( 67108864 <= lock_time_period_s ) return (704 );
return 1023; // will never happen
return 1023; // will never happen
}
// clang-format on
@ -5330,7 +5330,7 @@ int32_t Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro)
}
else
{
rr_mod_ms = static_cast<uint32_t>(std::floor(rough_range_m / meters_to_miliseconds / TWO_N10) + 0.5) & 0x3FFu;
rr_mod_ms = static_cast<uint32_t>(std::floor(rough_range_m / meters_to_miliseconds / TWO_N10) + 0.5) & 0x3FFU;
}
DF398 = std::bitset<10>(rr_mod_ms);
return 0;

View File

@ -64,6 +64,7 @@
#include <matio.h>
#include <exception>
#include <utility>
#include <vector>
Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t &rtk)
@ -172,34 +173,34 @@ bool Rtklib_Solver::save_matfile()
return false;
}
auto *TOW_at_current_symbol_ms = new uint32_t[num_epoch];
auto *week = new uint32_t[num_epoch];
auto *RX_time = new double[num_epoch];
auto *user_clk_offset = new double[num_epoch];
auto *pos_x = new double[num_epoch];
auto *pos_y = new double[num_epoch];
auto *pos_z = new double[num_epoch];
auto *vel_x = new double[num_epoch];
auto *vel_y = new double[num_epoch];
auto *vel_z = new double[num_epoch];
auto *cov_xx = new double[num_epoch];
auto *cov_yy = new double[num_epoch];
auto *cov_zz = new double[num_epoch];
auto *cov_xy = new double[num_epoch];
auto *cov_yz = new double[num_epoch];
auto *cov_zx = new double[num_epoch];
auto *latitude = new double[num_epoch];
auto *longitude = new double[num_epoch];
auto *height = new double[num_epoch];
auto *valid_sats = new uint8_t[num_epoch];
auto *solution_status = new uint8_t[num_epoch];
auto *solution_type = new uint8_t[num_epoch];
auto *AR_ratio_factor = new float[num_epoch];
auto *AR_ratio_threshold = new float[num_epoch];
auto *gdop = new double[num_epoch];
auto *pdop = new double[num_epoch];
auto *hdop = new double[num_epoch];
auto *vdop = new double[num_epoch];
auto TOW_at_current_symbol_ms = std::vector<uint32_t>(num_epoch);
auto week = std::vector<uint32_t>(num_epoch);
auto RX_time = std::vector<double>(num_epoch);
auto user_clk_offset = std::vector<double>(num_epoch);
auto pos_x = std::vector<double>(num_epoch);
auto pos_y = std::vector<double>(num_epoch);
auto pos_z = std::vector<double>(num_epoch);
auto vel_x = std::vector<double>(num_epoch);
auto vel_y = std::vector<double>(num_epoch);
auto vel_z = std::vector<double>(num_epoch);
auto cov_xx = std::vector<double>(num_epoch);
auto cov_yy = std::vector<double>(num_epoch);
auto cov_zz = std::vector<double>(num_epoch);
auto cov_xy = std::vector<double>(num_epoch);
auto cov_yz = std::vector<double>(num_epoch);
auto cov_zx = std::vector<double>(num_epoch);
auto latitude = std::vector<double>(num_epoch);
auto longitude = std::vector<double>(num_epoch);
auto height = std::vector<double>(num_epoch);
auto valid_sats = std::vector<uint8_t>(num_epoch);
auto solution_status = std::vector<uint8_t>(num_epoch);
auto solution_type = std::vector<uint8_t>(num_epoch);
auto AR_ratio_factor = std::vector<float>(num_epoch);
auto AR_ratio_threshold = std::vector<float>(num_epoch);
auto gdop = std::vector<double>(num_epoch);
auto pdop = std::vector<double>(num_epoch);
auto hdop = std::vector<double>(num_epoch);
auto vdop = std::vector<double>(num_epoch);
try
{
@ -242,35 +243,6 @@ bool Rtklib_Solver::save_matfile()
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] TOW_at_current_symbol_ms;
delete[] week;
delete[] RX_time;
delete[] user_clk_offset;
delete[] pos_x;
delete[] pos_y;
delete[] pos_z;
delete[] vel_x;
delete[] vel_y;
delete[] vel_z;
delete[] cov_xx;
delete[] cov_yy;
delete[] cov_zz;
delete[] cov_xy;
delete[] cov_yz;
delete[] cov_zx;
delete[] latitude;
delete[] longitude;
delete[] height;
delete[] valid_sats;
delete[] solution_status;
delete[] solution_type;
delete[] AR_ratio_factor;
delete[] AR_ratio_threshold;
delete[] gdop;
delete[] pdop;
delete[] hdop;
delete[] vdop;
return false;
}
@ -284,149 +256,120 @@ bool Rtklib_Solver::save_matfile()
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_UINT32, MAT_T_UINT32, 2, dims, TOW_at_current_symbol_ms, 0);
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_UINT32, MAT_T_UINT32, 2, dims, TOW_at_current_symbol_ms.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("week", MAT_C_UINT32, MAT_T_UINT32, 2, dims, week, 0);
matvar = Mat_VarCreate("week", MAT_C_UINT32, MAT_T_UINT32, 2, dims, week.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time, 0);
matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("user_clk_offset", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, user_clk_offset, 0);
matvar = Mat_VarCreate("user_clk_offset", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, user_clk_offset.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("pos_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_x, 0);
matvar = Mat_VarCreate("pos_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_x.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("pos_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_y, 0);
matvar = Mat_VarCreate("pos_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_y.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("pos_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_z, 0);
matvar = Mat_VarCreate("pos_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pos_z.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("vel_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_x, 0);
matvar = Mat_VarCreate("vel_x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_x.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("vel_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_y, 0);
matvar = Mat_VarCreate("vel_y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_y.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("vel_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_z, 0);
matvar = Mat_VarCreate("vel_z", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vel_z.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_xx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xx, 0);
matvar = Mat_VarCreate("cov_xx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xx.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_yy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yy, 0);
matvar = Mat_VarCreate("cov_yy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yy.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_zz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zz, 0);
matvar = Mat_VarCreate("cov_zz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zz.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_xy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xy, 0);
matvar = Mat_VarCreate("cov_xy", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_xy.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_yz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yz, 0);
matvar = Mat_VarCreate("cov_yz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_yz.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("cov_zx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zx, 0);
matvar = Mat_VarCreate("cov_zx", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, cov_zx.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("latitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, latitude, 0);
matvar = Mat_VarCreate("latitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, latitude.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("longitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, longitude, 0);
matvar = Mat_VarCreate("longitude", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, longitude.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("height", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, height, 0);
matvar = Mat_VarCreate("height", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, height.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("valid_sats", MAT_C_UINT8, MAT_T_UINT8, 2, dims, valid_sats, 0);
matvar = Mat_VarCreate("valid_sats", MAT_C_UINT8, MAT_T_UINT8, 2, dims, valid_sats.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("solution_status", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_status, 0);
matvar = Mat_VarCreate("solution_status", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_status.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("solution_type", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_type, 0);
matvar = Mat_VarCreate("solution_type", MAT_C_UINT8, MAT_T_UINT8, 2, dims, solution_type.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("AR_ratio_factor", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_factor, 0);
matvar = Mat_VarCreate("AR_ratio_factor", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_factor.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("AR_ratio_threshold", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_threshold, 0);
matvar = Mat_VarCreate("AR_ratio_threshold", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, AR_ratio_threshold.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("gdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, gdop, 0);
matvar = Mat_VarCreate("gdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, gdop.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("pdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pdop, 0);
matvar = Mat_VarCreate("pdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, pdop.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("hdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, hdop, 0);
matvar = Mat_VarCreate("hdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, hdop.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("vdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vdop, 0);
matvar = Mat_VarCreate("vdop", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, vdop.data(), 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] TOW_at_current_symbol_ms;
delete[] week;
delete[] RX_time;
delete[] user_clk_offset;
delete[] pos_x;
delete[] pos_y;
delete[] pos_z;
delete[] vel_x;
delete[] vel_y;
delete[] vel_z;
delete[] cov_xx;
delete[] cov_yy;
delete[] cov_zz;
delete[] cov_xy;
delete[] cov_yz;
delete[] cov_zx;
delete[] latitude;
delete[] longitude;
delete[] height;
delete[] valid_sats;
delete[] solution_status;
delete[] solution_type;
delete[] AR_ratio_factor;
delete[] AR_ratio_threshold;
delete[] gdop;
delete[] pdop;
delete[] hdop;
delete[] vdop;
return true;
}
@ -507,9 +450,9 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
int valid_obs = 0; // valid observations counter
int glo_valid_obs = 0; // GLONASS L1/L2 valid observations counter
obsd_t obs_data[MAXOBS];
eph_t eph_data[MAXOBS];
geph_t geph_data[MAXOBS];
std::array<obsd_t, MAXOBS> obs_data;
std::array<eph_t, MAXOBS> eph_data;
std::array<geph_t, MAXOBS> geph_data;
// Workaround for NAV/CNAV clash problem
bool gps_dual_band = false;
@ -894,8 +837,8 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
int result = 0;
int sat = 0;
nav_t nav_data;
nav_data.eph = eph_data;
nav_data.geph = geph_data;
nav_data.eph = eph_data.data();
nav_data.geph = geph_data.data();
nav_data.n = valid_obs;
nav_data.ng = glo_valid_obs;
@ -915,7 +858,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
}
}
result = rtkpos(&rtk_, obs_data, valid_obs + glo_valid_obs, &nav_data);
result = rtkpos(&rtk_, obs_data.data(), valid_obs + glo_valid_obs, &nav_data);
if (result == 0)
{
@ -976,7 +919,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
}
this->set_rx_pos(rx_position_and_time.rows(0, 2)); // save ECEF position for the next iteration
//compute Ground speed and COG
// compute Ground speed and COG
double ground_speed_ms = 0.0;
double pos[3];
double enuv[3];
@ -1015,9 +958,7 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
<< " [deg], Height= " << this->get_height() << " [m]"
<< " RX time offset= " << this->get_time_offset_s() << " [s]";
// PVT MONITOR
// ######## PVT MONITOR #########
// TOW
monitor_pvt.TOW_at_current_symbol_ms = gnss_observables_map.begin()->second.TOW_at_current_symbol_ms;
// WEEK
@ -1067,7 +1008,6 @@ bool Rtklib_Solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
monitor_pvt.hdop = dop_[2];
monitor_pvt.vdop = dop_[3];
// ######## LOG FILE #########
if (d_flag_dump_enabled == true)
{

View File

@ -84,7 +84,7 @@
/*!
* \brief This class implements a simple PVT Least Squares solution
* \brief This class implements a PVT solution based on RTKLIB
*/
class Rtklib_Solver : public Pvt_Solution
{
@ -107,7 +107,7 @@ public:
bool get_PVT(const std::map<int, Gnss_Synchro>& gnss_observables_map, bool flag_averaging);
sol_t pvt_sol;
ssat_t pvt_ssat[MAXSAT];
std::array<ssat_t, MAXSAT> pvt_ssat;
double get_hdop() const;
double get_vdop() const;
double get_pdop() const;

View File

@ -39,6 +39,8 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
#include <memory>
BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition(
@ -90,7 +92,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition(
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -123,7 +125,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -135,10 +137,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition(
}
BeidouB1iPcpsAcquisition::~BeidouB1iPcpsAcquisition()
{
delete[] code_;
}
BeidouB1iPcpsAcquisition::~BeidouB1iPcpsAcquisition() = default;
void BeidouB1iPcpsAcquisition::stop_acquisition()
@ -204,18 +203,17 @@ void BeidouB1iPcpsAcquisition::init()
void BeidouB1iPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
beidou_b1i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
for (uint32_t i = 0; i < sampled_ms_; i++)
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}
@ -331,6 +329,7 @@ gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_right_block()
return acquisition_;
}
void BeidouB1iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples)
{
acquisition_->set_resampler_latency(latency_samples);

View File

@ -42,7 +42,9 @@
#include <gnuradio/blocks/stream_to_vector.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -100,15 +102,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -159,7 +160,6 @@ public:
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
ConfigurationInterface* configuration_;
pcps_acquisition_sptr acquisition_;
@ -183,12 +183,11 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
uint32_t in_streams_;
uint32_t out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -37,7 +37,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
using google::LogMessage;
@ -66,7 +66,10 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition(
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
if (FLAGS_doppler_max != 0)
{
doppler_max_ = FLAGS_doppler_max;
}
acq_parameters.doppler_max = doppler_max_;
sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1);
acq_parameters.sampled_ms = sampled_ms_;
@ -88,7 +91,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition(
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -121,7 +124,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -133,16 +136,14 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition(
}
BeidouB3iPcpsAcquisition::~BeidouB3iPcpsAcquisition()
{
delete[] code_;
}
BeidouB3iPcpsAcquisition::~BeidouB3iPcpsAcquisition() = default;
void BeidouB3iPcpsAcquisition::stop_acquisition()
{
}
void BeidouB3iPcpsAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + ".pfa", 0.0);
@ -201,18 +202,17 @@ void BeidouB3iPcpsAcquisition::init()
void BeidouB3iPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
beidou_b3i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -41,7 +41,9 @@
#include <gnuradio/blocks/stream_to_vector.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -99,15 +101,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -158,7 +159,6 @@ public:
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
ConfigurationInterface* configuration_;
pcps_acquisition_sptr acquisition_;
@ -182,12 +182,11 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition(
@ -86,7 +87,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition(
int samples_per_ms = code_length_ / 4;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -110,7 +111,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -122,10 +123,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition(
}
GalileoE1Pcps8msAmbiguousAcquisition::~GalileoE1Pcps8msAmbiguousAcquisition()
{
delete[] code_;
}
GalileoE1Pcps8msAmbiguousAcquisition::~GalileoE1Pcps8msAmbiguousAcquisition() = default;
void GalileoE1Pcps8msAmbiguousAcquisition::stop_acquisition()
@ -216,20 +214,20 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code()
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
std::array<char, 3> Signal_;
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal,
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_cc_->set_local_code(code_);
delete[] code;
acquisition_cc_->set_local_code(code_.data());
}
}
@ -242,6 +240,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::reset()
}
}
float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa)
{
unsigned int frequency_bins = 0;

View File

@ -36,7 +36,9 @@
#include "galileo_pcps_8ms_acquisition_cc.h"
#include "gnss_synchro.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -165,7 +167,7 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -37,6 +37,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
@ -126,7 +127,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -154,7 +155,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -166,16 +167,14 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
}
GalileoE1PcpsAmbiguousAcquisition::~GalileoE1PcpsAmbiguousAcquisition()
{
delete[] code_;
}
GalileoE1PcpsAmbiguousAcquisition::~GalileoE1PcpsAmbiguousAcquisition() = default;
void GalileoE1PcpsAmbiguousAcquisition::stop_acquisition()
{
}
void GalileoE1PcpsAmbiguousAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0);
@ -242,45 +241,47 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code()
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
gsl::span<std::complex<float>> code_span(code.get(), code_length_);
if (acquire_pilot_ == true)
{
//set local signal generator to Galileo E1 pilot component (1C)
char pilot_signal[3] = "1C";
std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}};
if (acq_parameters_.use_automatic_resampler)
{
galileo_e1_code_gen_complex_sampled(code, pilot_signal,
galileo_e1_code_gen_complex_sampled(code_span, pilot_signal,
cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false);
}
else
{
galileo_e1_code_gen_complex_sampled(code, pilot_signal,
galileo_e1_code_gen_complex_sampled(code_span, pilot_signal,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
}
}
else
{
std::array<char, 3> Signal_;
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
if (acq_parameters_.use_automatic_resampler)
{
galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal,
galileo_e1_code_gen_complex_sampled(code_span, Signal_,
cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false);
}
else
{
galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal,
galileo_e1_code_gen_complex_sampled(code_span, Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
}
}
gsl::span<gr_complex> code__span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{
memcpy(&(code_[i * code_length_]), code, sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code__span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -39,7 +39,9 @@
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -98,13 +100,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -153,10 +156,8 @@ public:
/*!
* \brief Sets the resampler latency to account it in the acquisition code delay estimation
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
ConfigurationInterface* configuration_;
Acq_Conf acq_parameters_;
@ -181,7 +182,7 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -40,9 +40,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <cstring> // for memcpy
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
// the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA
// expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking.
@ -108,11 +108,12 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
// compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT
auto* code = new std::complex<float>[nsamples_total]; // buffer for the local code
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_all_fft_codes_ = new uint32_t[(nsamples_total * GALILEO_E1_NUMBER_OF_CODES)]; // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E1_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
int32_t tmp, tmp2, local_code, fft_data;
for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++)
@ -122,14 +123,14 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
if (acquire_pilot_ == true)
{
//set local signal generator to Galileo E1 pilot component (1C)
char pilot_signal[3] = "1C";
galileo_e1_code_gen_complex_sampled(code, pilot_signal,
std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}};
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), pilot_signal,
cboc, PRN, fs_in, 0, false);
}
else
{
char data_signal[3] = "1B";
galileo_e1_code_gen_complex_sampled(code, data_signal,
std::array<char, 3> data_signal = {{'1', 'B', '\0'}};
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), data_signal,
cboc, PRN, fs_in, 0, false);
}
@ -144,7 +145,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
code[s] = std::complex<float>(0.0, 0.0);
}
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
@ -173,7 +174,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
}
}
acq_parameters.all_fft_codes = d_all_fft_codes_;
acq_parameters.all_fft_codes = d_all_fft_codes_.data();
acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4);
acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0);
@ -188,17 +189,12 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can delete
delete[] code;
delete fft_if;
delete[] fft_codes_padded;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
}
GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga()
{
delete[] d_all_fft_codes_;
}
GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() = default;
void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition()

View File

@ -37,7 +37,9 @@
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstddef> // for size_t
#include <memory>
#include <string>
#include <vector>
class Gnss_Synchro;
class ConfigurationInterface;
@ -97,8 +99,8 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
@ -165,8 +167,7 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
uint32_t* d_all_fft_codes_; // memory that contains all the code ffts
std::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
};
#endif /* GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ */

View File

@ -86,8 +86,8 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition
int samples_per_ms = code_length_ / 4;
code_data_ = new gr_complex[vector_length_];
code_pilot_ = new gr_complex[vector_length_];
code_data_ = std::vector<std::complex<float>>(vector_length_);
code_pilot_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -111,7 +111,7 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -123,11 +123,7 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition
}
GalileoE1PcpsCccwsrAmbiguousAcquisition::~GalileoE1PcpsCccwsrAmbiguousAcquisition()
{
delete[] code_data_;
delete[] code_pilot_;
}
GalileoE1PcpsCccwsrAmbiguousAcquisition::~GalileoE1PcpsCccwsrAmbiguousAcquisition() = default;
void GalileoE1PcpsCccwsrAmbiguousAcquisition::stop_acquisition()
@ -168,6 +164,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_step(unsigned int dopp
}
}
void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_gnss_synchro(
Gnss_Synchro* gnss_synchro)
{
@ -203,19 +200,17 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_local_code()
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);
char signal[3];
std::array<char, 3> signal = {{'1', 'B', '\0'}};
strcpy(signal, "1B");
galileo_e1_code_gen_complex_sampled(code_data_, signal,
galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_data_.data(), vector_length_), signal,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
strcpy(signal, "1C");
std::array<char, 3> signal_C = {{'1', 'C', '\0'}};
galileo_e1_code_gen_complex_sampled(code_pilot_, signal,
galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_pilot_.data(), vector_length_), signal_C,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
acquisition_cc_->set_local_code(code_data_, code_pilot_);
acquisition_cc_->set_local_code(code_data_.data(), code_pilot_.data());
}
}
@ -228,6 +223,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::reset()
}
}
void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_state(int state)
{
acquisition_cc_->set_state(state);

View File

@ -36,7 +36,9 @@
#include "gnss_synchro.h"
#include "pcps_cccwsr_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -94,13 +96,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of CCCWSR algorithm
*/
@ -153,7 +156,6 @@ private:
std::string item_type_;
unsigned int vector_length_;
unsigned int code_length_;
//unsigned int satellite_;
unsigned int channel_;
std::weak_ptr<ChannelFsm> channel_fsm_;
float threshold_;
@ -164,8 +166,8 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_data_;
std::complex<float>* code_pilot_;
std::vector<std::complex<float>> code_data_;
std::vector<std::complex<float>> code_pilot_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcquisition(
@ -114,7 +115,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui
dump_filename_ = configuration_->property(role + ".dump_filename",
default_dump_filename);
code_ = new gr_complex[code_length_];
code_ = std::vector<std::complex<float>>(code_length_);
LOG(INFO) << "Vector Length: " << vector_length_
<< ", Samples per ms: " << samples_per_ms
<< ", Folding factor: " << folding_factor_
@ -144,7 +145,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -156,10 +157,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui
}
GalileoE1PcpsQuickSyncAmbiguousAcquisition::~GalileoE1PcpsQuickSyncAmbiguousAcquisition()
{
delete[] code_;
}
GalileoE1PcpsQuickSyncAmbiguousAcquisition::~GalileoE1PcpsQuickSyncAmbiguousAcquisition() = default;
void GalileoE1PcpsQuickSyncAmbiguousAcquisition::stop_acquisition()
@ -250,23 +248,20 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code()
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
std::array<char, 3> Signal_;
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal,
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < (sampled_ms_ / (folding_factor_ * 4)); i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
// memcpy(code_, code,sizeof(gr_complex)*code_length_);
acquisition_cc_->set_local_code(code_);
delete[] code;
code = nullptr;
acquisition_cc_->set_local_code(code_.data());
}
}
@ -279,6 +274,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::reset()
}
}
void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_state(int state)
{
if (item_type_ == "gr_complex")

View File

@ -36,7 +36,9 @@
#include "gnss_synchro.h"
#include "pcps_quicksync_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -169,7 +171,7 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition(
@ -89,7 +90,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition(
int samples_per_ms = code_length_ / 4;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -114,7 +115,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -126,10 +127,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition(
}
GalileoE1PcpsTongAmbiguousAcquisition::~GalileoE1PcpsTongAmbiguousAcquisition()
{
delete[] code_;
}
GalileoE1PcpsTongAmbiguousAcquisition::~GalileoE1PcpsTongAmbiguousAcquisition() = default;
void GalileoE1PcpsTongAmbiguousAcquisition::stop_acquisition()
@ -220,20 +218,19 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code()
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);
auto* code = new std::complex<float>[code_length_];
galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal,
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
std::array<char, 3> Signal_;
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_cc_->set_local_code(code_);
delete[] code;
acquisition_cc_->set_local_code(code_.data());
}
}
@ -246,6 +243,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::reset()
}
}
void GalileoE1PcpsTongAmbiguousAcquisition::set_state(int state)
{
acquisition_cc_->set_state(state);

View File

@ -36,7 +36,9 @@
#include "gnss_synchro.h"
#include "pcps_tong_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -168,7 +170,7 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -42,6 +42,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
@ -93,8 +94,8 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
vector_length_ = code_length_ * sampled_ms_;
codeI_ = new gr_complex[vector_length_];
codeQ_ = new gr_complex[vector_length_];
codeI_ = std::vector<std::complex<float>>(vector_length_);
codeQ_ = std::vector<std::complex<float>>(vector_length_);
both_signal_components = false;
std::string sig_ = configuration_->property("Channel.signal", std::string("5X"));
@ -119,7 +120,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -131,11 +132,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
}
GalileoE5aNoncoherentIQAcquisitionCaf::~GalileoE5aNoncoherentIQAcquisitionCaf()
{
delete[] codeI_;
delete[] codeQ_;
}
GalileoE5aNoncoherentIQAcquisitionCaf::~GalileoE5aNoncoherentIQAcquisitionCaf() = default;
void GalileoE5aNoncoherentIQAcquisitionCaf::stop_acquisition()
@ -223,55 +220,51 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code()
{
if (item_type_ == "gr_complex")
{
auto* codeI = new std::complex<float>[code_length_];
auto* codeQ = new std::complex<float>[code_length_];
std::vector<std::complex<float>> codeI(code_length_);
std::vector<std::complex<float>> codeQ(code_length_);
if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X')
{
char a[3];
strcpy(a, "5I");
galileo_e5_a_code_gen_complex_sampled(codeI, a,
std::array<char, 3> a = {{'5', 'I', '\0'}};
galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI.data(), code_length_), a,
gnss_synchro_->PRN, fs_in_, 0);
strcpy(a, "5Q");
galileo_e5_a_code_gen_complex_sampled(codeQ, a,
std::array<char, 3> b = {{'5', 'Q', '\0'}};
galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeQ.data(), code_length_), b,
gnss_synchro_->PRN, fs_in_, 0);
}
else
{
galileo_e5_a_code_gen_complex_sampled(codeI, gnss_synchro_->Signal,
std::array<char, 3> signal_type_ = {{'5', 'X', '\0'}};
galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI.data(), code_length_), signal_type_,
gnss_synchro_->PRN, fs_in_, 0);
}
// WARNING: 3ms are coherently integrated. Secondary sequence (1,1,1)
// is generated, and modulated in the 'block'.
gsl::span<gr_complex> codeQ_span(codeQ_.data(), vector_length_);
gsl::span<gr_complex> codeI_span(codeI_.data(), vector_length_);
if (Zero_padding == 0) // if no zero_padding
{
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(codeI_[i * code_length_]), codeI,
sizeof(gr_complex) * code_length_);
std::copy_n(codeI.data(), code_length_, codeI_span.subspan(i * code_length_, code_length_).data());
if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X')
{
memcpy(&(codeQ_[i * code_length_]), codeQ,
sizeof(gr_complex) * code_length_);
std::copy_n(codeQ.data(), code_length_, codeQ_span.subspan(i * code_length_, code_length_).data());
}
}
}
else
{
// 1ms code + 1ms zero padding
memcpy(&(codeI_[0]), codeI,
sizeof(gr_complex) * code_length_);
std::copy_n(codeI.data(), code_length_, codeI_.data());
if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X')
{
memcpy(&(codeQ_[0]), codeQ,
sizeof(gr_complex) * code_length_);
std::copy_n(codeQ.data(), code_length_, codeQ_.data());
}
}
acquisition_cc_->set_local_code(codeI_, codeQ_);
delete[] codeI;
delete[] codeQ;
acquisition_cc_->set_local_code(codeI_.data(), codeQ_.data());
}
}

View File

@ -41,7 +41,9 @@
#include "channel_fsm.h"
#include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h"
#include "gnss_synchro.h"
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -95,13 +97,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -171,8 +174,8 @@ private:
std::string dump_filename_;
int Zero_padding;
int CAF_window_hz_;
std::complex<float>* codeI_;
std::complex<float>* codeQ_;
std::vector<std::complex<float>> codeI_;
std::vector<std::complex<float>> codeQ_;
bool both_signal_components;
Gnss_Synchro* gnss_synchro_;
std::string role_;

View File

@ -37,6 +37,7 @@
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr_complex.h>
#include <algorithm>
GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* configuration,
@ -123,7 +124,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con
code_length_ = static_cast<unsigned int>(std::round(static_cast<double>(fs_in_) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast<double>(GALILEO_E5A_CODE_LENGTH_CHIPS)));
vector_length_ = code_length_ * sampled_ms_;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -152,7 +153,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -164,10 +165,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con
}
GalileoE5aPcpsAcquisition::~GalileoE5aPcpsAcquisition()
{
delete[] code_;
}
GalileoE5aPcpsAcquisition::~GalileoE5aPcpsAcquisition() = default;
void GalileoE5aPcpsAcquisition::stop_acquisition()
@ -235,38 +233,39 @@ void GalileoE5aPcpsAcquisition::init()
void GalileoE5aPcpsAcquisition::set_local_code()
{
auto* code = new gr_complex[code_length_];
char signal_[3];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
std::array<char, 3> signal_;
signal_[0] = '5';
signal_[2] = '\0';
if (acq_iq_)
{
strcpy(signal_, "5X");
signal_[1] = 'X';
}
else if (acq_pilot_)
{
strcpy(signal_, "5Q");
signal_[1] = 'Q';
}
else
{
strcpy(signal_, "5I");
signal_[1] = 'I';
}
if (acq_parameters_.use_automatic_resampler)
{
galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0);
galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code.get(), code_length_), signal_, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0);
}
else
{
galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, fs_in_, 0);
galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code.get(), code_length_), signal_, gnss_synchro_->PRN, fs_in_, 0);
}
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(code_ + (i * code_length_), code, sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -35,7 +35,9 @@
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "pcps_acquisition.h"
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -86,13 +88,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -143,29 +146,23 @@ public:
/*!
* \brief Sets the resampler latency to account it in the acquisition code delay estimation
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
float calculate_threshold(float pfa);
ConfigurationInterface* configuration_;
pcps_acquisition_sptr acquisition_;
Acq_Conf acq_parameters_;
size_t item_size_;
std::string item_type_;
std::string dump_filename_;
std::string role_;
bool bit_transition_flag_;
bool dump_;
bool acq_pilot_;
bool use_CFAR_;
bool blocking_;
bool acq_iq_;
unsigned int vector_length_;
unsigned int code_length_;
unsigned int channel_;
@ -176,18 +173,10 @@ private:
unsigned int max_dwells_;
unsigned int in_streams_;
unsigned int out_streams_;
int64_t fs_in_;
float threshold_;
/*
std::complex<float>* codeI_;
std::complex<float>* codeQ_;
*/
gr_complex* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
};
#endif /* GALILEO_E5A_PCPS_ACQUISITION_H_ */

View File

@ -40,9 +40,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <cstring> // for strcpy, memcpy
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
// the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA
// expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking.
@ -109,32 +109,34 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
// compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT
auto* code = new std::complex<float>[nsamples_total]; // buffer for the local code
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_all_fft_codes_ = new uint32_t[(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES)]; // memory containing all the possible fft codes for PRN 0 to 32
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
int32_t tmp, tmp2, local_code, fft_data;
for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++)
{
char signal_[3];
std::array<char, 3> signal_;
signal_[0] = '5';
signal_[2] = '\0';
if (acq_iq_)
{
strcpy(signal_, "5X");
signal_[1] = 'X';
}
else if (acq_pilot_)
{
strcpy(signal_, "5Q");
signal_[1] = 'Q';
}
else
{
strcpy(signal_, "5I");
signal_[1] = 'I';
}
galileo_e5_a_code_gen_complex_sampled(code, signal_, PRN, fs_in, 0);
galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), signal_, PRN, fs_in, 0);
for (uint32_t s = code_length; s < 2 * code_length; s++)
{
@ -147,7 +149,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
code[s] = std::complex<float>(0.0, 0.0);
}
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
@ -175,7 +177,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
}
}
acq_parameters.all_fft_codes = d_all_fft_codes_;
acq_parameters.all_fft_codes = d_all_fft_codes_.data();
// reference for the FPGA FFT-IFFT attenuation factor
acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 13);
@ -190,17 +192,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can delete
delete[] code;
delete fft_if;
delete[] fft_codes_padded;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
}
GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga()
{
delete[] d_all_fft_codes_;
}
GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() = default;
void GalileoE5aPcpsAcquisitionFpga::stop_acquisition()

View File

@ -39,7 +39,9 @@
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstddef> // for size_t
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
class Gnss_Synchro;
class ConfigurationInterface;
@ -99,8 +101,8 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
@ -167,24 +169,19 @@ public:
private:
ConfigurationInterface* configuration_;
pcps_acquisition_fpga_sptr acquisition_fpga_;
std::string item_type_;
std::string dump_filename_;
std::string role_;
bool acq_pilot_;
bool acq_iq_;
uint32_t channel_;
std::weak_ptr<ChannelFsm> channel_fsm_;
uint32_t doppler_max_;
uint32_t doppler_step_;
unsigned int in_streams_;
unsigned int out_streams_;
Gnss_Synchro* gnss_synchro_;
uint32_t* d_all_fft_codes_; // memory that contains all the code ffts
std::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
};
#endif /* GNSS_SDR_GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ */

View File

@ -39,6 +39,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
@ -93,7 +94,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -125,7 +126,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -137,16 +138,14 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
}
GlonassL1CaPcpsAcquisition::~GlonassL1CaPcpsAcquisition()
{
delete[] code_;
}
GlonassL1CaPcpsAcquisition::~GlonassL1CaPcpsAcquisition() = default;
void GlonassL1CaPcpsAcquisition::stop_acquisition()
{
}
void GlonassL1CaPcpsAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + ".pfa", 0.0);
@ -206,18 +205,17 @@ void GlonassL1CaPcpsAcquisition::init()
void GlonassL1CaPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
glonass_l1_ca_code_gen_complex_sampled(code, /* gnss_synchro_->PRN,*/ fs_in_, 0);
glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -39,7 +39,9 @@
#include "gnss_synchro.h"
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -86,6 +88,7 @@ public:
* tracking blocks
*/
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override;
/*!
* \brief Set acquisition channel unique ID
*/
@ -96,13 +99,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -172,12 +176,11 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -38,6 +38,7 @@
#include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
@ -92,7 +93,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -124,7 +125,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -136,10 +137,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
}
GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition()
{
delete[] code_;
}
GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition() = default;
void GlonassL2CaPcpsAcquisition::stop_acquisition()
@ -206,18 +204,17 @@ void GlonassL2CaPcpsAcquisition::init()
void GlonassL2CaPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
glonass_l2_ca_code_gen_complex_sampled(code, /* gnss_synchro_->PRN,*/ fs_in_, 0);
glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -38,7 +38,9 @@
#include "gnss_synchro.h"
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -96,13 +98,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -172,12 +175,11 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -41,6 +41,8 @@
#include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
#include <gsl/gsl>
GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
@ -121,7 +123,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L1_CA_CODE_PERIOD * 1000.0);
vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1);
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -147,7 +149,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -159,16 +161,14 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
}
GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition()
{
delete[] code_;
}
GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition() = default;
void GpsL1CaPcpsAcquisition::stop_acquisition()
{
}
void GpsL1CaPcpsAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + ".pfa", 0.0);
@ -226,24 +226,23 @@ void GpsL1CaPcpsAcquisition::init()
void GpsL1CaPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
if (acq_parameters_.use_automatic_resampler)
{
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0);
}
else
{
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
}
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}

View File

@ -43,7 +43,9 @@
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -102,13 +104,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -157,10 +160,8 @@ public:
/*!
* \brief Sets the resampler latency to account it in the acquisition code delay estimation
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
ConfigurationInterface* configuration_;
pcps_acquisition_sptr acquisition_;
@ -184,12 +185,11 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -80,7 +80,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler(
//--- Find number of samples per spreading code -------------------------
vector_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
acq_parameters.samples_per_ms = vector_length_;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -97,7 +97,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -109,10 +109,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler(
}
GpsL1CaPcpsAcquisitionFineDoppler::~GpsL1CaPcpsAcquisitionFineDoppler()
{
delete[] code_;
}
GpsL1CaPcpsAcquisitionFineDoppler::~GpsL1CaPcpsAcquisitionFineDoppler() = default;
void GpsL1CaPcpsAcquisitionFineDoppler::stop_acquisition()
@ -163,8 +160,8 @@ void GpsL1CaPcpsAcquisitionFineDoppler::init()
void GpsL1CaPcpsAcquisitionFineDoppler::set_local_code()
{
gps_l1_ca_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_, 0);
acquisition_cc_->set_local_code(code_);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code_.data(), vector_length_), gnss_synchro_->PRN, fs_in_, 0);
acquisition_cc_->set_local_code(code_.data());
}

View File

@ -37,7 +37,9 @@
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "pcps_acquisition_fine_doppler_cc.h"
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -95,13 +97,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -161,7 +164,7 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -43,9 +43,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <cstring> // for memcpy
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#define NUM_PRNs 32
@ -103,17 +103,17 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
// compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true));
// allocate memory to compute all the PRNs and compute all the possible codes
auto* code = new std::complex<float>[nsamples_total]; // buffer for the local code
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)]; // memory containing all the possible fft codes for PRN 0 to 32
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max;
int32_t tmp, tmp2, local_code, fft_data;
// temporary maxima search
for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++)
{
gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), PRN, fs_in, 0); // generate PRN code
for (uint32_t s = code_length; s < 2 * code_length; s++)
{
@ -126,7 +126,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
code[s] = std::complex<float>(0.0, 0.0);
}
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
@ -154,8 +154,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
}
}
//acq_parameters
acq_parameters.all_fft_codes = d_all_fft_codes_;
// acq_parameters
acq_parameters.all_fft_codes = d_all_fft_codes_.data();
// reference for the FPGA FFT-IFFT attenuation factor
acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 10);
@ -169,18 +169,13 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
channel_ = 0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can delete
delete[] code;
delete fft_if;
delete[] fft_codes_padded;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
}
GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga()
{
delete[] d_all_fft_codes_;
}
GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() = default;
void GpsL1CaPcpsAcquisitionFpga::stop_acquisition()

View File

@ -41,7 +41,9 @@
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstddef> // for size_t
#include <string> // for string
#include <memory>
#include <string>
#include <vector>
class Gnss_Synchro;
class ConfigurationInterface;
@ -167,7 +169,7 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
uint32_t* d_all_fft_codes_; // memory that contains all the code ffts
std::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
};
#endif /* GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ */

View File

@ -70,7 +70,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition(
//--- Find number of samples per spreading code -------------------------
vector_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
code_ = new gr_complex[vector_length_];
code_ = std::make_shared<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -89,7 +89,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -101,10 +101,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition(
}
GpsL1CaPcpsAssistedAcquisition::~GpsL1CaPcpsAssistedAcquisition()
{
delete[] code_;
}
GpsL1CaPcpsAssistedAcquisition::~GpsL1CaPcpsAssistedAcquisition() = default;
void GpsL1CaPcpsAssistedAcquisition::stop_acquisition()
@ -154,8 +151,8 @@ void GpsL1CaPcpsAssistedAcquisition::init()
void GpsL1CaPcpsAssistedAcquisition::set_local_code()
{
gps_l1_ca_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_, 0);
acquisition_cc_->set_local_code(code_);
gps_l1_ca_code_gen_complex_sampled(gsl::span<gr_complex>(code_.get(), vector_length_), gnss_synchro_->PRN, fs_in_, 0);
acquisition_cc_->set_local_code(code_.get());
}
void GpsL1CaPcpsAssistedAcquisition::reset()

View File

@ -37,7 +37,9 @@
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "pcps_assisted_acquisition_cc.h"
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -95,13 +97,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -147,7 +150,6 @@ private:
size_t item_size_;
std::string item_type_;
unsigned int vector_length_;
//unsigned int satellite_;
unsigned int channel_;
std::weak_ptr<ChannelFsm> channel_fsm_;
float threshold_;
@ -159,7 +161,7 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::shared_ptr<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;

View File

@ -36,6 +36,7 @@
#include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
@ -59,7 +60,10 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated);
dump_ = configuration_->property(role + ".dump", false);
doppler_max_ = configuration->property(role + ".doppler_max", 5000);
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
if (FLAGS_doppler_max != 0)
{
doppler_max_ = FLAGS_doppler_max;
}
sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1);
bit_transition_flag_ = configuration_->property("Acquisition.bit_transition_flag", false);
@ -81,7 +85,7 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
vector_length_ = code_length_ * sampled_ms_;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -105,7 +109,7 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -117,16 +121,14 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
}
GpsL1CaPcpsOpenClAcquisition::~GpsL1CaPcpsOpenClAcquisition()
{
delete[] code_;
}
GpsL1CaPcpsOpenClAcquisition::~GpsL1CaPcpsOpenClAcquisition() = default;
void GpsL1CaPcpsOpenClAcquisition::stop_acquisition()
{
}
void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0);
@ -207,19 +209,17 @@ void GpsL1CaPcpsOpenClAcquisition::set_local_code()
{
if (item_type_ == "gr_complex")
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_cc_->set_local_code(code_);
delete[] code;
acquisition_cc_->set_local_code(code_.data());
}
}

View File

@ -36,7 +36,9 @@
#include "gnss_synchro.h"
#include "pcps_opencl_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -94,13 +96,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -169,12 +172,11 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -37,6 +37,7 @@
#include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition(
@ -104,7 +105,7 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition(
dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename);
int samples_per_ms = round(code_length_);
code_ = new gr_complex[code_length_]();
code_ = std::vector<std::complex<float>>(code_length_);
/*Object relevant information for debugging*/
LOG(INFO) << "Implementation: " << this->implementation()
<< ", Vector Length: " << vector_length_
@ -137,7 +138,7 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -149,16 +150,14 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition(
}
GpsL1CaPcpsQuickSyncAcquisition::~GpsL1CaPcpsQuickSyncAcquisition()
{
delete[] code_;
}
GpsL1CaPcpsQuickSyncAcquisition::~GpsL1CaPcpsQuickSyncAcquisition() = default;
void GpsL1CaPcpsQuickSyncAcquisition::stop_acquisition()
{
}
void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0);
@ -236,20 +235,17 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_local_code()
{
if (item_type_ == "gr_complex")
{
auto* code = new std::complex<float>[code_length_]();
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < (sampled_ms_ / folding_factor_); i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
//memcpy(code_, code,sizeof(gr_complex)*code_length_);
acquisition_cc_->set_local_code(code_);
delete[] code;
acquisition_cc_->set_local_code(code_.data());
}
}

View File

@ -38,7 +38,9 @@
#include "gnss_synchro.h"
#include "pcps_quicksync_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -96,13 +98,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -170,12 +173,11 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -36,6 +36,7 @@
#include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition(
@ -75,7 +76,7 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition(
vector_length_ = code_length_ * sampled_ms_;
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "gr_complex")
{
@ -99,7 +100,7 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -111,16 +112,14 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition(
}
GpsL1CaPcpsTongAcquisition::~GpsL1CaPcpsTongAcquisition()
{
delete[] code_;
}
GpsL1CaPcpsTongAcquisition::~GpsL1CaPcpsTongAcquisition() = default;
void GpsL1CaPcpsTongAcquisition::stop_acquisition()
{
}
void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold)
{
float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0);
@ -193,23 +192,22 @@ void GpsL1CaPcpsTongAcquisition::init()
//set_local_code();
}
void GpsL1CaPcpsTongAcquisition::set_local_code()
{
if (item_type_ == "gr_complex")
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_cc_->set_local_code(code_);
delete[] code;
acquisition_cc_->set_local_code(code_.data());
}
}

View File

@ -37,7 +37,9 @@
#include "gnss_synchro.h"
#include "pcps_tong_acquisition_cc.h"
#include <gnuradio/blocks/stream_to_vector.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -95,13 +97,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_cc_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of TONG algorithm
*/
@ -169,12 +172,11 @@ private:
int64_t fs_in_;
bool dump_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};

View File

@ -39,6 +39,7 @@
#include "gps_l2c_signal.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
@ -126,7 +127,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L2_M_PERIOD * 1000.0);
vector_length_ = acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms * (acq_parameters_.bit_transition_flag ? 2 : 1);
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
if (item_type_ == "cshort")
{
@ -151,7 +152,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
num_codes_ = acq_parameters_.sampled_ms / acq_parameters_.ms_per_code;
if (in_streams_ > 1)
{
@ -164,10 +165,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
}
GpsL2MPcpsAcquisition::~GpsL2MPcpsAcquisition()
{
delete[] code_;
}
GpsL2MPcpsAcquisition::~GpsL2MPcpsAcquisition() = default;
void GpsL2MPcpsAcquisition::stop_acquisition()
@ -239,27 +237,24 @@ void GpsL2MPcpsAcquisition::init()
void GpsL2MPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
if (acq_parameters_.use_automatic_resampler)
{
gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs);
gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs);
}
else
{
gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_);
gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, fs_in_);
}
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < num_codes_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}
@ -268,6 +263,7 @@ void GpsL2MPcpsAcquisition::reset()
acquisition_->set_active(true);
}
void GpsL2MPcpsAcquisition::set_state(int state)
{
acquisition_->set_state(state);

View File

@ -40,7 +40,9 @@
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -99,13 +101,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -154,10 +157,8 @@ public:
/*!
* \brief Sets the resampler latency to account it in the acquisition code delay estimation
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
ConfigurationInterface* configuration_;
pcps_acquisition_sptr acquisition_;
@ -180,13 +181,12 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
unsigned int num_codes_;
float calculate_threshold(float pfa);
};

View File

@ -42,9 +42,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <cstring> // for memcpy
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#define NUM_PRNs 32
#define QUANT_BITS_LOCAL_CODE 16
@ -102,24 +102,24 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
// compute all the GPS L2C PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
// allocate memory to compute all the PRNs and compute all the possible codes
auto* code = new std::complex<float>[nsamples_total]; // buffer for the local code
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
//d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32
d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)]; // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
int32_t tmp, tmp2, local_code, fft_data;
for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++)
{
gps_l2c_m_code_gen_complex_sampled(code, PRN, fs_in_);
gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), PRN, fs_in_);
// fill in zero padding
for (unsigned int s = code_length; s < nsamples_total; s++)
{
code[s] = std::complex<float>(0.0, 0.0);
}
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
@ -149,28 +149,22 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
}
}
acq_parameters.all_fft_codes = d_all_fft_codes_;
// temporary buffers that we can delete
delete[] code;
delete fft_if;
delete[] fft_codes_padded;
acq_parameters.all_fft_codes = d_all_fft_codes_.data();
acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters);
channel_ = 0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
threshold_ = 0.0;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
}
GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga()
{
delete[] d_all_fft_codes_;
}
GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga() = default;
void GpsL2MPcpsAcquisitionFpga::stop_acquisition()

View File

@ -39,7 +39,9 @@
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstddef> // for size_t
#include <memory> // for weak_ptr
#include <string> // for string
#include <vector>
class Gnss_Synchro;
class ConfigurationInterface;
@ -98,8 +100,8 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
@ -168,10 +170,7 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
uint32_t* d_all_fft_codes_; // memory that contains all the code ffts
//float calculate_threshold(float pfa);
std::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
};
#endif /* GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H_ */

View File

@ -39,6 +39,7 @@
#include "gps_l5_signal.h"
#include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h>
#include <algorithm>
GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
@ -133,7 +134,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L5I_PERIOD * 1000.0);
vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1);
code_ = new gr_complex[vector_length_];
code_ = std::vector<std::complex<float>>(vector_length_);
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
@ -147,7 +148,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
threshold_ = 0.0;
doppler_step_ = 0;
gnss_synchro_ = nullptr;
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";
@ -159,10 +160,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
}
GpsL5iPcpsAcquisition::~GpsL5iPcpsAcquisition()
{
delete[] code_;
}
GpsL5iPcpsAcquisition::~GpsL5iPcpsAcquisition() = default;
void GpsL5iPcpsAcquisition::stop_acquisition()
@ -230,28 +228,27 @@ void GpsL5iPcpsAcquisition::init()
acquisition_->init();
}
void GpsL5iPcpsAcquisition::set_local_code()
{
auto* code = new std::complex<float>[code_length_];
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
if (acq_parameters_.use_automatic_resampler)
{
gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs);
gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs);
}
else
{
gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_);
gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, fs_in_);
}
gsl::span<gr_complex> code_span(code_.data(), vector_length_);
for (unsigned int i = 0; i < num_codes_; i++)
{
memcpy(&(code_[i * code_length_]), code,
sizeof(gr_complex) * code_length_);
std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data());
}
acquisition_->set_local_code(code_);
delete[] code;
acquisition_->set_local_code(code_.data());
}
@ -260,6 +257,7 @@ void GpsL5iPcpsAcquisition::reset()
acquisition_->set_active(true);
}
void GpsL5iPcpsAcquisition::set_state(int state)
{
acquisition_->set_state(state);
@ -359,6 +357,7 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_right_block()
return acquisition_;
}
void GpsL5iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples)
{
acquisition_->set_resampler_latency(latency_samples);

View File

@ -31,8 +31,8 @@
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_
#define GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_
#ifndef GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_
#define GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_
#include "channel_fsm.h"
#include "complex_byte_to_float_x2.h"
@ -40,7 +40,9 @@
#include "pcps_acquisition.h"
#include <gnuradio/blocks/float_to_complex.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <memory>
#include <string>
#include <vector>
class ConfigurationInterface;
@ -99,13 +101,14 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
acquisition_->set_channel_fsm(channel_fsm);
}
/*!
* \brief Set statistics threshold of PCPS algorithm
*/
@ -154,7 +157,6 @@ public:
/*!
* \brief Sets the resampler latency to account it in the acquisition code delay estimation
*/
void set_resampler_latency(uint32_t latency_samples) override;
private:
@ -179,14 +181,13 @@ private:
bool dump_;
bool blocking_;
std::string dump_filename_;
std::complex<float>* code_;
std::vector<std::complex<float>> code_;
Gnss_Synchro* gnss_synchro_;
std::string role_;
unsigned int num_codes_;
unsigned int in_streams_;
unsigned int out_streams_;
float calculate_threshold(float pfa);
};
#endif /* GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_ */
#endif /* GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_ */

View File

@ -43,9 +43,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#include <cstring> // for memcpy
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
#define NUM_PRNs 32
@ -108,17 +108,17 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
// compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT
auto* code = new gr_complex[nsamples_total];
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total);
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)]; // memory containing all the possible fft codes for PRN 0 to 32
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
int32_t tmp, tmp2, local_code, fft_data;
for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++)
{
gps_l5i_code_gen_complex_sampled(code, PRN, fs_in);
gps_l5i_code_gen_complex_sampled(gsl::span<gr_complex>(code.data(), nsamples_total), PRN, fs_in);
for (uint32_t s = code_length; s < 2 * code_length; s++)
{
@ -130,7 +130,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
// fill in zero padding
code[s] = std::complex<float>(0.0, 0.0);
}
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
@ -158,7 +158,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
}
}
acq_parameters.all_fft_codes = d_all_fft_codes_;
acq_parameters.all_fft_codes = d_all_fft_codes_.data();
// reference for the FPGA FFT-IFFT attenuation factor
acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 13);
@ -173,18 +173,12 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can delete
delete[] code;
delete fft_if;
delete[] fft_codes_padded;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
}
GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga()
{
//delete[] code_;
delete[] d_all_fft_codes_;
}
GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() = default;
void GpsL5iPcpsAcquisitionFpga::stop_acquisition()

View File

@ -40,7 +40,9 @@
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstddef> // for size_t
#include <memory>
#include <string>
#include <vector>
class Gnss_Synchro;
class ConfigurationInterface;
@ -99,8 +101,8 @@ public:
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
* \brief Set channel fsm associated to this acquisition instance
*/
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
{
channel_fsm_ = channel_fsm;
@ -167,9 +169,7 @@ private:
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
uint32_t* d_all_fft_codes_; // memory that contains all the code ffts
std::vector<uint32_t> d_all_fft_codes_; // memory that contains all the code ffts
float calculate_threshold(float pfa);
};

View File

@ -145,10 +145,10 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit
}
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -210,9 +210,6 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi
}
}
delete d_fft_if;
delete d_ifft;
try
{
if (d_dump)

View File

@ -44,6 +44,7 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
@ -122,8 +123,8 @@ private:
gr_complex* d_fft_code_Q_A;
gr_complex* d_fft_code_Q_B;
gr_complex* d_inbuffer;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
float d_doppler_freq;

View File

@ -87,10 +87,10 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -123,9 +123,6 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc()
volk_gnsssdr_free(d_fft_code_B);
volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try
{
if (d_dump)

View File

@ -38,6 +38,7 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
@ -105,8 +106,8 @@ private:
uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_A;
gr_complex* d_fft_code_B;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -140,10 +140,10 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
d_input_signal = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
d_gnss_synchro = nullptr;
d_grid_doppler_wipeoffs = nullptr;
@ -237,8 +237,6 @@ pcps_acquisition::~pcps_acquisition()
volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_tmp_buffer);
volk_gnsssdr_free(d_input_signal);
delete d_ifft;
delete d_fft_if;
volk_gnsssdr_free(d_data_buffer);
if (d_cshort)
{
@ -450,7 +448,7 @@ void pcps_acquisition::send_positive_acquisition()
if (!d_channel_fsm.expired())
{
//the channel FSM is set, so, notify it directly the positive acquisition to minimize delays
// the channel FSM is set, so, notify it directly the positive acquisition to minimize delays
d_channel_fsm.lock()->Event_valid_acquisition();
}
else
@ -510,11 +508,11 @@ void pcps_acquisition::dump_results(int32_t effective_fft_size)
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);
matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 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);
matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_doppler_step, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
@ -552,7 +550,7 @@ void pcps_acquisition::dump_results(int32_t effective_fft_size)
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("num_dwells", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_num_noncoherent_integrations_counter, 0);
matvar = Mat_VarCreate("num_dwells", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_num_noncoherent_integrations_counter, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
@ -774,7 +772,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
}
if (acq_parameters.use_automatic_resampler)
{
//take into account the acquisition resampler ratio
// take into account the acquisition resampler ratio
d_gnss_synchro->Acq_delay_samples = static_cast<double>(std::fmod(static_cast<float>(indext), acq_parameters.samples_per_code)) * acq_parameters.resampler_ratio;
d_gnss_synchro->Acq_delay_samples -= static_cast<double>(acq_parameters.resampler_latency_samples); //account the resampler filter latency
d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
@ -832,7 +830,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
if (acq_parameters.use_automatic_resampler)
{
//take into account the acquisition resampler ratio
// take into account the acquisition resampler ratio
d_gnss_synchro->Acq_delay_samples = static_cast<double>(std::fmod(static_cast<float>(indext), acq_parameters.samples_per_code)) * acq_parameters.resampler_ratio;
d_gnss_synchro->Acq_delay_samples -= static_cast<double>(acq_parameters.resampler_latency_samples); //account the resampler filter latency
d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);

View File

@ -62,6 +62,7 @@
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <volk/volk_complex.h> // for lv_16sc_t
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
@ -138,8 +139,8 @@ private:
gr_complex* d_fft_codes;
gr_complex* d_data_buffer;
lv_16sc_t* d_data_buffer_sc;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
arma::fmat grid_;
arma::fmat narrow_grid_;

View File

@ -93,10 +93,10 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con
d_10_ms_buffer = static_cast<gr_complex *>(volk_gnsssdr_malloc(50 * d_samples_per_ms * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = conf_.dump;
@ -168,6 +168,7 @@ unsigned int pcps_acquisition_fine_doppler_cc::nextPowerOf2(unsigned int n)
return n;
}
void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_step)
{
d_doppler_step = doppler_step;
@ -208,8 +209,6 @@ pcps_acquisition_fine_doppler_cc::~pcps_acquisition_fine_doppler_cc()
volk_gnsssdr_free(d_fft_codes);
volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_10_ms_buffer);
delete d_ifft;
delete d_fft_if;
free_grid_memory();
}
@ -430,7 +429,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler()
//1. generate local code aligned with the acquisition code phase estimation
auto *code_replica = static_cast<gr_complex *>(volk_gnsssdr_malloc(signal_samples * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_fs_in, 0);
gps_l1_ca_code_gen_complex_sampled(gsl::span<gr_complex>(code_replica, signal_samples * sizeof(gr_complex)), d_gnss_synchro->PRN, d_fs_in, 0);
int shift_index = static_cast<int>(d_gnss_synchro->Acq_delay_samples);
@ -705,11 +704,11 @@ void pcps_acquisition_fine_doppler_cc::dump_results(int effective_fft_size)
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, &d_config_doppler_max, 0);
matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_config_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);
matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims, &d_doppler_step, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);

View File

@ -58,6 +58,7 @@
#include <gnuradio/gr_complex.h>
#include <cstdint>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
@ -109,8 +110,8 @@ private:
float** d_grid_data;
gr_complex** d_grid_doppler_wipeoffs;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
float d_doppler_freq;

View File

@ -82,10 +82,10 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc(
d_carrier = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -129,8 +129,6 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc()
{
volk_gnsssdr_free(d_carrier);
volk_gnsssdr_free(d_fft_codes);
delete d_ifft;
delete d_fft_if;
try
{
if (d_dump)

View File

@ -54,6 +54,7 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
@ -125,8 +126,8 @@ private:
float** d_grid_data;
gr_complex** d_grid_doppler_wipeoffs;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -97,10 +97,10 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -137,9 +137,6 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc()
volk_gnsssdr_free(d_correlation_minus);
volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try
{
if (d_dump)

View File

@ -43,6 +43,7 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
@ -100,8 +101,8 @@ private:
uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_data;
gr_complex* d_fft_code_pilot;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -131,10 +131,10 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc(
if (d_opencl != 0)
{
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
}
// For dumping samples into a file
@ -179,11 +179,6 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc()
clFFT_DestroyPlan(d_cl_fft_plan);
}
else
{
delete d_ifft;
delete d_fft_if;
}
try
{

View File

@ -123,8 +123,8 @@ private:
gr_complex** d_grid_doppler_wipeoffs;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -106,9 +106,9 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
d_code = new gr_complex[d_samples_per_code]();
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -122,7 +122,6 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
d_threshold = 0;
d_doppler_step = 0;
d_grid_doppler_wipeoffs = nullptr;
d_fft_if2 = nullptr;
d_gnss_synchro = nullptr;
d_code_phase = 0;
d_doppler_freq = 0;
@ -150,8 +149,6 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc()
volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_magnitude_folded);
delete d_ifft;
delete d_fft_if;
delete d_code;
delete d_possible_delay;
delete d_corr_output_f;

View File

@ -136,9 +136,8 @@ private:
gr_complex** d_grid_doppler_wipeoffs;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_fft_if2;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -113,10 +113,10 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc(
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
// Direct FFT
d_fft_if = new gr::fft::fft_complex(d_fft_size, true);
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
// Inverse FFT
d_ifft = new gr::fft::fft_complex(d_fft_size, false);
d_ifft = std::make_shared<gr::fft::fft_complex>(d_fft_size, false);
// For dumping samples into a file
d_dump = dump;
@ -134,6 +134,7 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc(
d_channel = 0;
}
pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc()
{
if (d_num_doppler_bins > 0)
@ -150,9 +151,6 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc()
volk_gnsssdr_free(d_fft_codes);
volk_gnsssdr_free(d_magnitude);
delete d_ifft;
delete d_fft_if;
try
{
if (d_dump)

View File

@ -121,8 +121,8 @@ private:
uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes;
float** d_grid_data;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;
uint32_t d_code_phase;
float d_doppler_freq;

View File

@ -92,6 +92,23 @@ else()
target_link_libraries(algorithms_libs PRIVATE Boost::filesystem Boost::system)
endif()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <span>
int main()
{ std::span<float> sv; }"
has_span
)
if(${has_span})
target_compile_definitions(algorithms_libs PUBLIC -DHAS_SPAN=1)
else()
target_include_directories(algorithms_libs
PUBLIC
${CMAKE_SOURCE_DIR}/src/algorithms/libs/gsl/include
)
endif()
target_link_libraries(algorithms_libs
PUBLIC
Armadillo::armadillo

View File

@ -34,7 +34,7 @@
auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift)
void beidou_b1i_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _chip_shift)
{
const uint32_t _code_length = 2046;
bool G1[_code_length];
@ -112,12 +112,12 @@ void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift)
}
void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift)
void beidou_b1i_code_gen_float(gsl::span<float> _dest, int32_t _prn, uint32_t _chip_shift)
{
uint32_t _code_length = 2046;
int32_t b1i_code_int[_code_length];
beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift);
beidou_b1i_code_gen_int(gsl::span<int32_t>(b1i_code_int, _code_length), _prn, _chip_shift);
for (uint32_t ii = 0; ii < _code_length; ++ii)
{
@ -126,16 +126,16 @@ void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift)
}
void beidou_b1i_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32_t _chip_shift)
void beidou_b1i_code_gen_complex(gsl::span<std::complex<float>> _dest, int32_t _prn, uint32_t _chip_shift)
{
uint32_t _code_length = 2046;
int32_t b1i_code_int[_code_length];
beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift);
beidou_b1i_code_gen_int(gsl::span<int32_t>(b1i_code_int, _code_length), _prn, _chip_shift);
for (uint32_t ii = 0; ii < _code_length; ++ii)
{
_dest[ii] = std::complex<float>(static_cast<float>(b1i_code_int[ii]), 0.0f);
_dest[ii] = std::complex<float>(static_cast<float>(b1i_code_int[ii]), 0.0F);
}
}
@ -143,7 +143,7 @@ void beidou_b1i_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint3
/*
* Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency
*/
void beidou_b1i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
void beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
std::complex<float> _code[2046];

View File

@ -36,20 +36,27 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//! Generates int32_t GPS L1 C/A code for the desired SV ID and code shift
void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift);
void beidou_b1i_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates float GPS L1 C/A code for the desired SV ID and code shift
void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift);
void beidou_b1i_code_gen_float(gsl::span<float> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency
void beidou_b1i_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32_t _chip_shift);
void beidou_b1i_code_gen_complex(gsl::span<std::complex<float>> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift
void beidou_b1i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
void beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
//! Generates complex GPS L1 C/A code for the desired SV ID and code shift
void beidou_b1i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
void beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
#endif /* BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ */

View File

@ -34,7 +34,7 @@
auto auxCeil = [](float x) { return static_cast<int>(static_cast<long>((x) + 1)); };
void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift)
void beidou_b3i_code_gen_int(gsl::span<int> _dest, signed int _prn, unsigned int _chip_shift)
{
const unsigned int _code_length = 10230;
bool G1[_code_length];
@ -113,7 +113,9 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi
// A simple error check
if ((prn_idx < 0) || (prn_idx > 63))
return;
{
return;
}
// Assign shifted G2 register based on prn number
G2_register = G2_register_shifted[prn_idx];
@ -170,7 +172,7 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi
}
void beidou_b3i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift)
void beidou_b3i_code_gen_float(gsl::span<float> _dest, signed int _prn, unsigned int _chip_shift)
{
unsigned int _code_length = 10230;
int b3i_code_int[10230];
@ -184,7 +186,7 @@ void beidou_b3i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip
}
void beidou_b3i_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift)
void beidou_b3i_code_gen_complex(gsl::span<std::complex<float>> _dest, signed int _prn, unsigned int _chip_shift)
{
unsigned int _code_length = 10230;
int b3i_code_int[10230];
@ -193,12 +195,12 @@ void beidou_b3i_code_gen_complex(std::complex<float>* _dest, signed int _prn, un
for (unsigned int ii = 0; ii < _code_length; ++ii)
{
_dest[ii] = std::complex<float>(static_cast<float>(b3i_code_int[ii]), 0.0f);
_dest[ii] = std::complex<float>(static_cast<float>(b3i_code_int[ii]), 0.0F);
}
}
void beidou_b3i_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift)
void beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, unsigned int _prn, int _fs, unsigned int _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
std::complex<float> _code[10230];

View File

@ -39,19 +39,26 @@
#include <array>
#include <algorithm>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//! Generates int BeiDou B3I code for the desired SV ID and code shift
void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift);
void beidou_b3i_code_gen_int(gsl::span<int> _dest, signed int _prn, unsigned int _chip_shift);
//! Generates float BeiDou B3I code for the desired SV ID and code shift
void beidou_b3i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift);
void beidou_b3i_code_gen_float(gsl::span<float> _dest, signed int _prn, unsigned int _chip_shift);
//! Generates complex BeiDou B3I code for the desired SV ID and code shift, and sampled to specific sampling frequency
void beidou_b3i_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift);
void beidou_b3i_code_gen_complex(gsl::span<std::complex<float>> _dest, signed int _prn, unsigned int _chip_shift);
//! Generates N complex BeiDou B3I codes for the desired SV ID and code shift
void beidou_b3i_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift, unsigned int _ncodes);
void beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, unsigned int _prn, int _fs, unsigned int _chip_shift, unsigned int _ncodes);
//! Generates complex BeiDou B3I code for the desired SV ID and code shift
void beidou_b3i_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift);
void beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, unsigned int _prn, int _fs, unsigned int _chip_shift);
#endif /* GNSS_SDR_BEIDOU_B3I_SIGNAL_PROCESSING_H_ */

View File

@ -34,12 +34,13 @@
#include "Galileo_E1.h"
#include "gnss_signal_processing.h"
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <memory>
#include <string>
void galileo_e1_code_gen_int(int* _dest, char _Signal[3], int32_t _prn)
void galileo_e1_code_gen_int(gsl::span<int> _dest, const std::array<char, 3>& _Signal, int32_t _prn)
{
std::string _galileo_signal = _Signal;
std::string _galileo_signal = _Signal.data();
int32_t prn = _prn - 1;
int32_t index = 0;
@ -53,7 +54,7 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], int32_t _prn)
{
for (char i : GALILEO_E1_B_PRIMARY_CODE[prn])
{
hex_to_binary_converter(&_dest[index], i);
hex_to_binary_converter(_dest.subspan(index, 4), i);
index += 4;
}
}
@ -61,17 +62,17 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], int32_t _prn)
{
for (char i : GALILEO_E1_C_PRIMARY_CODE[prn])
{
hex_to_binary_converter(&_dest[index], i);
hex_to_binary_converter(_dest.subspan(index, 4), i);
index += 4;
}
}
}
void galileo_e1_sinboc_11_gen_int(int* _dest, const int* _prn, uint32_t _length_out)
void galileo_e1_sinboc_11_gen_int(gsl::span<int> _dest, gsl::span<const int> _prn)
{
const uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS;
auto _period = static_cast<uint32_t>(_length_out / _length_in);
auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
for (uint32_t i = 0; i < _length_in; i++)
{
for (uint32_t j = 0; j < (_period / 2); j++)
@ -86,10 +87,10 @@ void galileo_e1_sinboc_11_gen_int(int* _dest, const int* _prn, uint32_t _length_
}
void galileo_e1_sinboc_61_gen_int(int* _dest, const int* _prn, uint32_t _length_out)
void galileo_e1_sinboc_61_gen_int(gsl::span<int> _dest, gsl::span<const int> _prn)
{
const uint32_t _length_in = GALILEO_E1_B_CODE_LENGTH_CHIPS;
auto _period = static_cast<uint32_t>(_length_out / _length_in);
auto _period = static_cast<uint32_t>(_dest.size() / _length_in);
for (uint32_t i = 0; i < _length_in; i++)
{
@ -105,9 +106,9 @@ void galileo_e1_sinboc_61_gen_int(int* _dest, const int* _prn, uint32_t _length_
}
void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn)
void galileo_e1_code_gen_sinboc11_float(gsl::span<float> _dest, const std::array<char, 3>& _Signal, uint32_t _prn)
{
std::string _galileo_signal = _Signal;
std::string _galileo_signal = _Signal.data();
const auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS);
int32_t primary_code_E1_chips[4092]; // _codeLength not accepted by Clang
galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip
@ -119,18 +120,20 @@ void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t
}
void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3])
void galileo_e1_gen_float(gsl::span<float> _dest, gsl::span<int> _prn, const std::array<char, 3>& _Signal)
{
std::string _galileo_signal = _Signal;
std::string _galileo_signal = _Signal.data();
const uint32_t _codeLength = 12 * GALILEO_E1_B_CODE_LENGTH_CHIPS;
const float alpha = sqrt(10.0 / 11.0);
const float beta = sqrt(1.0 / 11.0);
int32_t sinboc_11[12 * 4092] = {0}; // _codeLength not accepted by Clang
int32_t sinboc_61[12 * 4092] = {0};
gsl::span<int32_t> sinboc_11_(sinboc_11, _codeLength);
gsl::span<int32_t> sinboc_61_(sinboc_61, _codeLength);
galileo_e1_sinboc_11_gen_int(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip
galileo_e1_sinboc_61_gen_int(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip
galileo_e1_sinboc_11_gen_int(sinboc_11_, _prn); //generate sinboc(1,1) 12 samples per chip
galileo_e1_sinboc_61_gen_int(sinboc_61_, _prn); //generate sinboc(6,1) 12 samples per chip
if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2)
{
@ -151,12 +154,12 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3])
}
void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift,
bool _secondary_flag)
{
// This function is based on the GNU software GPS for MATLAB in Kay Borre's book
std::string _galileo_signal = _Signal;
std::string _galileo_signal = _Signal.data();
uint32_t _samplesPerCode;
const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz
auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS);
@ -167,73 +170,78 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
const uint32_t delay = ((static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS;
galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip
float* _signal_E1;
galileo_e1_code_gen_int(gsl::span<int32_t>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal, _prn); // generate Galileo E1 code, 1 sample per chip
_codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS;
_signal_E1 = new float[_codeLength];
std::unique_ptr<float> _signal_E1{new float[_codeLength]};
gsl::span<float> _signal_E1_span(_signal_E1, _codeLength);
if (_cboc == true)
{
galileo_e1_gen_float(_signal_E1, primary_code_E1_chips, _Signal); // generate cboc 12 samples per chip
galileo_e1_gen_float(_signal_E1_span, gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal); // generate cboc 12 samples per chip
}
else
{
auto* _signal_E1_int = static_cast<int32_t*>(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment()));
galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips, _codeLength); // generate sinboc(1,1) 2 samples per chip
gsl::span<int32_t> _signal_E1_int_span(_signal_E1_int, _codeLength);
galileo_e1_sinboc_11_gen_int(_signal_E1_int_span, gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS))); // generate sinboc(1,1) 2 samples per chip
for (uint32_t ii = 0; ii < _codeLength; ++ii)
{
_signal_E1[ii] = static_cast<float>(_signal_E1_int[ii]);
_signal_E1_span[ii] = static_cast<float>(_signal_E1_int_span[ii]);
}
volk_gnsssdr_free(_signal_E1_int);
}
if (_fs != _samplesPerChip * _codeFreqBasis)
{
auto* _resampled_signal = new float[_samplesPerCode];
std::unique_ptr<float> _resampled_signal{new float[_samplesPerCode]};
resampler(_signal_E1, _resampled_signal, _samplesPerChip * _codeFreqBasis, _fs,
_codeLength, _samplesPerCode); // resamples code to fs
resampler(gsl::span<float>(_signal_E1, _codeLength), gsl::span<float>(_resampled_signal, _samplesPerCode), _samplesPerChip * _codeFreqBasis, _fs); // resamples code to fs
delete[] _signal_E1;
_signal_E1 = _resampled_signal;
_signal_E1 = std::move(_resampled_signal);
}
uint32_t size_signal_E1 = _codeLength;
if (_fs != _samplesPerChip * _codeFreqBasis)
{
size_signal_E1 = _samplesPerCode;
}
gsl::span<float> _signal_E1_span_aux(_signal_E1, size_signal_E1);
if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag)
{
auto* _signal_E1C_secondary = new float[static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode];
std::unique_ptr<float> _signal_E1C_secondary{new float[static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]};
gsl::span<float> _signal_E1C_secondary_span(_signal_E1C_secondary, static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode);
for (uint32_t i = 0; i < static_cast<uint32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); i++)
{
for (unsigned k = 0; k < _samplesPerCode; k++)
{
_signal_E1C_secondary[i * _samplesPerCode + k] = _signal_E1[k] * (GALILEO_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f);
_signal_E1C_secondary_span[i * _samplesPerCode + k] = _signal_E1_span_aux[k] * (GALILEO_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0F : -1.0F);
}
}
_samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH);
delete[] _signal_E1;
_signal_E1 = _signal_E1C_secondary;
_signal_E1 = std::move(_signal_E1C_secondary);
}
if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag)
{
size_signal_E1 = static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode;
}
gsl::span<float> _signal_E1_span_aux2(_signal_E1, size_signal_E1);
for (uint32_t i = 0; i < _samplesPerCode; i++)
{
_dest[(i + delay) % _samplesPerCode] = _signal_E1[i];
_dest[(i + delay) % _samplesPerCode] = _signal_E1_span_aux2[i];
}
delete[] _signal_E1;
volk_gnsssdr_free(primary_code_E1_chips);
}
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift,
bool _secondary_flag)
{
std::string _galileo_signal = _Signal;
std::string _galileo_signal = _Signal.data();
const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz
auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) /
(static_cast<double>(_codeFreqBasis) / static_cast<double>(GALILEO_E1_B_CODE_LENGTH_CHIPS)));
@ -244,25 +252,25 @@ void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signa
}
auto* real_code = static_cast<float*>(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment()));
galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag);
gsl::span<float> real_code_span(real_code, _samplesPerCode);
galileo_e1_code_gen_float_sampled(real_code_span, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag);
for (uint32_t ii = 0; ii < _samplesPerCode; ++ii)
{
_dest[ii] = std::complex<float>(real_code[ii], 0.0f);
_dest[ii] = std::complex<float>(real_code_span[ii], 0.0F);
}
volk_gnsssdr_free(real_code);
}
void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
galileo_e1_code_gen_float_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false);
}
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false);

View File

@ -32,21 +32,29 @@
#ifndef GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_
#define GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_
#include <array>
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
/*!
* \brief This function generates Galileo E1 code (can select E1B or E1C sinboc).
*
*/
void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn);
void galileo_e1_code_gen_sinboc11_float(gsl::span<float> _dest, const std::array<char, 3>& _Signal, uint32_t _prn);
/*!
* \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc
* and the sample frequency _fs).
*
*/
void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift,
bool _secondary_flag);
@ -55,7 +63,7 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
* and the sample frequency _fs).
*
*/
void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
/*!
@ -63,14 +71,14 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
* and the sample frequency _fs).
*
*/
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift,
bool _secondary_flag);
/*!
* \brief galileo_e1_code_gen_complex_sampled without _secondary_flag for backward compatibility.
*/
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
#endif /* GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ */

View File

@ -35,9 +35,10 @@
#include "Galileo_E5a.h"
#include "gnss_signal_processing.h"
#include <gnuradio/gr_complex.h>
#include <memory>
void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, int32_t _prn, const char _Signal[3])
void galileo_e5_a_code_gen_complex_primary(gsl::span<std::complex<float>> _dest, int32_t _prn, const std::array<char, 3>& _Signal)
{
uint32_t prn = _prn - 1;
uint32_t index = 0;
@ -100,7 +101,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, int32_t _
}
void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, const std::array<char, 3>& _Signal,
uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
uint32_t _samplesPerCode;
@ -108,9 +109,9 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
const uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS;
const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_HZ;
auto* _code = new std::complex<float>[_codeLength]();
galileo_e5_a_code_gen_complex_primary(_code, _prn, _Signal);
std::unique_ptr<std::complex<float>> _code{new std::complex<float>[_codeLength]};
gsl::span<std::complex<float>> _code_span(_code, _codeLength);
galileo_e5_a_code_gen_complex_primary(_code_span, _prn, _Signal);
_samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
@ -118,25 +119,18 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
if (_fs != _codeFreqBasis)
{
std::complex<float>* _resampled_signal;
if (posix_memalign(reinterpret_cast<void**>(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0)
{
};
resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); // resamples code to fs
delete[] _code;
_code = _resampled_signal;
}
for (uint32_t i = 0; i < _samplesPerCode; i++)
{
_dest[(i + delay) % _samplesPerCode] = _code[i];
std::unique_ptr<std::complex<float>> _resampled_signal{new std::complex<float>[_samplesPerCode]};
resampler(_code_span, gsl::span<std::complex<float>>(_resampled_signal, _samplesPerCode), _codeFreqBasis, _fs); // resamples code to fs
_code = std::move(_resampled_signal);
}
uint32_t size_code = _codeLength;
if (_fs != _codeFreqBasis)
{
free(_code);
size_code = _samplesPerCode;
}
else
gsl::span<std::complex<float>> _code_span_aux(_code, size_code);
for (uint32_t i = 0; i < _samplesPerCode; i++)
{
delete[] _code;
_dest[(i + delay) % _samplesPerCode] = _code_span_aux[i];
}
}

View File

@ -36,22 +36,27 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
/*!
* \brief Generates Galileo E5a code at 1 sample/chip
* bool _pilot generates E5aQ code if true and E5aI (data signal) if false.
*/
void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, int32_t _prn, const char _Signal[3]);
void galileo_e5_a_code_gen_tiered(std::complex<float>* _dest, std::complex<float>* _primary, uint32_t _prn, char _Signal[3]);
void galileo_e5_a_code_gen_complex_primary(gsl::span<std::complex<float>> _dest, int32_t _prn, const std::array<char, 3>& _Signal);
/*!
* \brief Generates Galileo E5a complex code, shifted to the desired chip and sampled at a frequency fs
* bool _pilot generates E5aQ code if true and E5aI (data signal) if false.
*/
void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest,
char _Signal[3], uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest,
const std::array<char, 3>& _Signal, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
#endif /* GNSS_SDR_GALILEO_E5_SIGNAL_PROCESSING_H_ */

View File

@ -34,7 +34,7 @@
auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
void glonass_l1_ca_code_gen_complex(std::complex<float>* _dest, /* int32_t _prn,*/ uint32_t _chip_shift)
void glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t _prn,*/ uint32_t _chip_shift)
{
const uint32_t _code_length = 511;
bool G1[_code_length];
@ -104,7 +104,7 @@ void glonass_l1_ca_code_gen_complex(std::complex<float>* _dest, /* int32_t _prn
/*
* Generates complex GLONASS L1 C/A code for the desired SV ID and sampled to specific sampling frequency
*/
void glonass_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift)
void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
std::complex<float> _code[511];
@ -119,9 +119,9 @@ void glonass_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint3
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength));
//--- Find time constants --------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
_tc = 1.0 / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
glonass_l1_ca_code_gen_complex(_code, _chip_shift); //generate C/A code 1 sample per chip
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
_tc = 1.0 / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>>(_code, 511), _chip_shift); //generate C/A code 1 sample per chip
for (int32_t i = 0; i < _samplesPerCode; i++)
{

View File

@ -36,13 +36,20 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//!Generates complex GLONASS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency
void glonass_l1_ca_code_gen_complex(std::complex<float>* _dest, /*int32_t _prn,*/ uint32_t _chip_shift);
void glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /*int32_t _prn,*/ uint32_t _chip_shift);
//! Generates N complex GLONASS L1 C/A codes for the desired SV ID and code shift
void glonass_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
//! Generates complex GLONASS L1 C/A code for the desired SV ID and code shift
void glonass_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift);
void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift);
#endif /* GNSS_SDR_GLONASS_SDR_SIGNAL_PROCESSING_H_ */

View File

@ -34,7 +34,7 @@
auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
void glonass_l2_ca_code_gen_complex(std::complex<float>* _dest, /* int32_t _prn,*/ uint32_t _chip_shift)
void glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t _prn,*/ uint32_t _chip_shift)
{
const uint32_t _code_length = 511;
bool G1[_code_length];
@ -104,7 +104,7 @@ void glonass_l2_ca_code_gen_complex(std::complex<float>* _dest, /* int32_t _prn,
/*
* Generates complex GLONASS L2 C/A code for the desired SV ID and sampled to specific sampling frequency
*/
void glonass_l2_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift)
void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
std::complex<float> _code[511];
@ -119,9 +119,9 @@ void glonass_l2_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint3
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength));
//--- Find time constants --------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
_tc = 1.0 / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
glonass_l2_ca_code_gen_complex(_code, _chip_shift); //generate C/A code 1 sample per chip
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
_tc = 1.0 / static_cast<float>(_codeFreqBasis); // C/A chip period in sec
glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>>(_code, 511), _chip_shift); //generate C/A code 1 sample per chip
for (int32_t i = 0; i < _samplesPerCode; i++)
{

View File

@ -36,13 +36,20 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//!Generates complex GLONASS L2 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency
void glonass_l2_ca_code_gen_complex(std::complex<float>* _dest, /*int32_t _prn,*/ uint32_t _chip_shift);
void glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /*int32_t _prn,*/ uint32_t _chip_shift);
//! Generates N complex GLONASS L2 C/A codes for the desired SV ID and code shift
void glonass_l2_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
//! Generates complex GLONASS L2 C/A code for the desired SV ID and code shift
void glonass_l2_ca_code_gen_complex_sampled(std::complex<float>* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift);
void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift);
#endif /* GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ */

View File

@ -38,135 +38,135 @@
auto auxCeil2 = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, uint32_t _samps)
void complex_exp_gen(gsl::span<std::complex<float>> _dest, double _f, double _fs)
{
gr::fxpt_nco d_nco;
d_nco.set_freq((GPS_TWO_PI * _f) / _fs);
d_nco.sincos(_dest, _samps, 1);
d_nco.sincos(_dest.data(), _dest.size(), 1);
}
void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, uint32_t _samps)
void complex_exp_gen_conj(gsl::span<std::complex<float>> _dest, double _f, double _fs)
{
gr::fxpt_nco d_nco;
d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs);
d_nco.sincos(_dest, _samps, 1);
d_nco.sincos(_dest.data(), _dest.size(), 1);
}
void hex_to_binary_converter(int32_t* _dest, char _from)
void hex_to_binary_converter(gsl::span<int32_t> _dest, char _from)
{
switch (_from)
{
case '0':
*(_dest) = 1;
*(_dest + 1) = 1;
*(_dest + 2) = 1;
*(_dest + 3) = 1;
_dest[0] = 1;
_dest[1] = 1;
_dest[2] = 1;
_dest[3] = 1;
break;
case '1':
*(_dest) = 1;
*(_dest + 1) = 1;
*(_dest + 2) = 1;
*(_dest + 3) = -1;
_dest[0] = 1;
_dest[1] = 1;
_dest[2] = 1;
_dest[3] = -1;
break;
case '2':
*(_dest) = 1;
*(_dest + 1) = 1;
*(_dest + 2) = -1;
*(_dest + 3) = 1;
_dest[0] = 1;
_dest[1] = 1;
_dest[2] = -1;
_dest[3] = 1;
break;
case '3':
*(_dest) = 1;
*(_dest + 1) = 1;
*(_dest + 2) = -1;
*(_dest + 3) = -1;
_dest[0] = 1;
_dest[1] = 1;
_dest[2] = -1;
_dest[3] = -1;
break;
case '4':
*(_dest) = 1;
*(_dest + 1) = -1;
*(_dest + 2) = 1;
*(_dest + 3) = 1;
_dest[0] = 1;
_dest[1] = -1;
_dest[2] = 1;
_dest[3] = 1;
break;
case '5':
*(_dest) = 1;
*(_dest + 1) = -1;
*(_dest + 2) = 1;
*(_dest + 3) = -1;
_dest[0] = 1;
_dest[1] = -1;
_dest[2] = 1;
_dest[3] = -1;
break;
case '6':
*(_dest) = 1;
*(_dest + 1) = -1;
*(_dest + 2) = -1;
*(_dest + 3) = 1;
_dest[0] = 1;
_dest[1] = -1;
_dest[2] = -1;
_dest[3] = 1;
break;
case '7':
*(_dest) = 1;
*(_dest + 1) = -1;
*(_dest + 2) = -1;
*(_dest + 3) = -1;
_dest[0] = 1;
_dest[1] = -1;
_dest[2] = -1;
_dest[3] = -1;
break;
case '8':
*(_dest) = -1;
*(_dest + 1) = 1;
*(_dest + 2) = 1;
*(_dest + 3) = 1;
_dest[0] = -1;
_dest[1] = 1;
_dest[2] = 1;
_dest[3] = 1;
break;
case '9':
*(_dest) = -1;
*(_dest + 1) = 1;
*(_dest + 2) = 1;
*(_dest + 3) = -1;
_dest[0] = -1;
_dest[1] = 1;
_dest[2] = 1;
_dest[3] = -1;
break;
case 'A':
*(_dest) = -1;
*(_dest + 1) = 1;
*(_dest + 2) = -1;
*(_dest + 3) = 1;
_dest[0] = -1;
_dest[1] = 1;
_dest[2] = -1;
_dest[3] = 1;
break;
case 'B':
*(_dest) = -1;
*(_dest + 1) = 1;
*(_dest + 2) = -1;
*(_dest + 3) = -1;
_dest[0] = -1;
_dest[1] = 1;
_dest[2] = -1;
_dest[3] = -1;
break;
case 'C':
*(_dest) = -1;
*(_dest + 1) = -1;
*(_dest + 2) = 1;
*(_dest + 3) = 1;
_dest[0] = -1;
_dest[1] = -1;
_dest[2] = 1;
_dest[3] = 1;
break;
case 'D':
*(_dest) = -1;
*(_dest + 1) = -1;
*(_dest + 2) = 1;
*(_dest + 3) = -1;
_dest[0] = -1;
_dest[1] = -1;
_dest[2] = 1;
_dest[3] = -1;
break;
case 'E':
*(_dest) = -1;
*(_dest + 1) = -1;
*(_dest + 2) = -1;
*(_dest + 3) = 1;
_dest[0] = -1;
_dest[1] = -1;
_dest[2] = -1;
_dest[3] = 1;
break;
case 'F':
*(_dest) = -1;
*(_dest + 1) = -1;
*(_dest + 2) = -1;
*(_dest + 3) = -1;
_dest[0] = -1;
_dest[1] = -1;
_dest[2] = -1;
_dest[3] = -1;
break;
}
}
void resampler(const float* _from, float* _dest, float _fs_in,
float _fs_out, uint32_t _length_in, uint32_t _length_out)
void resampler(const gsl::span<float> _from, gsl::span<float> _dest, float _fs_in,
float _fs_out)
{
uint32_t _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
for (uint32_t i = 0; i < _length_out - 1; i++)
for (uint32_t i = 0; i < _dest.size() - 1; i++)
{
//=== Digitizing =======================================================
//--- compute index array to read sampled values -------------------------
@ -178,19 +178,19 @@ void resampler(const float* _from, float* _dest, float _fs_in,
_dest[i] = _from[_codeValueIndex];
}
//--- Correct the last index (due to number rounding issues) -----------
_dest[_length_out - 1] = _from[_length_in - 1];
_dest[_dest.size() - 1] = _from[_from.size() - 1];
}
void resampler(const std::complex<float>* _from, std::complex<float>* _dest, float _fs_in,
float _fs_out, uint32_t _length_in, uint32_t _length_out)
void resampler(gsl::span<const std::complex<float>> _from, gsl::span<std::complex<float>> _dest, float _fs_in,
float _fs_out)
{
uint32_t _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
for (uint32_t i = 0; i < _length_out - 1; i++)
for (uint32_t i = 0; i < _dest.size() - 1; i++)
{
//=== Digitizing =======================================================
//--- compute index array to read sampled values -------------------------
@ -202,5 +202,5 @@ void resampler(const std::complex<float>* _from, std::complex<float>* _dest, flo
_dest[i] = _from[_codeValueIndex];
}
//--- Correct the last index (due to number rounding issues) -----------
_dest[_length_out - 1] = _from[_length_in - 1];
_dest[_dest.size() - 1] = _from[_from.size() - 1];
}

View File

@ -38,42 +38,45 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
/*!
* \brief This function generates a complex exponential in _dest.
*
*/
void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs,
uint32_t _samps);
void complex_exp_gen(gsl::span<std::complex<float>> _dest, double _f, double _fs);
/*!
* \brief This function generates a conjugate complex exponential in _dest.
*
*/
void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs,
uint32_t _samps);
void complex_exp_gen_conj(gsl::span<std::complex<float>> _dest, double _f, double _fs);
/*!
* \brief This function makes a conversion from hex (the input is a char)
* to binary (the output are 4 ints with +1 or -1 values).
*
*/
void hex_to_binary_converter(int32_t* _dest, char _from);
void hex_to_binary_converter(gsl::span<int32_t> _dest, char _from);
/*!
* \brief This function resamples a sequence of float values.
*
*/
void resampler(const float* _from, float* _dest,
float _fs_in, float _fs_out, uint32_t _length_in,
uint32_t _length_out);
void resampler(const gsl::span<float> _from, gsl::span<float> _dest,
float _fs_in, float _fs_out);
/*!
* \brief This function resamples a sequence of complex values.
*
*/
void resampler(const std::complex<float>* _from, std::complex<float>* _dest,
float _fs_in, float _fs_out, uint32_t _length_in,
uint32_t _length_out);
void resampler(gsl::span<const std::complex<float>> _from, gsl::span<std::complex<float>> _dest,
float _fs_in, float _fs_out);
#endif /* GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ */

View File

@ -33,6 +33,7 @@
#include "gps_l2c_signal.h"
#include "GPS_L2C.h"
#include <cmath>
#include <memory>
int32_t gps_l2c_m_shift(int32_t x)
@ -41,7 +42,7 @@ int32_t gps_l2c_m_shift(int32_t x)
}
void gps_l2c_m_code(int32_t* _dest, uint32_t _prn)
void gps_l2c_m_code(gsl::span<int32_t> _dest, uint32_t _prn)
{
int32_t x;
x = GPS_L2C_M_INIT_REG[_prn - 1];
@ -53,51 +54,48 @@ void gps_l2c_m_code(int32_t* _dest, uint32_t _prn)
}
void gps_l2c_m_code_gen_complex(std::complex<float>* _dest, uint32_t _prn)
void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
gps_l2c_m_code(_code, _prn);
gps_l2c_m_code(_code_span, _prn);
}
for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
}
delete[] _code;
}
void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn)
void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
gps_l2c_m_code(_code, _prn);
gps_l2c_m_code(_code_span, _prn);
}
for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
}
delete[] _code;
}
/*
* Generates complex GPS L2C M code for the desired SV ID and sampled to specific sampling frequency
*/
void gps_l2c_m_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs)
void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs)
{
auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
gps_l2c_m_code(_code, _prn);
gps_l2c_m_code(_code_span, _prn);
}
int32_t _samplesPerCode, _codeValueIndex;
@ -112,27 +110,22 @@ void gps_l2c_m_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _pr
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
_tc = 1.0 / static_cast<float>(GPS_L2_M_CODE_RATE_HZ); // C/A chip period in sec
//float aux;
for (int32_t i = 0; i < _samplesPerCode; i++)
{
//=== Digitizing =======================================================
//--- Make index array to read L2C code values -------------------------
//TODO: Check this formula! Seems to start with an extra sample
_codeValueIndex = std::ceil((_ts * (static_cast<float>(i) + 1)) / _tc) - 1;
//aux = (_ts * (i + 1)) / _tc;
//_codeValueIndex = static_cast<int32_t>(static_cast<long>(aux)) - 1;
//--- Make the digitized version of the L2C code -----------------------
if (i == _samplesPerCode - 1)
{
//--- Correct the last index (due to number rounding issues) -----------
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0);
}
else
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0); //repeat the chip -> upsample
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0); //repeat the chip -> upsample
}
}
delete[] _code;
}

View File

@ -36,12 +36,19 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//! Generates complex GPS L2C M code for the desired SV ID
void gps_l2c_m_code_gen_complex(std::complex<float>* _dest, uint32_t _prn);
void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn);
void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn);
void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn);
//! Generates complex GPS L2C M code for the desired SV ID, and sampled to specific sampling frequency
void gps_l2c_m_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs);
void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs);
#endif /* GNSS_GPS_L2C_SIGNAL_H_ */

View File

@ -131,7 +131,7 @@ std::deque<bool> make_l5q_xb()
}
void make_l5i(int32_t* _dest, int32_t prn)
void make_l5i(gsl::span<int32_t> _dest, int32_t prn)
{
int32_t xb_offset = GPS_L5I_INIT_REG[prn];
@ -151,7 +151,7 @@ void make_l5i(int32_t* _dest, int32_t prn)
}
void make_l5q(int32_t* _dest, int32_t prn)
void make_l5q(gsl::span<int32_t> _dest, int32_t prn)
{
int32_t xb_offset = GPS_L5Q_INIT_REG[prn];
@ -171,51 +171,48 @@ void make_l5q(int32_t* _dest, int32_t prn)
}
void gps_l5i_code_gen_complex(std::complex<float>* _dest, uint32_t _prn)
void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5i(_code, _prn - 1);
make_l5i(_code_span, _prn - 1);
}
for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
}
delete[] _code;
}
void gps_l5i_code_gen_float(float* _dest, uint32_t _prn)
void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5i(_code, _prn - 1);
make_l5i(_code_span, _prn - 1);
}
for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
}
delete[] _code;
}
/*
* Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency
*/
void gps_l5i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs)
void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs)
{
auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5i(_code, _prn - 1);
make_l5i(_code_span, _prn - 1);
}
int32_t _samplesPerCode, _codeValueIndex;
@ -241,62 +238,58 @@ void gps_l5i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn,
if (i == _samplesPerCode - 1)
{
//--- Correct the last index (due to number rounding issues) -----------
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0.0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0);
}
else
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0.0); // repeat the chip -> upsample
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0); // repeat the chip -> upsample
}
}
delete[] _code;
}
void gps_l5q_code_gen_complex(std::complex<float>* _dest, uint32_t _prn)
void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5q(_code, _prn - 1);
make_l5q(_code_span, _prn - 1);
}
for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
}
delete[] _code;
}
void gps_l5q_code_gen_float(float* _dest, uint32_t _prn)
void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn)
{
auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5q(_code, _prn - 1);
make_l5q(_code_span, _prn - 1);
}
for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++)
{
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
}
delete[] _code;
}
/*
* Generates complex GPS L5Q code for the desired SV ID and sampled to specific sampling frequency
*/
void gps_l5q_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs)
void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs)
{
auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS];
std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]};
gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS);
if (_prn > 0 and _prn < 51)
{
make_l5q(_code, _prn - 1);
make_l5q(_code_span, _prn - 1);
}
int32_t _samplesPerCode, _codeValueIndex;
@ -323,12 +316,11 @@ void gps_l5q_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn,
if (i == _samplesPerCode - 1)
{
//--- Correct the last index (due to number rounding issues) -----------
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0);
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0);
}
else
{
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0); // repeat the chip -> upsample
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0); // repeat the chip -> upsample
}
}
delete[] _code;
}

View File

@ -36,23 +36,30 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//! Generates complex GPS L5I code for the desired SV ID
void gps_l5i_code_gen_complex(std::complex<float>* _dest, uint32_t _prn);
void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn);
//! Generates real GPS L5I code for the desired SV ID
void gps_l5i_code_gen_float(float* _dest, uint32_t _prn);
void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn);
//! Generates complex GPS L5Q code for the desired SV ID
void gps_l5q_code_gen_complex(std::complex<float>* _dest, uint32_t _prn);
void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn);
//! Generates real GPS L5Q code for the desired SV ID
void gps_l5q_code_gen_float(float* _dest, uint32_t _prn);
void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn);
//! Generates complex GPS L5I code for the desired SV ID, and sampled to specific sampling frequency
void gps_l5i_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs);
void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs);
//! Generates complex GPS L5Q code for the desired SV ID, and sampled to specific sampling frequency
void gps_l5q_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs);
void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs);
#endif /* GNSS_SDR_GPS_L5_SIGNAL_H_ */

View File

@ -34,7 +34,7 @@
auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift)
void gps_l1_ca_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _chip_shift)
{
const uint32_t _code_length = 1023;
bool G1[_code_length];
@ -116,7 +116,7 @@ void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift)
}
void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift)
void gps_l1_ca_code_gen_float(gsl::span<float> _dest, int32_t _prn, uint32_t _chip_shift)
{
const uint32_t _code_length = 1023;
int32_t ca_code_int[_code_length];
@ -130,7 +130,7 @@ void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift)
}
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32_t _chip_shift)
void gps_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, int32_t _prn, uint32_t _chip_shift)
{
const uint32_t _code_length = 1023;
int32_t ca_code_int[_code_length] = {0};
@ -139,7 +139,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32
for (uint32_t ii = 0; ii < _code_length; ++ii)
{
_dest[ii] = std::complex<float>(static_cast<float>(ca_code_int[ii]), 0.0f);
_dest[ii] = std::complex<float>(static_cast<float>(ca_code_int[ii]), 0.0F);
}
}
@ -148,7 +148,7 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32
* Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency
* NOTICE: the number of samples is rounded towards zero (integer truncation)
*/
void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
std::complex<float> _code[1023];

View File

@ -36,19 +36,26 @@
#include <complex>
#include <cstdint>
#if HAS_SPAN
#include <span>
namespace gsl = std;
#else
#include <gsl/gsl>
#endif
//! Generates int GPS L1 C/A code for the desired SV ID and code shift
void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift);
void gps_l1_ca_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates float GPS L1 C/A code for the desired SV ID and code shift
void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift);
void gps_l1_ca_code_gen_float(gsl::span<float> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, int32_t _prn, uint32_t _chip_shift);
void gps_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, int32_t _prn, uint32_t _chip_shift);
//! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift
void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes);
//! Generates complex GPS L1 C/A code for the desired SV ID and code shift
void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift);
#endif /* GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ */

View File

@ -0,0 +1,27 @@
//
// gsl-lite is based on GSL: Guidelines Support Library.
// For more information see https://github.com/martinmoene/gsl-lite
//
// Copyright (c) 2015 Martin Moene
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// mimic MS include hierarchy
#pragma once
#ifndef GSL_GSL_H_INCLUDED
#define GSL_GSL_H_INCLUDED
#include "gsl-lite.hpp"
#endif // GSL_GSL_H_INCLUDED

Some files were not shown because too many files have changed in this diff Show More