1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00

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

This commit is contained in:
Carles Fernandez 2017-11-21 17:35:40 +01:00
commit 9139c4053c
77 changed files with 4756 additions and 569 deletions

View File

@ -49,7 +49,7 @@ option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Tele
option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF)
option(ENABLE_GN3S "Enable the use of the GN3S dongle as signal source (experimental)" OFF)
option(ENABLE_PLUTOSDR "Enable the use of ADALM-PLUTO Evaluation Boards (Analog Devices Inc.), requires gr-iio" OFF)
option(ENABLE_FMCOMMS2 "Enable the use of FMCOMMS4-EBZ + ZedBoard hardware" OFF)
option(ENABLE_FMCOMMS2 "Enable the use of FMCOMMS4-EBZ + ZedBoard hardware, requires gr-iio" OFF)
# Performance analysis tools
option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF)
@ -317,6 +317,19 @@ set(GNSSSDR_ARMADILLO_MIN_VERSION "4.200.0")
################################################################################
# Versions to download and build (but not installed) if not found
################################################################################
set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.1")
set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.5")
set(GNSSSDR_ARMADILLO_LOCAL_VERSION "unstable")
set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.0")
set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master")
set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10")
set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.11")
################################################################################
# Check cmake version
################################################################################
@ -668,7 +681,6 @@ endif(NOT VOLK_GNSSSDR_FOUND)
# gflags - https://github.com/gflags/gflags
################################################################################
set(LOCAL_GFLAGS false)
set(gflags_RELEASE 2.2.1)
find_package(GFlags)
if (NOT GFlags_FOUND)
message (STATUS " gflags library has not been found.")
@ -677,12 +689,12 @@ if (NOT GFlags_FOUND)
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gflags-${gflags_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
GIT_REPOSITORY git://github.com/gflags/gflags.git
GIT_TAG v${gflags_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
UPDATE_COMMAND ""
@ -691,15 +703,15 @@ if (NOT GFlags_FOUND)
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gflags-${gflags_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
GIT_REPOSITORY git://github.com/gflags/gflags.git
GIT_TAG v${gflags_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
@ -707,16 +719,16 @@ if (NOT GFlags_FOUND)
endif(CMAKE_VERSION VERSION_LESS 3.2)
set(GFlags_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/include CACHE PATH "Local Gflags headers"
${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers"
)
add_library(gflags UNKNOWN IMPORTED)
set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX})
add_dependencies(gflags gflags-${gflags_RELEASE})
set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX})
add_dependencies(gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
set(GFlags_LIBS gflags)
file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*")
set(GFlags_LIBRARY gflags-${gflags_RELEASE})
set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib )
file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*")
set(GFlags_LIBRARY gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib )
link_directories(${GFlags_LIBRARY_PATH})
set(GFlags_lib ${GFlags_LIBS} CACHE FILEPATH "Local Gflags library")
set(GFlags_LIBRARY_PATH ${GFlags_LIBS})
@ -734,7 +746,7 @@ if(NOT ${ENABLE_OWN_GLOG})
set(GLOG_FOUND ON)
endif(GLOG_INCLUDE_DIRS)
endif(NOT ${ENABLE_OWN_GLOG})
set(glog_RELEASE 0.3.5)
set(glog_RELEASE ${GNSSSDR_GLOG_LOCAL_VERSION})
if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
message (STATUS " glog library has not been found")
if(NOT GFlags_FOUND)
@ -743,20 +755,20 @@ if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
message (STATUS " glog will be downloaded and built automatically ")
message (STATUS " when doing 'make'. ")
if(NOT ${LOCAL_GFLAGS})
add_library(gflags-${gflags_RELEASE} UNKNOWN IMPORTED)
set_property(TARGET gflags-${gflags_RELEASE} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}")
add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED)
set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}")
endif(NOT ${LOCAL_GFLAGS})
set(TARGET_GFLAGS gflags-${gflags_RELEASE})
set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
if(${LOCAL_GFLAGS})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib)
set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib)
else(${LOCAL_GFLAGS})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS})
endif(${LOCAL_GFLAGS})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
"#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK}
@ -764,34 +776,34 @@ export LIBS=\"${GFLAGS_LIBRARIES_TO_LINK} -lc++\"
export CXXFLAGS=\"-stdlib=libc++\"
export CC=clang
export CXX=clang++
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/
aclocal
automake --add-missing
autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure")
else("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
"#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK}
export LIBS=${GFLAGS_LIBRARIES_TO_LINK}
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/
aclocal
automake --add-missing
autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure")
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/configure_with_gflags)
set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags)
# Ensure that aclocal and libtool are present
if(OS_IS_LINUX)
@ -826,13 +838,13 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
glog-${glog_RELEASE}
glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/glog/
GIT_TAG v${glog_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}"
UPDATE_COMMAND ""
@ -841,16 +853,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
glog-${glog_RELEASE}
glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/glog/
GIT_TAG v${glog_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}"
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
@ -859,16 +871,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
# Set up variables
set(GLOG_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/src/
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/src
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src/
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src
)
set(GLOG_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
)
set(LOCAL_GLOG true CACHE STRING "Glog downloaded and built automatically" FORCE)
else(NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
add_library(glog-${glog_RELEASE} UNKNOWN IMPORTED)
set_property(TARGET glog-${glog_RELEASE} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}")
add_library(glog-${GNSSSDR_GLOG_LOCAL_VERSION} UNKNOWN IMPORTED)
set_property(TARGET glog-${GNSSSDR_GLOG_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}")
endif(NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
if(NOT ENABLE_LOG)
@ -1051,7 +1063,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO)
message(STATUS " Armadillo has not been found.")
message(STATUS " Armadillo will be downloaded and built automatically")
message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ")
set(armadillo_BRANCH unstable)
set(armadillo_BRANCH ${GNSSSDR_ARMADILLO_LOCAL_VERSION})
set(armadillo_RELEASE ${armadillo_BRANCH})
if(CMAKE_VERSION VERSION_LESS 3.2)
@ -1431,6 +1443,74 @@ endif(ENABLE_GPROF)
########################################################################
# Matio (OPTIONAL) - https://github.com/tbeu/matio
########################################################################
find_package(MATIO)
if(NOT MATIO_FOUND)
find_package(ZLIB)
if(ZLIB_FOUND)
get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY)
find_package(HDF5)
if(HDF5_FOUND)
list(GET HDF5_LIBRARIES 0 HDF5_FIRST_DIR)
get_filename_component(HDF5_BASE_DIR2 ${HDF5_FIRST_DIR} DIRECTORY)
get_filename_component(HDF5_BASE_DIR ${HDF5_BASE_DIR2} DIRECTORY)
if(OS_IS_MACOSX)
if(EXISTS /opt/local/include/hdf5.h)
set(HDF5_BASE_DIR /opt/local)
endif(EXISTS /opt/local/include/hdf5.h)
if(EXISTS /usr/local/include/hdf5.h)
set(HDF5_BASE_DIR /usr/local)
endif(EXISTS /usr/local/include/hdf5.h)
endif(OS_IS_MACOSX)
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
matio-${GNSSSDR_MATIO_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/mati
GIT_REPOSITORY https://github.com/tbeu/matio
GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}
UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix=<INSTALL_DIR>
BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}"
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
matio-${GNSSSDR_MATIO_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio
GIT_REPOSITORY https://github.com/tbeu/matio
GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}
UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix=<INSTALL_DIR>
BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}"
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX}
)
endif(CMAKE_VERSION VERSION_LESS 3.2)
set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} )
set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include )
set(MATIO_LOCAL true)
else(HDF5_FOUND)
message(STATUS " The hdf5 library has not been found in your system.")
message(STATUS " Please try to install it by doing:")
if(OS_IS_MACOSX)
message(STATUS " $ sudo port install hdf5")
message(STATUS " or")
message(STATUS " $ brew install hdf5")
endif(OS_IS_MACOSX)
if(OS_IS_LINUX)
message(STATUS " $ sudo apt-get install libhdf5-dev")
endif(OS_IS_LINUX)
message(FATAL_ERROR "*** The hdf5 library is required to build gnss-sdr")
endif(HDF5_FOUND)
else(ZLIB_FOUND)
message(FATAL_ERROR "*** The zlib library is required to build gnss-sdr")
endif(ZLIB_FOUND)
endif(NOT MATIO_FOUND)
########################################################################
# Set compiler flags
########################################################################

View File

@ -1,10 +1,10 @@
![](./docs/doxygen/images/gnss-sdr_logo.png)
[![](./docs/doxygen/images/gnss-sdr_logo.png)](http://gnss-sdr.org "GNSS-SDR website")
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
**Welcome to GNSS-SDR!**
Visit [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver.
If you have questions about GNSS-SDR, please [subscribe to the gnss-sdr-developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers "Subscribe to the gnss-sdr-developers mailing list" ) and post your questions there.
Visit [http://gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR website") for more information about this open source GNSS software defined receiver.
@ -47,7 +47,7 @@ $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time
libboost-serialization-dev libboost-program-options-dev libboost-test-dev \
liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev \
libarmadillo-dev libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev libgtest-dev \
python-mako python-six
python-mako python-six libmatio-dev
~~~~~~
Alternatively, and starting from Ubuntu 16.04 LTS, you can install all the required dependencies by adding the line
@ -84,11 +84,16 @@ Download, build and install PyBOMBS:
$ sudo pip install git+https://github.com/gnuradio/pybombs.git
~~~~~~
Add some software recipes (i.e., instructions on how to install software dependencies):
Apply a configuration:
~~~~~~
$ pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git
$ pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git
$ pybombs auto-config
~~~~~~
Add list of default recipes:
~~~~~~
$ pybombs recipes add-defaults
~~~~~~
Download, build and install GNU Radio, related drivers and some other extra modules into the directory ```/path/to/prefix``` (replace this path by your preferred one, for instance ```$HOME/sdr```):
@ -129,9 +134,9 @@ or manually as explained below, and then please follow instructions on how to [d
$ sudo apt-get install libopenblas-dev liblapack-dev # For Debian/Ubuntu/LinuxMint
$ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL
$ sudo zypper install lapack-devel blas-devel # For OpenSUSE
$ wget http://sourceforge.net/projects/arma/files/armadillo-7.800.2.tar.xz
$ tar xvfz armadillo-7.800.2.tar.xz
$ cd armadillo-7.800.2
$ wget http://sourceforge.net/projects/arma/files/armadillo-8.200.2.tar.xz
$ tar xvfz armadillo-8.200.2.tar.xz
$ cd armadillo-8.200.2
$ cmake .
$ make
$ sudo make install
@ -144,9 +149,9 @@ The full stop separated from ```cmake``` by a space is important. [CMake](http:/
#### Install [Gflags](https://github.com/gflags/gflags "Gflags' Homepage"), a commandline flags processing module for C++:
~~~~~~
$ wget https://github.com/gflags/gflags/archive/v2.2.0.tar.gz
$ tar xvfz v2.2.0.tar.gz
$ cd gflags-2.2.0
$ wget https://github.com/gflags/gflags/archive/v2.2.1.tar.gz
$ tar xvfz v2.2.1.tar.gz
$ cd gflags-2.2.1
$ cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DBUILD_gflags_nothreads_LIB=OFF .
$ make
$ sudo make install
@ -158,9 +163,9 @@ $ sudo ldconfig
#### Install [Glog](https://github.com/google/glog "Glog's Homepage"), a library that implements application-level logging:
~~~~~~
$ wget https://github.com/google/glog/archive/v0.3.4.tar.gz
$ tar xvfz v0.3.4.tar.gz
$ cd glog-0.3.4
$ wget https://github.com/google/glog/archive/v0.3.5.tar.gz
$ tar xvfz v0.3.5.tar.gz
$ cd glog-0.3.5
$ ./configure
$ make
$ sudo make install
@ -370,61 +375,50 @@ $ sudo make install
###### Build FMCOMMS2 based SDR Hardware support (OPTIONAL):
Install the [libiio](https://github.com/analogdevicesinc/libiio.git) (>=v0.11), [libad9361](https://github.com/analogdevicesinc/libad9361-iio.git) (>=v0.1-1) libraries and [gr-iio](https://github.com/analogdevicesinc/gr-iio.git) (>=v0.2) gnuradio block. For example in Ubuntu 16.04 follow these instructions (based on https://github.com/blurbdust/blurbdust.github.io):
Install the [libiio](https://github.com/analogdevicesinc/libiio.git) (>=v0.11), [libad9361](https://github.com/analogdevicesinc/libad9361-iio.git) (>=v0.1-1) libraries and [gr-iio](https://github.com/analogdevicesinc/gr-iio.git) (>v0.2) gnuradio block:
~~~~~~
$ sudo apt-get install libxml2-dev bison flex
$ git clone https://github.com/analogdevicesinc/libiio.git
$ cd libiio
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig
$ make && sudo make install && sudo ldconfig
$ cd ../..
$ git clone https://github.com/analogdevicesinc/libad9361-iio.git
$ cd libad9361-iio
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig
$ make && sudo make install && sudo ldconfig
$ cd ../..
$ git clone https://github.com/analogdevicesinc/gr-iio.git
$ cd gr-iio
$ mv include/gnuradio/iio include/iio
$ rm -r include/gnuradio
$ sed -i 's/gnuradio\/iio/iio/g' CMakeLists.txt
$ sed -i 's/gnuradio\/iio/iio/g' swig/*
$ sed -i 's/gnuradio\/iio/iio/g' include/iio/*
$ sed -i 's/gnuradio\/iio/iio/g' lib/*
$ sed -i 's/gnuradio\/iio/iio/g' python/iio/*
$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_pluto_sink.xml
$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_pluto_source.xml
$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_fmcomms2_sink.xml
$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_fmcomms2_source.xml
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig
$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
$ make && sudo make install && sudo ldconfig
$ cd ../..
~~~~~~
Then configure the gnss-sdr to build the `Fmcomms2_Signal_Source` and `Plutosdr_Signal_Source`:
Then configure GNSS-SDR to build the `Fmcomms2_Signal_Source` implementation:
~~~~~~
$ cd gnss-sdr/build
$ cmake -DENABLE_FMCOMMS2=ON ../
$ make
$ sudo make install
~~~~~~
or configure only `Plutosdr_Signal_Source`:
or configure it to build `Plutosdr_Signal_Source`:
~~~~~~
$ cmake -DENABLE_PLUTOSDR=ON ../
$ make
$ sudo make install
~~~~~~
With `Fmcomms2_Signal_Source` you can use any SDR hardware based on fmcomms2, including the ADALM-PLUTO (PlutoSdr) by configuring correctly the .conf file. The `Plutosdr_Signal_Source` offers a simplier manner to use the ADALM-PLUTO because implements only a subset of fmcomms2's parameters valid for those devices.
With `Fmcomms2_Signal_Source` you can use any SDR hardware based on [FMCOMMS2](https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz), including the ADALM-PLUTO (PlutoSdr) by configuring correctly the .conf file. The `Plutosdr_Signal_Source` offers a simpler manner to use the ADALM-PLUTO because implements only a subset of FMCOMMS2's parameters valid for those devices.
###### Build OpenCL support (OPTIONAL):
@ -501,6 +495,7 @@ $ sudo port install gnutls
$ sudo port install google-glog +gflags
$ sudo port install py27-mako
$ sudo port install py27-six
$ sudo port install matio
~~~~~~
You also might need to activate a Python installation. The list of installed versions can be retrieved with:
@ -517,15 +512,31 @@ $ sudo port select --set python python27
#### <a name="homebrew">Homebrew</a>
Instructions for installing GNU Radio using [homebrew](http://www.brew.sh) can be found [here](http://github.com/odrisci/homebrew-gnuradio) - please ensure to install all dependencies as required.
First, install [Homebrew](https://brew.sh/). Paste this in a terminal prompt:
Install Armadillo and dependencies:
~~~~~~
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
~~~~~~
The script explains what it will do and then pauses before it does it. There are more installation options [here](https://docs.brew.sh/Installation.html).
Install pip:
~~~~~~
$ sudo easy_install pip
~~~~~~
Install the required dependencies:
~~~~~~
$ brew tap homebrew/science
$ brew install cmake hdf5 arpack superlu
$ brew install armadillo
$ brew install glog gflags gnutls
$ brew install gnuradio
$ brew install libmatio
$ pip install mako
$ pip install six
~~~~~~
#### Build GNSS-SDR

View File

@ -7,10 +7,16 @@
# also defined, but not for general use are
# GPSTK_LIBRARY, where to find the GPSTK library.
FIND_PATH(GPSTK_INCLUDE_DIR Rinex3ObsBase.hpp)
FIND_PATH(GPSTK_INCLUDE_DIR Rinex3ObsBase.hpp
HINTS /usr/include/gpstk
/usr/local/include/gpstk
/opt/local/include/gpstk )
SET(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk)
FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} )
FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES}
HINTS /usr/lib
/usr/local/lib
/opt/local/lib )
# handle the QUIETLY and REQUIRED arguments and set GPSTK_FOUND to TRUE if
# all listed variables are TRUE

View File

@ -0,0 +1,100 @@
# FindMATIO
#
# Try to find MATIO library
#
# Once done this will define:
#
# MATIO_FOUND - True if MATIO found.
# MATIO_LIBRARIES - MATIO libraries.
# MATIO_INCLUDE_DIRS - where to find matio.h, etc..
# MATIO_VERSION_STRING - version number as a string (e.g.: "1.3.4")
#
#=============================================================================
# Copyright 2015 Avtech Scientific <http://avtechscientific.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
#
# Look for the header file.
find_path(MATIO_INCLUDE_DIR NAMES matio.h DOC "The MATIO include directory")
# Look for the library.
find_library(MATIO_LIBRARY NAMES matio DOC "The MATIO library")
if(MATIO_INCLUDE_DIR)
# ---------------------------------------------------
# Extract version information from MATIO
# ---------------------------------------------------
# If the file is missing, set all values to 0
set(MATIO_MAJOR_VERSION 0)
set(MATIO_MINOR_VERSION 0)
set(MATIO_RELEASE_LEVEL 0)
# new versions of MATIO have `matio_pubconf.h`
if(EXISTS ${MATIO_INCLUDE_DIR}/matio_pubconf.h)
set(MATIO_CONFIG_FILE "matio_pubconf.h")
else()
set(MATIO_CONFIG_FILE "matioConfig.h")
endif()
if(MATIO_CONFIG_FILE)
# Read and parse MATIO config header file for version number
file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ")
foreach(line ${_matio_HEADER_CONTENTS})
if(line MATCHES "#define ([A-Z_]+) ([0-9]+)")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
endforeach()
unset(_matio_HEADER_CONTENTS)
endif()
set(MATIO_VERSION_STRING "${MATIO_MAJOR_VERSION}.${MATIO_MINOR_VERSION}.${MATIO_RELEASE_LEVEL}")
endif ()
#==================
mark_as_advanced(MATIO_INCLUDE_DIR MATIO_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MATIO REQUIRED_VARS MATIO_LIBRARY MATIO_INCLUDE_DIR VERSION_VAR MATIO_VERSION_STRING)
if(MATIO_FOUND)
set(MATIO_LIBRARIES ${MATIO_LIBRARY})
set(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR})
else(MATIO_FOUND)
set(MATIO_LIBRARIES)
set(MATIO_INCLUDE_DIRS)
endif(MATIO_FOUND)

View File

@ -0,0 +1,29 @@
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PC_IIO gnuradio-iio)
FIND_PATH(
IIO_INCLUDE_DIRS
NAMES gnuradio/iio/api.h
HINTS $ENV{IIO_DIR}/include
${PC_IIO_INCLUDEDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/include
/usr/local/include
/usr/include
)
FIND_LIBRARY(
IIO_LIBRARIES
NAMES gnuradio-iio
HINTS $ENV{IIO_DIR}/lib
${PC_IIO_LIBDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS)
MARK_AS_ADVANCED(IIO_LIBRARIES IIO_INCLUDE_DIRS)

View File

@ -0,0 +1,11 @@
:+1::tada: Hello, and thanks for contributing to [GNSS-SDR](http://gnss-sdr.org)! :tada::+1:
Before submitting your pull request, please make sure the following is done:
1. You undertake the [Contributor Covenant Code of Conduct](https://github.com/gnss-sdr/gnss-sdr/blob/master/CODE_OF_CONDUCT.md).
2. If you are a first-time contributor, after your pull request you will be asked to sign an Individual Contributor License Agreement ([CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement)) before your code gets accepted into `master`. This license is for your protection as a Contributor as well as for the protection of [CTTC](http://www.cttc.es/); it does not change your rights to use your own contributions for any other purpose. Except for the license granted therein to CTTC and recipients of software distributed by CTTC, you reserve all right, title, and interest in and to your contributions. The information you provide in that CLA will be maintained in accordance with [CTTC's privacy policy](http://www.cttc.es/privacy/).
3. You have read the [Contributing Guidelines](https://github.com/gnss-sdr/gnss-sdr/blob/master/CONTRIBUTING.md).
4. You have read the [coding style guide](http://gnss-sdr.org/coding-style/).
5. You have forked the [gnss-sdr upstream repository](https://github.com/gnss-sdr/gnss-sdr) and have created your branch from `next` (or any other currently living branch in the upstream repository).
6. Please include a description of your changes here.
**Please feel free to delete this line and the above text once you have read it and in case you want to go on with your pull request.**

View File

@ -84,7 +84,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false);
//--- Find number of samples per spreading code (1ms)-------------------------
code_length_ = round(fs_in_ / Galileo_E5a_CODE_CHIP_RATE_HZ * Galileo_E5a_CODE_LENGTH_CHIPS);
code_length_ = 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_;

View File

@ -39,7 +39,6 @@
#define GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H_
#include <string>
#include <gnuradio/blocks/stream_to_vector.h>
#include "gnss_synchro.h"
#include "acquisition_interface.h"
#include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h"
@ -135,7 +134,6 @@ public:
private:
ConfigurationInterface* configuration_;
galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr acquisition_cc_;
gr::blocks::stream_to_vector::sptr stream_to_vector_;
size_t item_size_;
std::string item_type_;
unsigned int vector_length_;

View File

@ -344,7 +344,7 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_state(int state)
int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items,
int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items __attribute__((unused)),
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items __attribute__((unused)))
{
@ -392,17 +392,17 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items
{
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]); //Get the input samples pointer
unsigned int buff_increment;
if (ninput_items[0] + d_buffer_count <= d_fft_size)
if ((ninput_items[0] + d_buffer_count) <= d_fft_size)
{
buff_increment = ninput_items[0];
}
else
{
buff_increment = (d_fft_size - d_buffer_count);
buff_increment = d_fft_size - d_buffer_count;
}
memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex) * buff_increment);
// If buffer will be full in next iteration
if (d_buffer_count >= d_fft_size - d_gr_stream_buffer)
if (d_buffer_count >= (d_fft_size - d_gr_stream_buffer))
{
d_state = 2;
}
@ -419,7 +419,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items
{
memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex)*(d_fft_size-d_buffer_count));
}
d_sample_counter += d_fft_size-d_buffer_count; // sample counter
d_sample_counter += (d_fft_size - d_buffer_count); // sample counter
// initialize acquisition algorithm
int doppler;
@ -810,6 +810,6 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items
}
}
return noutput_items;
return 0;
}

View File

@ -31,6 +31,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/core/system_parameters
${CMAKE_SOURCE_DIR}/src/core/interfaces
${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/libs
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}

View File

@ -51,6 +51,7 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_8sc_t);
@ -63,6 +64,10 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_ic_ = make_conjugate_ic();
}
}
@ -74,7 +79,26 @@ void IbyteToCbyte::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
top_block->connect(conjugate_ic_, 0, file_sink_, 0);
}
else
{
top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -83,21 +107,40 @@ void IbyteToCbyte::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
top_block->disconnect(conjugate_ic_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
}
}
}
gr::basic_block_sptr IbyteToCbyte::get_left_block()
{
return ibyte_to_cbyte_;
}
gr::basic_block_sptr IbyteToCbyte::get_right_block()
{
return ibyte_to_cbyte_;
if(inverted_spectrum)
{
return conjugate_ic_;
}
else
{
return ibyte_to_cbyte_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_ic.h"
#include "gnss_block_interface.h"
#include "interleaved_byte_to_complex_byte.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_ic_sptr conjugate_ic_;
bool inverted_spectrum;
};
#endif

View File

@ -49,6 +49,7 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(gr_complex);
@ -56,6 +57,10 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin
DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_char_to_complex_->unique_id() << ")";
if (inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
@ -72,7 +77,26 @@ void IbyteToComplex::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
top_block->connect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -81,22 +105,40 @@ void IbyteToComplex::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
top_block->disconnect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
}
}
}
gr::basic_block_sptr IbyteToComplex::get_left_block()
{
return gr_interleaved_char_to_complex_;
}
gr::basic_block_sptr IbyteToComplex::get_right_block()
{
return gr_interleaved_char_to_complex_;
if(inverted_spectrum)
{
return conjugate_cc_;
}
else
{
return gr_interleaved_char_to_complex_;
}
}

View File

@ -34,8 +34,9 @@
#include <string>
#include <gnuradio/blocks/interleaved_char_to_complex.h>
#include <gnuradio/blocks/file_sink.h>
#include "gnss_synchro.h"
#include "conjugate_cc.h"
#include "gnss_block_interface.h"
#include "gnss_synchro.h"
class ConfigurationInterface;
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_cc_sptr conjugate_cc_;
bool inverted_spectrum;
};
#endif

View File

@ -51,6 +51,7 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_16sc_t);
@ -63,6 +64,10 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
@ -74,7 +79,22 @@ void IbyteToCshort::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
top_block->connect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
@ -83,22 +103,40 @@ void IbyteToCshort::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
top_block->disconnect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
gr::basic_block_sptr IbyteToCshort::get_left_block()
{
return interleaved_byte_to_complex_short_;
}
gr::basic_block_sptr IbyteToCshort::get_right_block()
{
return interleaved_byte_to_complex_short_;
if(inverted_spectrum)
{
return conjugate_sc_;
}
else
{
return interleaved_byte_to_complex_short_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "gnss_block_interface.h"
#include "conjugate_sc.h"
#include "interleaved_byte_to_complex_short.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_sc_sptr conjugate_sc_;
bool inverted_spectrum;
};
#endif

View File

@ -49,6 +49,7 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(gr_complex);
@ -56,6 +57,10 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str
DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")";
if (inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
@ -72,11 +77,26 @@ void IshortToComplex::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
top_block->connect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
}
}
else
{
DLOG(INFO) << "Nothing to connect internally";
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -85,22 +105,40 @@ void IshortToComplex::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
top_block->disconnect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
}
}
}
gr::basic_block_sptr IshortToComplex::get_left_block()
{
return gr_interleaved_short_to_complex_;
}
gr::basic_block_sptr IshortToComplex::get_right_block()
{
return gr_interleaved_short_to_complex_;
if(inverted_spectrum)
{
return conjugate_cc_;
}
else
{
return gr_interleaved_short_to_complex_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/interleaved_short_to_complex.h>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_cc.h"
#include "gnss_block_interface.h"
@ -84,6 +85,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_cc_sptr conjugate_cc_;
bool inverted_spectrum;
};
#endif

View File

@ -51,6 +51,7 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_16sc_t);
@ -63,6 +64,10 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
@ -74,11 +79,26 @@ void IshortToCshort::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
top_block->connect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
DLOG(INFO) << "Nothing to connect internally";
if(inverted_spectrum)
{
top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -87,22 +107,40 @@ void IshortToCshort::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
top_block->disconnect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
gr::basic_block_sptr IshortToCshort::get_left_block()
{
return interleaved_short_to_complex_short_;
}
gr::basic_block_sptr IshortToCshort::get_right_block()
{
return interleaved_short_to_complex_short_;
if(inverted_spectrum)
{
return conjugate_sc_;
}
else
{
return interleaved_short_to_complex_short_;
}
}

View File

@ -33,6 +33,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_sc.h"
#include "gnss_block_interface.h"
#include "interleaved_short_to_complex_short.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_sc_sptr conjugate_sc_;
bool inverted_spectrum;
};
#endif

View File

@ -1,11 +1,12 @@
/*!
* \file freq_xlating_fir_filter.cc
* \brief Adapts a gnuradio gr_freq_xlating_fir_filter designed with gr_remez
* \brief Adapts a gnuradio gr_freq_xlating_fir_filter designed with gr_remez or gr_firdes
* \author Luis Esteve, 2012. luis(at)epsilon-formacion.com
* Antonio Ramos, 2017. antonio.ramos(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@ -32,6 +33,7 @@
#include <boost/lexical_cast.hpp>
#include <gnuradio/blocks/file_sink.h>
#include <gnuradio/filter/pm_remez.h>
#include <gnuradio/filter/firdes.h>
#include <glog/logging.h>
#include <volk/volk.h>
#include "configuration_interface.h"
@ -343,8 +345,8 @@ void FreqXlatingFirFilter::init()
std::string default_output_item_type = "gr_complex";
std::string default_taps_item_type = "float";
std::string default_dump_filename = "../data/input_filter.dat";
double default_intermediate_freq = 0;
double default_sampling_freq = 4000000;
double default_intermediate_freq = 0.0;
double default_sampling_freq = 4000000.0;
int default_number_of_taps = 6;
unsigned int default_number_of_bands = 2;
std::vector<double> default_bands = { 0.0, 0.4, 0.6, 1.0 };
@ -364,46 +366,54 @@ void FreqXlatingFirFilter::init()
sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq);
int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps);
unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands);
std::vector<double> bands;
std::vector<double> ampl;
std::vector<double> error_w;
std::string option;
double option_value;
for (unsigned int i = 0; i < number_of_bands; i++)
{
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_begin";
option_value = config_->property(role_ + option, default_bands[i]);
bands.push_back(option_value);
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_end";
option_value = config_->property(role_ + option, default_bands[i]);
bands.push_back(option_value);
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_begin";
option_value = config_->property(role_ + option, default_bands[i]);
ampl.push_back(option_value);
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_end";
option_value = config_->property(role_ + option, default_bands[i]);
ampl.push_back(option_value);
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_error";
option_value = config_->property(role_ + option, default_bands[i]);
error_w.push_back(option_value);
}
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
std::vector<double> taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl,
error_w, filter_type, grid_density);
taps_.reserve(taps_d.size());
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++)
if(filter_type.compare("lowpass") != 0)
{
taps_.push_back(float(*it));
//std::cout<<"TAP="<<float(*it)<<std::endl;
std::vector<double> taps_d;
std::vector<double> bands;
std::vector<double> ampl;
std::vector<double> error_w;
std::string option;
double option_value;
for (unsigned int i = 0; i < number_of_bands; i++)
{
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_begin";
option_value = config_->property(role_ + option, default_bands[i]);
bands.push_back(option_value);
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_end";
option_value = config_->property(role_ + option, default_bands[i]);
bands.push_back(option_value);
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_begin";
option_value = config_->property(role_ + option, default_bands[i]);
ampl.push_back(option_value);
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_end";
option_value = config_->property(role_ + option, default_bands[i]);
ampl.push_back(option_value);
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_error";
option_value = config_->property(role_ + option, default_bands[i]);
error_w.push_back(option_value);
}
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density);
taps_.reserve(taps_d.size());
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++)
{
taps_.push_back(static_cast<float>(*it));
}
}
else
{
double default_bw = 2000000.0;
double bw_ = config_->property(role_ + ".bw", default_bw);
double default_tw = bw_ / 10.0;
double tw_ = config_->property(role_ + ".tw", default_tw);
taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_, tw_);
}
}

View File

@ -28,10 +28,13 @@
* -------------------------------------------------------------------------
*/
#include "pulse_blanking_filter.h"
#include <boost/lexical_cast.hpp>
#include <vector>
#include <cmath>
#include <glog/logging.h>
#include <gnuradio/filter/firdes.h>
#include "configuration_interface.h"
#include "pulse_blanking_filter.h"
using google::LogMessage;
@ -41,6 +44,7 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration,
out_streams_(out_streams)
{
size_t item_size;
xlat_ = false;
std::string default_input_item_type = "gr_complex";
std::string default_output_item_type = "gr_complex";
std::string default_dump_filename = "../data/input_filter.dat";
@ -71,7 +75,21 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration,
item_size = sizeof(gr_complex); //avoids uninitialization
input_size_ = sizeof(gr_complex); //avoids uninitialization
}
double default_if = 0.0;
double if_aux = config_->property(role_ + ".if", default_if);
double if_ = config_->property(role_ + ".IF", if_aux);
if (std::abs(if_) > 1.0)
{
xlat_ = true;
double default_sampling_freq = 4000000.0;
double sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq);
double default_bw = 2000000.0;
double bw_ = config_->property(role_ + ".bw", default_bw);
double default_tw = bw_ / 10.0;
double tw_ = config_->property(role_ + ".tw", default_tw);
const std::vector<float> taps = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_ , tw_);
freq_xlating_ = gr::filter::freq_xlating_fir_filter_ccf::make(1, taps, if_, sampling_freq_);
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
@ -95,6 +113,10 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block)
{
top_block->connect(pulse_blanking_cc_, 0, file_sink_, 0);
}
if (xlat_)
{
top_block->connect(freq_xlating_, 0, pulse_blanking_cc_, 0);
}
}
else
@ -113,6 +135,10 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block)
{
top_block->disconnect(pulse_blanking_cc_, 0, file_sink_, 0);
}
if (xlat_)
{
top_block->disconnect(freq_xlating_, 0, pulse_blanking_cc_, 0);
}
}
else
{
@ -125,7 +151,14 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block()
{
if (input_item_type_.compare("gr_complex") == 0)
{
return pulse_blanking_cc_;
if (xlat_)
{
return freq_xlating_;
}
else
{
return pulse_blanking_cc_;
}
}
else
{

View File

@ -33,8 +33,8 @@
#define GNSS_SDR_PULSE_BLANKING_FILTER_H_
#include <string>
#include <vector>
#include <gnuradio/blocks/file_sink.h>
#include <gnuradio/filter/freq_xlating_fir_filter_ccf.h>
#include "gnss_block_interface.h"
#include "pulse_blanking_cc.h"
@ -73,6 +73,7 @@ public:
private:
ConfigurationInterface* config_;
bool dump_;
bool xlat_;
std::string dump_filename_;
std::string input_item_type_;
size_t input_size_;
@ -82,6 +83,7 @@ private:
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
pulse_blanking_cc_sptr pulse_blanking_cc_;
gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_;
};
#endif // GNSS_SDR_PULSE_BLANKING_FILTER_H_

View File

@ -33,6 +33,9 @@ set(GNSS_SPLIBS_SOURCES
cshort_to_float_x2.cc
short_x2_to_cshort.cc
complex_float_to_complex_byte.cc
conjugate_cc.cc
conjugate_sc.cc
conjugate_ic.cc
)

View File

@ -0,0 +1,29 @@
#include "conjugate_cc.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
conjugate_cc_sptr make_conjugate_cc()
{
return conjugate_cc_sptr(new conjugate_cc());
}
conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc",
gr::io_signature::make (1, 1, sizeof(gr_complex)),
gr::io_signature::make (1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_cc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
volk_32fc_conjugate_32fc(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_cc.h
* \brief Conjugate
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_CC_H_
#define GNSS_SDR_CONJUGATE_CC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_cc;
typedef boost::shared_ptr<conjugate_cc> conjugate_cc_sptr;
conjugate_cc_sptr make_conjugate_cc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_cc : public gr::sync_block
{
private:
friend conjugate_cc_sptr make_conjugate_cc();
public:
conjugate_cc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -0,0 +1,29 @@
#include "conjugate_ic.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_ic_sptr make_conjugate_ic()
{
return conjugate_ic_sptr(new conjugate_ic());
}
conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic",
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_ic::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_8sc_t *in = reinterpret_cast<const lv_8sc_t *>(input_items[0]);
lv_8sc_t *out = reinterpret_cast<lv_8sc_t *>(output_items[0]);
volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_ic.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_IC_H_
#define GNSS_SDR_CONJUGATE_IC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_ic;
typedef boost::shared_ptr<conjugate_ic> conjugate_ic_sptr;
conjugate_ic_sptr make_conjugate_ic();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_ic : public gr::sync_block
{
private:
friend conjugate_ic_sptr make_conjugate_ic();
public:
conjugate_ic();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -0,0 +1,29 @@
#include "conjugate_sc.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_sc_sptr make_conjugate_sc()
{
return conjugate_sc_sptr(new conjugate_sc());
}
conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc",
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_sc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_16sc_t *in = reinterpret_cast<const lv_16sc_t *>(input_items[0]);
lv_16sc_t *out = reinterpret_cast<lv_16sc_t *>(output_items[0]);
volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_sc.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_CONJUGATE_SC_H_
#define GNSS_SDR_CONJUGATE_SC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_sc;
typedef boost::shared_ptr<conjugate_sc> conjugate_sc_sptr;
conjugate_sc_sptr make_conjugate_sc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_sc : public gr::sync_block
{
private:
friend conjugate_sc_sptr make_conjugate_sc();
public:
conjugate_sc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
}
item_type_ = configuration->property(role + ".item_type", input_type);
vector_size_ = configuration->property(role + ".vector_size", 1);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
if(item_type_.compare("float") == 0)
{
@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
if(inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
}
else if(item_type_.compare("short") == 0)
{
@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cshort") == 0)
{
item_size_ = sizeof(lv_16sc_t);
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
else if(item_type_.compare("byte") == 0)
{
@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cbyte") == 0)
{
item_size_ = sizeof(lv_8sc_t);
if(inverted_spectrum)
{
conjugate_ic_ = make_conjugate_ic();
}
}
else
{
LOG(WARNING) << item_type_ << " unrecognized item type. Using float";
item_size_ = sizeof(float);
}
kludge_copy_ = gr::blocks::copy::make(item_size_);
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
}
@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr Pass_Through::get_left_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}
@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block()
gr::basic_block_sptr Pass_Through::get_right_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}

View File

@ -37,6 +37,10 @@
#include <gnuradio/hier_block2.h>
#include <gnuradio/blocks/copy.h>
#include "gnss_block_interface.h"
#include "conjugate_cc.h"
#include "conjugate_sc.h"
#include "conjugate_ic.h"
class ConfigurationInterface;
@ -69,11 +73,6 @@ public:
return item_type_;
}
inline size_t vector_size() const
{
return vector_size_;
}
inline size_t item_size() override
{
return item_size_;
@ -86,13 +85,16 @@ public:
private:
std::string item_type_;
size_t vector_size_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
//gr_kludge_copy_sptr kludge_copy_;
gr::blocks::copy::sptr kludge_copy_;
size_t item_size_;
conjugate_cc_sptr conjugate_cc_;
conjugate_sc_sptr conjugate_sc_;
conjugate_ic_sptr conjugate_ic_;
bool inverted_spectrum;
};
#endif /*GNSS_SDR_PASS_THROUGH_H_*/

View File

@ -31,6 +31,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
if(CMAKE_VERSION VERSION_GREATER "3.0")
cmake_policy(SET CMP0042 NEW)
if(CMAKE_VERSION VERSION_GREATER "3.9")
cmake_policy(SET CMP0068 NEW)
endif(CMAKE_VERSION VERSION_GREATER "3.9")
endif(CMAKE_VERSION VERSION_GREATER "3.0")
option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project
@ -84,6 +91,7 @@ if(UNIX)
)
endif(UNIX)
########################################################################
# Dependencies setup
########################################################################

View File

@ -50,6 +50,15 @@ elseif(ORC_FOUND)
endif(ORC_FOUND)
# allow 'large' files in 32 bit builds
if(UNIX)
add_definitions( -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64
-D_LARGE_FILES
)
endif(UNIX)
# MAKE volk_gnsssdr_profile
add_executable(volk_gnsssdr_profile
${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_profile.cc

View File

@ -213,7 +213,6 @@ int main(int argc, char *argv[]) {
}
if(!dry_run) {
write_results(&results, false);
if(vm.count("path")) write_results(&results, false, config_file);
else write_results(&results, false);
}

View File

@ -82,7 +82,7 @@ for arch_xml in archs_xml:
flags = dict()
for flag_xml in arch_xml.getElementsByTagName("flag"):
name = flag_xml.attributes["compiler"].value
if not flags.has_key(name): flags[name] = list()
if name not in flags: flags[name] = list()
flags[name].append(flag_xml.firstChild.data)
#force kwargs keys to be of type str, not unicode for py25
kwargs = dict((str(k), v) for k, v in six.iteritems(kwargs))

View File

@ -0,0 +1,234 @@
/*!
* \file volk_gnsssdr_16ic_conjugate_16ic.h
* \brief VOLK_GNSSSDR kernel: returns the conjugate of a 16 bits complex vector.
* \authors <ul>
* <li> Carles Fernandez Prades 2017 cfernandez at cttc dot cat
* </ul>
*
* VOLK_GNSSSDR kernel that calculates the conjugate of a
* 16 bits complex vector (16 bits the real part and 16 bits the imaginary part)
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
/*!
* \page volk_gnsssdr_16ic_conjugate_16ic
*
* \b Overview
*
* Takes the conjugate of a complex signed 16-bit integer vector.
*
* <b>Dispatcher Prototype</b>
* \code
* void volk_gnsssdr_16ic_conjugate_16ic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points);
* \endcode
*
* \b Inputs
* \li aVector: Vector of complex items to be conjugated
* \li num_points: The number of complex data points.
*
* \b Outputs
* \li cVector: The vector where the result will be stored
*
*/
#ifndef INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H
#define INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H
#include <volk_gnsssdr/volk_gnsssdr_complex.h>
#ifdef LV_HAVE_GENERIC
static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
{
lv_16sc_t* cPtr = cVector;
const lv_16sc_t* aPtr = aVector;
unsigned int number;
for(number = 0; number < num_points; number++)
{
*cPtr++ = lv_conj(*aPtr++);
}
}
#endif /* LV_HAVE_GENERIC */
#ifdef LV_HAVE_SSSE3
#include <tmmintrin.h>
static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
{
const unsigned int sse_iters = num_points / 4;
unsigned int i;
lv_16sc_t* c = cVector;
const lv_16sc_t* a = aVector;
__m128i tmp;
__m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1);
for (i = 0; i < sse_iters; ++i)
{
tmp = _mm_lddqu_si128((__m128i*)a);
tmp = _mm_sign_epi16(tmp, conjugator);
_mm_storeu_si128((__m128i*)c, tmp);
a += 4;
c += 4;
}
for (i = sse_iters * 4; i < num_points; ++i)
{
*c++ = lv_conj(*a++);
}
}
#endif /* LV_HAVE_SSSE3 */
#ifdef LV_HAVE_SSSE3
#include <tmmintrin.h>
static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
{
const unsigned int sse_iters = num_points / 4;
unsigned int i;
lv_16sc_t* c = cVector;
const lv_16sc_t* a = aVector;
__m128i tmp;
__m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1);
for (i = 0; i < sse_iters; ++i)
{
tmp = _mm_load_si128((__m128i*)a);
tmp = _mm_sign_epi16(tmp, conjugator);
_mm_store_si128((__m128i*)c, tmp);
a += 4;
c += 4;
}
for (i = sse_iters * 4; i < num_points; ++i)
{
*c++ = lv_conj(*a++);
}
}
#endif /* LV_HAVE_SSSE3 */
#ifdef LV_HAVE_AVX2
#include <immintrin.h>
static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
{
const unsigned int avx2_iters = num_points / 8;
unsigned int i;
lv_16sc_t* c = cVector;
const lv_16sc_t* a = aVector;
__m256i tmp;
__m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1);
for (i = 0; i < avx2_iters; ++i)
{
tmp = _mm256_load_si256((__m256i*)a);
tmp = _mm256_sign_epi16(tmp, conjugator);
_mm256_store_si256((__m256i*)c, tmp);
a += 8;
c += 8;
}
for (i = avx2_iters * 8; i < num_points; ++i)
{
*c++ = lv_conj(*a++);
}
}
#endif /* LV_HAVE_AVX2 */
#ifdef LV_HAVE_AVX2
#include <immintrin.h>
static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
{
const unsigned int avx2_iters = num_points / 8;
unsigned int i;
lv_16sc_t* c = cVector;
const lv_16sc_t* a = aVector;
__m256i tmp;
__m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1);
for (i = 0; i < avx2_iters; ++i)
{
tmp = _mm256_loadu_si256((__m256i*)a);
tmp = _mm256_sign_epi16(tmp, conjugator);
_mm256_storeu_si256((__m256i*)c, tmp);
a += 8;
c += 8;
}
for (i = avx2_iters * 8; i < num_points; ++i)
{
*c++ = lv_conj(*a++);
}
}
#endif /* LV_HAVE_AVX2 */
//
//
//#ifdef LV_HAVE_NEON
//#include <arm_neon.h>
//
//static inline void volk_gnsssdr_16ic_conjugate_16ic_neon(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points)
//{
// const unsigned int sse_iters = num_points / 4;
// unsigned int i;
// lv_16sc_t* c = cVector;
// const lv_16sc_t* a = aVector;
// int16x4x2_t a_val;
//
// for (i = 0; i < sse_iters; ++i)
// {
// a_val = vld2_s16((const int16_t*)a);
// __VOLK_GNSSSDR_PREFETCH(a + 4);
// a_val.val[1] = vneg_s16(a_val.val[1]);
// vst2_s16((int16_t*)c, a_val);
// a += 4;
// c += 4;
// }
//
// for (i = sse_iters * 4; i < num_points; ++i)
// {
// *c++ = lv_conj(*a++);
// }
//}
//#endif /* LV_HAVE_NEON */
#endif /* INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H */

View File

@ -176,9 +176,10 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
const float* aPtr = (float*)in_common;
const float* bPtr[ num_a_vectors];
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){
bPtr[vec_ind] = in_a[vec_ind];
}
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
bPtr[vec_ind] = in_a[vec_ind];
}
lv_32fc_t _phase = (*phase);
lv_32fc_t wo;
@ -193,20 +194,22 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
__m256 dotProdVal2[num_a_vectors];
__m256 dotProdVal3[num_a_vectors];
for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ ){
dotProdVal0[vec_ind] = _mm256_setzero_ps();
dotProdVal1[vec_ind] = _mm256_setzero_ps();
dotProdVal2[vec_ind] = _mm256_setzero_ps();
dotProdVal3[vec_ind] = _mm256_setzero_ps();
}
for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ )
{
dotProdVal0[vec_ind] = _mm256_setzero_ps();
dotProdVal1[vec_ind] = _mm256_setzero_ps();
dotProdVal2[vec_ind] = _mm256_setzero_ps();
dotProdVal3[vec_ind] = _mm256_setzero_ps();
}
// Set up the complex rotator
__m256 z0, z1, z2, z3;
__attribute__((aligned(32))) lv_32fc_t phase_vec[16];
for( vec_ind = 0; vec_ind < 16; ++vec_ind ){
phase_vec[vec_ind] = _phase;
_phase *= phase_inc;
}
__VOLK_ATTR_ALIGNED(32) lv_32fc_t phase_vec[16];
for( vec_ind = 0; vec_ind < 16; ++vec_ind )
{
phase_vec[vec_ind] = _phase;
_phase *= phase_inc;
}
z0 = _mm256_load_ps( (float *)phase_vec );
z1 = _mm256_load_ps( (float *)(phase_vec + 4) );
@ -215,104 +218,267 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
lv_32fc_t dz = phase_inc; dz *= dz; dz *= dz; dz *= dz; dz *= dz; // dz = phase_inc^16;
for( vec_ind = 0; vec_ind < 4; ++vec_ind ){
phase_vec[vec_ind] = dz;
}
for( vec_ind = 0; vec_ind < 4; ++vec_ind )
{
phase_vec[vec_ind] = dz;
}
__m256 dz_reg = _mm256_load_ps( (float *)phase_vec );
dz_reg = _mm256_complexnormalise_ps( dz_reg );
for(;number < sixteenthPoints; number++){
a0Val = _mm256_loadu_ps(aPtr);
a1Val = _mm256_loadu_ps(aPtr+8);
a2Val = _mm256_loadu_ps(aPtr+16);
a3Val = _mm256_loadu_ps(aPtr+24);
a0Val = _mm256_complexmul_ps( a0Val, z0 );
a1Val = _mm256_complexmul_ps( a1Val, z1 );
a2Val = _mm256_complexmul_ps( a2Val, z2 );
a3Val = _mm256_complexmul_ps( a3Val, z3 );
z0 = _mm256_complexmul_ps( z0, dz_reg );
z1 = _mm256_complexmul_ps( z1, dz_reg );
z2 = _mm256_complexmul_ps( z2, dz_reg );
z3 = _mm256_complexmul_ps( z3, dz_reg );
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){
x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7
x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8);
x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5
x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7
x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]);
x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]);
// TODO: it may be possible to rearrange swizzling to better pipeline data
b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3
b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7
b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20);
b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31);
c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]);
c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]);
c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]);
c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]);
dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]);
dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]);
dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]);
bPtr[vec_ind] += 16;
}
// Force the rotators back onto the unit circle
if ((number % 64) == 0)
for(;number < sixteenthPoints; number++)
{
z0 = _mm256_complexnormalise_ps( z0 );
z1 = _mm256_complexnormalise_ps( z1 );
z2 = _mm256_complexnormalise_ps( z2 );
z3 = _mm256_complexnormalise_ps( z3 );
}
a0Val = _mm256_loadu_ps(aPtr);
a1Val = _mm256_loadu_ps(aPtr+8);
a2Val = _mm256_loadu_ps(aPtr+16);
a3Val = _mm256_loadu_ps(aPtr+24);
aPtr += 32;
}
a0Val = _mm256_complexmul_ps( a0Val, z0 );
a1Val = _mm256_complexmul_ps( a1Val, z1 );
a2Val = _mm256_complexmul_ps( a2Val, z2 );
a3Val = _mm256_complexmul_ps( a3Val, z3 );
z0 = _mm256_complexmul_ps( z0, dz_reg );
z1 = _mm256_complexmul_ps( z1, dz_reg );
z2 = _mm256_complexmul_ps( z2, dz_reg );
z3 = _mm256_complexmul_ps( z3, dz_reg );
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7
x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8);
x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5
x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7
x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]);
x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]);
// TODO: it may be possible to rearrange swizzling to better pipeline data
b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3
b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7
b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20);
b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31);
c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]);
c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]);
c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]);
c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]);
dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]);
dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]);
dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]);
bPtr[vec_ind] += 16;
}
// Force the rotators back onto the unit circle
if ((number % 64) == 0)
{
z0 = _mm256_complexnormalise_ps( z0 );
z1 = _mm256_complexnormalise_ps( z1 );
z2 = _mm256_complexnormalise_ps( z2 );
z3 = _mm256_complexnormalise_ps( z3 );
}
aPtr += 32;
}
__VOLK_ATTR_ALIGNED(32) lv_32fc_t dotProductVector[4];
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]);
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]);
_mm256_store_ps((float *)dotProductVector,dotProdVal0[vec_ind]); // Store the results back into the dot product vector
_mm256_store_ps((float *)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector
result[ vec_ind ] = lv_cmake( 0, 0 );
for( i = 0; i < 4; ++i ){
result[vec_ind] += dotProductVector[i];
result[ vec_ind ] = lv_cmake( 0, 0 );
for( i = 0; i < 4; ++i )
{
result[vec_ind] += dotProductVector[i];
}
}
}
z0 = _mm256_complexnormalise_ps( z0 );
_mm256_store_ps((float*)phase_vec, z0);
_phase = phase_vec[0];
_phase = phase_vec[0];
_mm256_zeroupper();
number = sixteenthPoints*16;
for(;number < num_points; number++){
wo = (*aPtr++)*_phase;
_phase *= phase_inc;
for(;number < num_points; number++)
{
wo = (*aPtr++)*_phase;
_phase *= phase_inc;
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){
result[vec_ind] += wo * in_a[vec_ind][number];
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
result[vec_ind] += wo * in_a[vec_ind][number];
}
}
}
*phase = _phase;
}
#endif /* LV_HAVE_AVX */
#ifdef LV_HAVE_AVX
#include <immintrin.h>
#include <volk_gnsssdr/volk_gnsssdr_avx_intrinsics.h>
static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points)
{
unsigned int number = 0;
unsigned int vec_ind = 0;
unsigned int i = 0;
const unsigned int sixteenthPoints = num_points / 16;
const float* aPtr = (float*)in_common;
const float* bPtr[ num_a_vectors];
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
bPtr[vec_ind] = in_a[vec_ind];
}
lv_32fc_t _phase = (*phase);
lv_32fc_t wo;
__m256 a0Val, a1Val, a2Val, a3Val;
__m256 b0Val[num_a_vectors], b1Val[num_a_vectors], b2Val[num_a_vectors], b3Val[num_a_vectors];
__m256 x0Val[num_a_vectors], x1Val[num_a_vectors], x0loVal[num_a_vectors], x0hiVal[num_a_vectors], x1loVal[num_a_vectors], x1hiVal[num_a_vectors];
__m256 c0Val[num_a_vectors], c1Val[num_a_vectors], c2Val[num_a_vectors], c3Val[num_a_vectors];
__m256 dotProdVal0[num_a_vectors];
__m256 dotProdVal1[num_a_vectors];
__m256 dotProdVal2[num_a_vectors];
__m256 dotProdVal3[num_a_vectors];
for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ )
{
dotProdVal0[vec_ind] = _mm256_setzero_ps();
dotProdVal1[vec_ind] = _mm256_setzero_ps();
dotProdVal2[vec_ind] = _mm256_setzero_ps();
dotProdVal3[vec_ind] = _mm256_setzero_ps();
}
// Set up the complex rotator
__m256 z0, z1, z2, z3;
__VOLK_ATTR_ALIGNED(32) lv_32fc_t phase_vec[16];
for( vec_ind = 0; vec_ind < 16; ++vec_ind )
{
phase_vec[vec_ind] = _phase;
_phase *= phase_inc;
}
z0 = _mm256_load_ps( (float *)phase_vec );
z1 = _mm256_load_ps( (float *)(phase_vec + 4) );
z2 = _mm256_load_ps( (float *)(phase_vec + 8) );
z3 = _mm256_load_ps( (float *)(phase_vec + 12) );
lv_32fc_t dz = phase_inc; dz *= dz; dz *= dz; dz *= dz; dz *= dz; // dz = phase_inc^16;
for( vec_ind = 0; vec_ind < 4; ++vec_ind )
{
phase_vec[vec_ind] = dz;
}
__m256 dz_reg = _mm256_load_ps( (float *)phase_vec );
dz_reg = _mm256_complexnormalise_ps( dz_reg );
for(;number < sixteenthPoints; number++)
{
a0Val = _mm256_load_ps(aPtr);
a1Val = _mm256_load_ps(aPtr+8);
a2Val = _mm256_load_ps(aPtr+16);
a3Val = _mm256_load_ps(aPtr+24);
a0Val = _mm256_complexmul_ps( a0Val, z0 );
a1Val = _mm256_complexmul_ps( a1Val, z1 );
a2Val = _mm256_complexmul_ps( a2Val, z2 );
a3Val = _mm256_complexmul_ps( a3Val, z3 );
z0 = _mm256_complexmul_ps( z0, dz_reg );
z1 = _mm256_complexmul_ps( z1, dz_reg );
z2 = _mm256_complexmul_ps( z2, dz_reg );
z3 = _mm256_complexmul_ps( z3, dz_reg );
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7
x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8);
x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5
x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7
x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]);
x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]);
// TODO: it may be possible to rearrange swizzling to better pipeline data
b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3
b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7
b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20);
b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31);
c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]);
c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]);
c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]);
c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]);
dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]);
dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]);
dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]);
bPtr[vec_ind] += 16;
}
// Force the rotators back onto the unit circle
if ((number % 64) == 0)
{
z0 = _mm256_complexnormalise_ps( z0 );
z1 = _mm256_complexnormalise_ps( z1 );
z2 = _mm256_complexnormalise_ps( z2 );
z3 = _mm256_complexnormalise_ps( z3 );
}
aPtr += 32;
}
__VOLK_ATTR_ALIGNED(32) lv_32fc_t dotProductVector[4];
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]);
dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]);
_mm256_store_ps((float *)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector
result[ vec_ind ] = lv_cmake( 0, 0 );
for( i = 0; i < 4; ++i )
{
result[vec_ind] += dotProductVector[i];
}
}
z0 = _mm256_complexnormalise_ps( z0 );
_mm256_store_ps((float*)phase_vec, z0);
_phase = phase_vec[0];
_mm256_zeroupper();
number = sixteenthPoints*16;
for(;number < num_points; number++)
{
wo = (*aPtr++)*_phase;
_phase *= phase_inc;
for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind )
{
result[vec_ind] += wo * in_a[vec_ind][number];
}
}
*phase = _phase;
}
#endif /* LV_HAVE_AVX */
#endif /* INCLUDED_volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_H */

View File

@ -128,5 +128,35 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_u_avx(lv_3
#endif // AVX
#ifdef LV_HAVE_AVX
static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_a_avx(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points)
{
// phases must be normalized. Phase rotator expects a complex exponential input!
float rem_carrier_phase_in_rad = 0.25;
float phase_step_rad = 0.1;
lv_32fc_t phase[1];
phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad));
lv_32fc_t phase_inc[1];
phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad));
unsigned int n;
int num_a_vectors = 3;
float ** in_a = (float **)volk_gnsssdr_malloc(sizeof(float *) * num_a_vectors, volk_gnsssdr_get_alignment());
for(n = 0; n < num_a_vectors; n++)
{
in_a[n] = (float *)volk_gnsssdr_malloc(sizeof(float ) * num_points, volk_gnsssdr_get_alignment());
memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points);
}
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(result, local_code, phase_inc[0], phase, (const float**) in_a, num_a_vectors, num_points);
for(n = 0; n < num_a_vectors; n++)
{
volk_gnsssdr_free(in_a[n]);
}
volk_gnsssdr_free(in_a);
}
#endif // AVX
#endif // INCLUDED_volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_H

View File

@ -84,6 +84,7 @@ std::vector<volk_gnsssdr_test_case_t> init_test_list(volk_gnsssdr_test_params_t
(VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_dot_prod_16ic, test_params))
(VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_multiply_16ic, test_params_more_iters))
(VOLK_INIT_TEST(volk_gnsssdr_16ic_convert_32fc, test_params_more_iters))
(VOLK_INIT_TEST(volk_gnsssdr_16ic_conjugate_16ic, test_params_more_iters))
(VOLK_INIT_PUPP(volk_gnsssdr_s32f_sincospuppet_32fc, volk_gnsssdr_s32f_sincos_32fc, test_params_inacc2))
(VOLK_INIT_PUPP(volk_gnsssdr_16ic_rotatorpuppet_16ic, volk_gnsssdr_16ic_s32fc_x2_rotator_16ic, test_params_int1))
(VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastpuppet_16ic, volk_gnsssdr_16ic_resampler_fast_16ic, test_params))

View File

@ -31,6 +31,7 @@ include_directories(
${ARMADILLO_INCLUDE_DIRS}
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${MATIO_INCLUDE_DIRS}
)
file(GLOB OBS_GR_BLOCKS_HEADERS "*.h")
@ -38,4 +39,4 @@ list(SORT OBS_GR_BLOCKS_HEADERS)
add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS})
add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE})
target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES})
target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES})

View File

@ -38,6 +38,7 @@
#include <armadillo>
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <matio.h>
#include "Galileo_E1.h"
#include "GPS_L1_CA.h"
@ -104,6 +105,197 @@ hybrid_observables_cc::~hybrid_observables_cc()
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
}
}
if(d_dump == true)
{
std::cout << "Writing observables .mat files ...";
hybrid_observables_cc::save_matfile();
std::cout << " done." << std::endl;
}
}
int hybrid_observables_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 7;
int epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels;
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
double ** RX_time = new double * [d_nchannels];
double ** TOW_at_current_symbol_s = new double * [d_nchannels];
double ** Carrier_Doppler_hz = new double * [d_nchannels];
double ** Carrier_phase_cycles = new double * [d_nchannels];
double ** Pseudorange_m = new double * [d_nchannels];
double ** PRN = new double * [d_nchannels];
double ** Flag_valid_pseudorange = new double * [d_nchannels];
for(unsigned int i = 0; i < d_nchannels; i++)
{
RX_time[i] = new double [num_epoch];
TOW_at_current_symbol_s[i] = new double[num_epoch];
Carrier_Doppler_hz[i] = new double[num_epoch];
Carrier_phase_cycles[i] = new double[num_epoch];
Pseudorange_m[i] = new double[num_epoch];
PRN[i] = new double[num_epoch];
Flag_valid_pseudorange[i] = new double[num_epoch];
}
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
for(unsigned int chan = 0; chan < d_nchannels; chan++)
{
dump_file.read(reinterpret_cast<char *>(&RX_time[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_s[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&Carrier_Doppler_hz[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&Carrier_phase_cycles[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&Pseudorange_m[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[chan][i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&Flag_valid_pseudorange[chan][i]), sizeof(double));
}
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
for(unsigned int i = 0; i < d_nchannels; i++)
{
delete[] RX_time[i];
delete[] TOW_at_current_symbol_s[i];
delete[] Carrier_Doppler_hz[i];
delete[] Carrier_phase_cycles[i];
delete[] Pseudorange_m[i];
delete[] PRN[i];
delete[] Flag_valid_pseudorange[i];
}
delete[] RX_time;
delete[] TOW_at_current_symbol_s;
delete[] Carrier_Doppler_hz;
delete[] Carrier_phase_cycles;
delete[] Pseudorange_m;
delete[] PRN;
delete[] Flag_valid_pseudorange;
return 1;
}
double * RX_time_aux = new double [d_nchannels * num_epoch];
double * TOW_at_current_symbol_s_aux = new double [d_nchannels * num_epoch];
double * Carrier_Doppler_hz_aux = new double [d_nchannels * num_epoch];
double * Carrier_phase_cycles_aux = new double [d_nchannels * num_epoch];
double * Pseudorange_m_aux = new double [d_nchannels * num_epoch];
double * PRN_aux = new double [d_nchannels * num_epoch];
double * Flag_valid_pseudorange_aux = new double[d_nchannels * num_epoch];
unsigned int k = 0;
for(long int j = 0; j < num_epoch; j++ )
{
for(unsigned int i = 0; i < d_nchannels; i++ )
{
RX_time_aux[k] = RX_time[i][j];
TOW_at_current_symbol_s_aux[k] = TOW_at_current_symbol_s[i][j];
Carrier_Doppler_hz_aux[k] = Carrier_Doppler_hz[i][j];
Carrier_phase_cycles_aux[k] = Carrier_phase_cycles[i][j];
Pseudorange_m_aux[k] = Pseudorange_m[i][j];
PRN_aux[k] = PRN[i][j];
Flag_valid_pseudorange_aux[k] = Flag_valid_pseudorange[i][j];
k++;
}
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {static_cast<size_t>(d_nchannels), static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("TOW_at_current_symbol_s", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, TOW_at_current_symbol_s_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Carrier_Doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Carrier_Doppler_hz_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Carrier_phase_cycles", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Carrier_phase_cycles_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Pseudorange_m", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Pseudorange_m_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, PRN_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Flag_valid_pseudorange", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Flag_valid_pseudorange_aux, MAT_F_DONT_COPY_DATA);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
for(unsigned int i = 0; i < d_nchannels; i++)
{
delete[] RX_time[i];
delete[] TOW_at_current_symbol_s[i];
delete[] Carrier_Doppler_hz[i];
delete[] Carrier_phase_cycles[i];
delete[] Pseudorange_m[i];
delete[] PRN[i];
delete[] Flag_valid_pseudorange[i];
}
delete[] RX_time;
delete[] TOW_at_current_symbol_s;
delete[] Carrier_Doppler_hz;
delete[] Carrier_phase_cycles;
delete[] Pseudorange_m;
delete[] PRN;
delete[] Flag_valid_pseudorange;
delete[] RX_time_aux;
delete[] TOW_at_current_symbol_s_aux;
delete[] Carrier_Doppler_hz_aux;
delete[] Carrier_phase_cycles_aux;
delete[] Pseudorange_m_aux;
delete[] PRN_aux;
delete[] Flag_valid_pseudorange_aux;
return 0;
}
@ -149,7 +341,11 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused
double past_history_s = 100e-3;
Gnss_Synchro current_gnss_synchro[d_nchannels];
Gnss_Synchro aux = Gnss_Synchro();
for(unsigned int i = 0; i < d_nchannels; i++)
{
current_gnss_synchro[i] = aux;
}
/*
* 1. Read the GNSS SYNCHRO objects from available channels.
* Multi-rate GNURADIO Block. Read how many input items are avaliable in each channel
@ -339,13 +535,13 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz;
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI;
tmp_double = current_gnss_synchro[i].Carrier_phase_rads / GPS_TWO_PI;
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = current_gnss_synchro[i].Pseudorange_m;
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = current_gnss_synchro[i].PRN;
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange;
tmp_double = static_cast<double>(current_gnss_synchro[i].Flag_valid_pseudorange);
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
}
}
@ -384,3 +580,4 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused
return n_outputs;
}

View File

@ -72,6 +72,8 @@ private:
unsigned int history_deep;
std::string d_dump_filename;
std::ofstream d_dump_file;
int save_matfile();
};
#endif

View File

@ -21,36 +21,41 @@ list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS)
# Optional drivers
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
find_package(iio REQUIRED)
if(NOT IIO_FOUND)
message(STATUS "gnuradio-iio not found, its installation is required.")
message(STATUS "Please build and install the following projects:")
message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio")
message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio")
message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio")
message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled")
endif(NOT IIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
if(ENABLE_PLUTOSDR)
##############################################
# ADALM-PLUTO (Analog Devices Inc.)
##############################################
find_package(iio REQUIRED)
if(NOT IIO_FOUND)
message("gnuradio-iio not found, installation is required")
message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled")
else(NOT IIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
if(IIO_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc)
endif(NOT IIO_FOUND)
endif(IIO_FOUND)
endif(ENABLE_PLUTOSDR)
if(ENABLE_FMCOMMS2)
###############################################
# FMCOMMS2 based SDR Hardware
###############################################
find_package(iio REQUIRED)
if(NOT IIO_FOUND)
message("gnuradio-iio not found, installation is required")
message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled")
else(NOT IIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc plutosdr_signal_source.cc)
endif(NOT IIO_FOUND)
if(IIO_FOUND)
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc)
endif(IIO_FOUND)
endif(ENABLE_FMCOMMS2)
if(ENABLE_GN3S)
##############################################
# GN3S (USB dongle)
@ -134,7 +139,7 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc
gen_signal_source.cc
nsr_file_signal_source.cc
spir_file_signal_source.cc
rtl_tcp_signal_source.cc
rtl_tcp_signal_source.cc
${OPT_DRIVER_SOURCES}
)

View File

@ -30,11 +30,8 @@
*/
#include "fmcomms2_signal_source.h"
#include <cstdio>
#include <iostream>
#include <boost/format.hpp>
#include <glog/logging.h>
#include <gnuradio/blocks/file_sink.h>
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include "GPS_L1_CA.h"
@ -75,10 +72,10 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
item_size_ = sizeof(gr_complex);
std::cout << "device address: " << uri_ << std::endl;
std::cout << "LO frequency : " << freq_ << "Hz" << std::endl;
std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl;
std::cout << "LO frequency : " << freq_ << " Hz" << std::endl;
std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl;
if(item_type_.compare("gr_complex")==0)
if(item_type_.compare("gr_complex") == 0)
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
@ -92,7 +89,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
}
else
{
LOG(FATAL) << "Exception: item type " << item_type_ << " not suported!";
LOG(FATAL) << "Configuration error: item type " << item_type_ << " not supported!";
}
if (samples_ != 0)
@ -153,7 +150,7 @@ void Fmcomms2SignalSource::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(fmcomms2_source_f32c_, 0, file_sink_, 0);
top_block->disconnect(fmcomms2_source_f32c_, 0, file_sink_, 0);
}
}
}

View File

@ -37,7 +37,7 @@
#include <boost/shared_ptr.hpp>
#include <gnuradio/msg_queue.h>
#include <gnuradio/blocks/file_sink.h>
#include <iio/fmcomms2_source.h>
#include <gnuradio/iio/fmcomms2_source.h>
#include "gnss_block_interface.h"
class ConfigurationInterface;
@ -57,7 +57,7 @@ public:
}
/*!
* \brief Returns "fmcomms2_Signal_Source"
* \brief Returns "Fmcomms2_Signal_Source"
*/
inline std::string implementation() override
{

View File

@ -30,9 +30,7 @@
#include "plutosdr_signal_source.h"
#include <iostream>
#include <boost/format.hpp>
#include <glog/logging.h>
#include <gnuradio/blocks/file_sink.h>
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include "GPS_L1_CA.h"
@ -51,7 +49,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
std::string default_dump_file = "./data/signal_source.dat";
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
sample_rate_ configuration->property(role + ".sampling_frequency", 3000000);
sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000);
bandwidth_ = configuration->property(role + ".bandwidth", 2000000);
buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000);
decimation_ = configuration->property(role + ".decimation", 1);
@ -70,15 +68,15 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
if(item_type_.compare("gr_complex") != 0)
{
std::cout << "bad item_type!!" << std::endl;
LOG(FATAL) << "Exception: item type must be gr_complex!";
std::cout << "Configuration error: item_type must be gr_complex" << std::endl;
LOG(FATAL) << "Configuration error: item_type must be gr_complex!";
}
item_size_ = sizeof(gr_complex);
std::cout << "device address: " << uri_ << std::endl;
std::cout << "frequency : " << freq_ << "Hz" << std::endl;
std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl;
std::cout << "frequency : " << freq_ << " Hz" << std::endl;
std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl;
std::cout << "gain mode: " << gain_mode_ << std::endl;
std::cout << "item type: " << item_type_ << std::endl;

View File

@ -36,7 +36,7 @@
#include <boost/shared_ptr.hpp>
#include <gnuradio/msg_queue.h>
#include <gnuradio/blocks/file_sink.h>
#include <iio/pluto_source.h>
#include <gnuradio/iio/pluto_source.h>
#include "gnss_block_interface.h"
class ConfigurationInterface;

View File

@ -54,6 +54,7 @@ include_directories(
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
${OPT_TRACKING_INCLUDES}
${MATIO_INCLUDE_DIRS}
)
if(ENABLE_GENERIC_ARCH)
@ -65,7 +66,7 @@ list(SORT TRACKING_GR_BLOCKS_HEADERS)
add_library(tracking_gr_blocks ${TRACKING_GR_BLOCKS_SOURCES} ${TRACKING_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${TRACKING_GR_BLOCKS_HEADERS})
target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_TRACKING_LIBRARIES})
target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${MATIO_LIBRARIES} ${OPT_TRACKING_LIBRARIES})
if(NOT VOLK_GNSSSDR_FOUND)
add_dependencies(tracking_gr_blocks volk_gnsssdr_module)

View File

@ -42,6 +42,7 @@
#include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include "galileo_e1_signal_processing.h"
#include "tracking_discriminators.h"
@ -262,6 +263,18 @@ galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
galileo_e1_dll_pll_veml_tracking_cc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
@ -509,6 +522,228 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
}
int galileo_e1_dll_pll_veml_tracking_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 1;
int number_of_float_vars = 17;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_VE = new float [num_epoch];
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * abs_VL = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
float * acc_carrier_phase_rad = new float [num_epoch];
float * carrier_doppler_hz = new float [num_epoch];
float * code_freq_chips = new float [num_epoch];
float * carr_error_hz = new float [num_epoch];
float * carr_error_filt_hz = new float [num_epoch];
float * code_error_chips = new float [num_epoch];
float * code_error_filt_chips = new float [num_epoch];
float * CN0_SNV_dB_Hz = new float [num_epoch];
float * carrier_lock_test = new float [num_epoch];
float * aux1 = new float [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_VE[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_VL[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_VE;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] abs_VL;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_VL", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_VE;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] abs_VL;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
void galileo_e1_dll_pll_veml_tracking_cc::set_channel(unsigned int channel)
{

View File

@ -174,6 +174,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif //GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_CC_H

View File

@ -41,6 +41,7 @@
#include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include "galileo_e5_signal_processing.h"
#include "tracking_discriminators.h"
@ -224,6 +225,20 @@ Galileo_E5a_Dll_Pll_Tracking_cc::~Galileo_E5a_Dll_Pll_Tracking_cc()
LOG(WARNING)<<"Exception in destructor "<<ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
Galileo_E5a_Dll_Pll_Tracking_cc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
delete[] d_codeI;
@ -430,6 +445,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute
current_synchro_data.Carrier_phase_rads = 0.0;
current_synchro_data.CN0_dB_hz = 0.0;
current_synchro_data.fs = d_fs_in;
*out[0] = current_synchro_data;
consume_each(samples_offset); //shift input to perform alignment with local replica
return 1;
break;
@ -747,6 +763,213 @@ void Galileo_E5a_Dll_Pll_Tracking_cc::set_channel(unsigned int channel)
}
int Galileo_E5a_Dll_Pll_Tracking_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
void Galileo_E5a_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
{
d_acquisition_gnss_synchro = p_gnss_synchro;

View File

@ -204,6 +204,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif /* GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_CC_H_ */

View File

@ -36,6 +36,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <glog/logging.h>
@ -299,7 +300,6 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking()
gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc()
{
if (d_dump_file.is_open())
{
try
@ -311,6 +311,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
@ -326,6 +340,212 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc()
}
int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)

View File

@ -196,6 +196,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H

View File

@ -37,6 +37,7 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <glog/logging.h>
@ -309,6 +310,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga
LOG(WARNING)<< "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
@ -665,6 +680,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work(
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
tmp_double = static_cast<double>(d_sample_counter + d_correlation_length_samples);
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
// PRN
unsigned int prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char*>(&prn_), sizeof(unsigned int));
}
catch (const std::ifstream::failure* e)
{
@ -710,6 +729,212 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel)
}
int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro(
Gnss_Synchro* p_gnss_synchro)
{

View File

@ -178,6 +178,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_FPGA_SC_H

View File

@ -39,6 +39,7 @@
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <glog/logging.h>
#include <matio.h>
#include "gnss_synchro.h"
#include "gps_sdr_signal_processing.h"
#include "tracking_discriminators.h"
@ -313,6 +314,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
@ -330,6 +345,212 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc()
}
int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)

View File

@ -200,6 +200,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H

View File

@ -43,6 +43,7 @@
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <matio.h>
#include "gps_sdr_signal_processing.h"
#include "tracking_discriminators.h"
#include "lock_detectors.h"
@ -266,6 +267,213 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking()
}
int Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc()
{
if (d_dump_file.is_open())
@ -279,6 +487,20 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
@ -291,6 +513,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc()
{
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
@ -443,7 +666,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute__
d_correlator_outs[n] = gr_complex(0,0);
}
current_synchro_data.Tracking_sample_counter =d_sample_counter + d_current_prn_length_samples;
current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples;
current_synchro_data.System = {'G'};
current_synchro_data.correlation_length_ms = 1;
}

View File

@ -101,6 +101,7 @@ private:
float dll_bw_hz,
float early_late_space_chips);
int save_matfile();
// tracking configuration vars
unsigned int d_vector_length;
bool d_dump;

View File

@ -42,6 +42,7 @@
#include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include "gps_l2c_signal.h"
#include "tracking_discriminators.h"
@ -269,6 +270,213 @@ void gps_l2_m_dll_pll_tracking_cc::start_tracking()
}
int gps_l2_m_dll_pll_tracking_cc::save_matfile()
{
// READ DUMP FILE
std::ifstream::pos_type size;
int number_of_double_vars = 11;
int number_of_float_vars = 5;
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
std::ifstream dump_file;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
}
catch(const std::ifstream::failure &e)
{
std::cerr << "Problem opening dump file:" << e.what() << std::endl;
return 1;
}
// count number of epochs and rewind
long int num_epoch = 0;
if (dump_file.is_open())
{
size = dump_file.tellg();
num_epoch = static_cast<long int>(size) / static_cast<long int>(epoch_size_bytes);
dump_file.seekg(0, std::ios::beg);
}
else
{
return 1;
}
float * abs_E = new float [num_epoch];
float * abs_P = new float [num_epoch];
float * abs_L = new float [num_epoch];
float * Prompt_I = new float [num_epoch];
float * Prompt_Q = new float [num_epoch];
unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch];
double * acc_carrier_phase_rad = new double [num_epoch];
double * carrier_doppler_hz = new double [num_epoch];
double * code_freq_chips = new double [num_epoch];
double * carr_error_hz = new double [num_epoch];
double * carr_error_filt_hz = new double [num_epoch];
double * code_error_chips = new double [num_epoch];
double * code_error_filt_chips = new double [num_epoch];
double * CN0_SNV_dB_Hz = new double [num_epoch];
double * carrier_lock_test = new double [num_epoch];
double * aux1 = new double [num_epoch];
double * aux2 = new double [num_epoch];
unsigned int * PRN = new unsigned int [num_epoch];
try
{
if (dump_file.is_open())
{
for(long int i = 0; i < num_epoch; i++)
{
dump_file.read(reinterpret_cast<char *>(&abs_E[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_P[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&abs_L[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_I[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&Prompt_Q[i]), sizeof(float));
dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count[i]), sizeof(unsigned long int));
dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_freq_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&carrier_lock_test[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux1[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&aux2[i]), sizeof(double));
dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(unsigned int));
}
}
dump_file.close();
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem reading dump file:" << e.what() << std::endl;
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 1;
}
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = d_dump_filename;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
if(reinterpret_cast<long*>(matfp) != NULL)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
}
Mat_Close(matfp);
delete[] abs_E;
delete[] abs_P;
delete[] abs_L;
delete[] Prompt_I;
delete[] Prompt_Q;
delete[] PRN_start_sample_count;
delete[] acc_carrier_phase_rad;
delete[] carrier_doppler_hz;
delete[] code_freq_chips;
delete[] carr_error_hz;
delete[] carr_error_filt_hz;
delete[] code_error_chips;
delete[] code_error_filt_chips;
delete[] CN0_SNV_dB_Hz;
delete[] carrier_lock_test;
delete[] aux1;
delete[] aux2;
delete[] PRN;
return 0;
}
gps_l2_m_dll_pll_tracking_cc::~gps_l2_m_dll_pll_tracking_cc()
{
if (d_dump_file.is_open())
@ -282,6 +490,18 @@ gps_l2_m_dll_pll_tracking_cc::~gps_l2_m_dll_pll_tracking_cc()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if(d_dump)
{
if(d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
gps_l2_m_dll_pll_tracking_cc::save_matfile();
if(d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);

View File

@ -162,6 +162,8 @@ private:
std::map<std::string, std::string> systemName;
std::string sys;
int save_matfile();
};
#endif //GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_CC_H

View File

@ -41,6 +41,58 @@ if(ENABLE_FPGA)
endif(ENABLE_FPGA)
if(Boost_VERSION LESS 105000)
add_definitions(-DOLD_BOOST=1)
endif(Boost_VERSION LESS 105000)
if(OPENSSL_FOUND)
add_definitions( -DUSE_OPENSSL_FALLBACK=1 )
endif(OPENSSL_FOUND)
if(ENABLE_GN3S)
add_definitions(-DGN3S_DRIVER=1)
endif(ENABLE_GN3S)
if(ENABLE_ARRAY)
add_definitions(-DRAW_ARRAY_DRIVER=1)
endif(ENABLE_ARRAY)
if(ENABLE_FLEXIBAND)
add_definitions(-DFLEXIBAND_DRIVER=1)
endif(ENABLE_FLEXIBAND)
if(ENABLE_OSMOSDR)
if(GROSMOSDR_FOUND)
add_definitions(-DOSMOSDR_DRIVER=1)
endif(GROSMOSDR_FOUND)
endif(ENABLE_OSMOSDR)
if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd)
add_definitions(-DUHD_DRIVER=1)
endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd)
#Enable OpenCL if found in the system
if(OPENCL_FOUND)
message(STATUS "Adding processing blocks implemented using OpenCL" )
add_definitions(-DOPENCL_BLOCKS=1)
else(OPENCL_FOUND)
add_definitions(-DOPENCL_BLOCKS=0)
endif(OPENCL_FOUND)
#enable SDR Hardware based on fmcomms2
if(ENABLE_PLUTOSDR)
add_definitions(-DPLUTOSDR_DRIVER=1)
set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
endif(ENABLE_PLUTOSDR)
if(ENABLE_FMCOMMS2)
add_definitions(-DFMCOMMS2_DRIVER=1)
set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
endif(ENABLE_FMCOMMS2)
add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/core/system_parameters
@ -86,56 +138,6 @@ include_directories(
${VOLK_GNSSSDR_INCLUDE_DIRS}
)
if(Boost_VERSION LESS 105000)
add_definitions(-DOLD_BOOST=1)
endif(Boost_VERSION LESS 105000)
if(OPENSSL_FOUND)
add_definitions( -DUSE_OPENSSL_FALLBACK=1 )
endif(OPENSSL_FOUND)
if(ENABLE_GN3S)
add_definitions(-DGN3S_DRIVER=1)
endif(ENABLE_GN3S)
if(ENABLE_ARRAY)
add_definitions(-DRAW_ARRAY_DRIVER=1)
endif(ENABLE_ARRAY)
if(ENABLE_FLEXIBAND)
add_definitions(-DFLEXIBAND_DRIVER=1)
endif(ENABLE_FLEXIBAND)
if(ENABLE_OSMOSDR)
if(GROSMOSDR_FOUND)
add_definitions(-DOSMOSDR_DRIVER=1)
endif(GROSMOSDR_FOUND)
endif(ENABLE_OSMOSDR)
if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd)
add_definitions(-DUHD_DRIVER=1)
endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd)
#Enable OpenCL if found in the system
if(OPENCL_FOUND)
message(STATUS "Adding processing blocks implemented using OpenCL" )
add_definitions(-DOPENCL_BLOCKS=1)
else(OPENCL_FOUND)
add_definitions(-DOPENCL_BLOCKS=0)
endif(OPENCL_FOUND)
#enable SDR Hardware based on fmcomms2
if(ENABLE_PLUTOSDR)
add_definitions(-DPLUTOSDR_DRIVER=1)
endif(ENABLE_PLUTOSDR)
if(ENABLE_FMCOMMS2)
add_definitions(-DFMCOMMS2_DRIVER=1)
add_definitions(-DPLUTOSDR_DRIVER=1)
endif(ENABLE_FMCOMMS2)
add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}")
file(GLOB GNSS_RECEIVER_HEADERS "*.h")
list(SORT GNSS_RECEIVER_HEADERS)
file(GLOB GNSS_RECEIVER_INTERFACE_HEADERS "../interfaces/*.h")

View File

@ -47,15 +47,13 @@ endif(EXISTS $ENV{OECORE_TARGET_SYSROOT})
if(NOT ${GTEST_DIR_LOCAL})
# if GTEST_DIR is not defined, we download and build it
set(gtest_RELEASE 1.8.0)
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gtest-${gtest_RELEASE}
gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-${gtest_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}
GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG}
UPDATE_COMMAND ""
PATCH_COMMAND ""
@ -63,41 +61,41 @@ if(NOT ${GTEST_DIR_LOCAL})
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gtest-${gtest_RELEASE}
gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-${gtest_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}
GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG}
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}
INSTALL_COMMAND ""
)
endif(CMAKE_VERSION VERSION_LESS 3.2)
# Set up variables
# Set recently downloaded and build Googletest root folder
set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}/googletest")
set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest")
# Source code
ExternalProject_Get_Property(gtest-${gtest_RELEASE} source_dir)
ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} source_dir)
set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src)
# Library
ExternalProject_Get_Property(gtest-${gtest_RELEASE} binary_dir)
ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} binary_dir)
if(OS_IS_MACOSX)
if(CMAKE_GENERATOR STREQUAL Xcode)
set(binary_dir "${binary_dir}/Debug")
endif(CMAKE_GENERATOR STREQUAL Xcode)
endif(OS_IS_MACOSX)
set(GTEST_LIBRARY_PATH "${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX};${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GTEST_LIBRARY gtest-${gtest_RELEASE})
set(GTEST_LIBRARY gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
set(GTEST_LIBRARIES
${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}
)
set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest")
set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest")
else(NOT ${GTEST_DIR_LOCAL})
if(GTEST_INCLUDE_DIRS)
set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR})
@ -163,6 +161,12 @@ if(GNUPLOT_FOUND)
add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}")
endif(GNUPLOT_FOUND)
if(MATIO_FOUND OR MATIO_LOCAL)
add_definitions(-DMATIO_TEST=1)
set(GNSS_SDR_TEST_OPTIONAL_LIBS "${GNSS_SDR_TEST_OPTIONAL_LIBS};${MATIO_LIBRARIES}")
set(GNSS_SDR_TEST_OPTIONAL_HEADERS "${GNSS_SDR_TEST_OPTIONAL_HEADERS};${MATIO_INCLUDE_DIRS}")
endif(MATIO_FOUND OR MATIO_LOCAL)
################################################################################
# Optional generator
################################################################################
@ -178,7 +182,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
ExternalProject_Add(
gnss-sim
GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator
GIT_TAG master
GIT_TAG ${GNSSSDR_GNSS_SIM_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gnss-sim
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR}
@ -207,38 +211,36 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
find_package(GPSTK)
if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK)
if(NOT ENABLE_FPGA)
set(gpstk_RELEASE "2.9")
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gpstk-${gpstk_RELEASE}
gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/SGL-UT/GPSTk
GIT_TAG v${gpstk_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${gpstk_RELEASE}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF
GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF
UPDATE_COMMAND ""
PATCH_COMMAND ""
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
gpstk-${gpstk_RELEASE}
gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/SGL-UT/GPSTk
GIT_TAG v${gpstk_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${gpstk_RELEASE}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}
GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}
UPDATE_COMMAND ""
PATCH_COMMAND ""
)
endif(CMAKE_VERSION VERSION_LESS 3.2)
set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/include CACHE PATH "Local GPSTK headers")
set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers")
add_library(gpstk UNKNOWN IMPORTED)
set_property(TARGET gpstk PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX})
add_dependencies(gpstk gpstk-${gpstk_RELEASE})
set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/bin/ )
set_property(TARGET gpstk PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX})
add_dependencies(gpstk gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION})
set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/ )
add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}")
set(gpstk_libs gpstk)
set(OWN_GPSTK True)
@ -327,7 +329,6 @@ include_directories(
${VOLK_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
${GNSS_SDR_TEST_OPTIONAL_HEADERS}
${GNSS_SDR_TEST_OPTIONAL_HEADERS}
)
@ -364,7 +365,7 @@ if(ENABLE_UNIT_TESTING)
${GNSS_SDR_TEST_OPTIONAL_LIBS}
)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(run_tests gtest-${gtest_RELEASE})
add_dependencies(run_tests gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
endif(NOT ${GTEST_DIR_LOCAL})
if(ENABLE_INSTALL_TESTS)
@ -418,13 +419,20 @@ if(ENABLE_SYSTEM_TESTING)
set(HOST_SYSTEM "MacOS")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-DHOST_SYSTEM="${HOST_SYSTEM}")
add_executable(ttff
${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc )
set(TTFF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc)
# Ensure that ttff is rebuilt if it was previously built and then removed
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${TTFF_SOURCES})
endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff)
add_executable(ttff ${TTFF_SOURCES} )
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(ttff gtest-${gtest_RELEASE})
add_dependencies(ttff gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(ttff gtest)
endif(NOT ${GTEST_DIR_LOCAL})
target_link_libraries(ttff
${Boost_LIBRARIES}
${GFlags_LIBS}
@ -452,10 +460,14 @@ if(ENABLE_SYSTEM_TESTING)
endif(ENABLE_INSTALL_TESTS)
if(ENABLE_SYSTEM_TESTING_EXTRA)
add_executable(position_test
${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc )
set(POSITION_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc)
# Ensure that position_test is rebuilt if it was previously built and then removed
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${POSITION_TEST_SOURCES})
endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
add_executable(position_test ${POSITION_TEST_SOURCES})
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(position_test gtest-${gtest_RELEASE})
add_dependencies(position_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(position_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
@ -486,13 +498,28 @@ if(ENABLE_SYSTEM_TESTING)
endif(ENABLE_INSTALL_TESTS)
if(GPSTK_FOUND OR OWN_GPSTK)
add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc)
set(OBS_GPS_L1_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc)
# Ensure that obs_gps_l1_system_test is rebuilt if it was previously built and then removed
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_GPS_L1_TEST_SOURCES})
endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
add_executable(obs_gps_l1_system_test ${OBS_GPS_L1_TEST_SOURCES})
set(OBS_SYSTEM_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_system_test.cc)
# Ensure that obs_system_test is rebuilt if it was previously built and then removed
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_SYSTEM_TEST_SOURCES})
endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
add_executable(obs_system_test ${OBS_SYSTEM_TEST_SOURCES})
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(obs_gps_l1_system_test gtest-${gtest_RELEASE} )
add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} )
add_dependencies(obs_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} )
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(obs_gps_l1_system_test gtest)
add_dependencies(obs_system_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
include_directories(${GPSTK_INCLUDE_DIRS})
include_directories(${GPSTK_INCLUDE_DIRS} ${GPSTK_INCLUDE_DIRS}/gpstk)
target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS}
${GLOG_LIBRARIES}
${GTEST_LIBRARIES}
@ -500,19 +527,59 @@ if(ENABLE_SYSTEM_TESTING)
gnss_rx
${gpstk_libs})
target_link_libraries(obs_system_test ${GFlags_LIBS}
${GLOG_LIBRARIES}
${GTEST_LIBRARIES}
gnss_sp_libs
gnss_rx
${gpstk_libs})
if(ENABLE_INSTALL_TESTS)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
install(TARGETS obs_gps_l1_system_test RUNTIME DESTINATION bin COMPONENT "obs_gps_l1_system_test")
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
install(TARGETS obs_system_test RUNTIME DESTINATION bin COMPONENT "obs_system_test")
else(ENABLE_INSTALL_TESTS)
add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:obs_gps_l1_system_test>
${CMAKE_SOURCE_DIR}/install/$<TARGET_FILE_NAME:obs_gps_l1_system_test> )
add_custom_command(TARGET obs_system_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:obs_system_test>
${CMAKE_SOURCE_DIR}/install/$<TARGET_FILE_NAME:obs_system_test> )
endif(ENABLE_INSTALL_TESTS)
endif(GPSTK_FOUND OR OWN_GPSTK)
else(ENABLE_SYSTEM_TESTING_EXTRA)
# Avoid working with old executables if they were switched ON and then OFF
if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
endif(ENABLE_SYSTEM_TESTING_EXTRA)
else(ENABLE_SYSTEM_TESTING)
# Avoid working with old executables if they were switched ON and then OFF
if(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test)
if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test)
endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test)
endif(ENABLE_SYSTEM_TESTING)
@ -538,7 +605,7 @@ if(NOT ${ENABLE_PACKAGING})
)
add_test(control_thread_test control_thread_test)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(control_thread_test gtest-${gtest_RELEASE})
add_dependencies(control_thread_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(control_thread_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
@ -560,7 +627,7 @@ if(NOT ${ENABLE_PACKAGING})
${VOLK_GNSSSDR_LIBRARIES} )
add_test(flowgraph_test flowgraph_test)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(flowgraph_test gtest-${gtest_RELEASE})
add_dependencies(flowgraph_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(flowgraph_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
@ -595,7 +662,7 @@ if(NOT ${ENABLE_PACKAGING})
)
add_test(gnss_block_test gnss_block_test)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(gnss_block_test gtest-${gtest_RELEASE})
add_dependencies(gnss_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(gnss_block_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
@ -620,7 +687,7 @@ target_link_libraries(gnuradio_block_test ${Boost_LIBRARIES}
)
add_test(gnuradio_block_test gnuradio_block_test)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(gnuradio_block_test gtest-${gtest_RELEASE})
add_dependencies(gnuradio_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(gnuradio_block_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})
@ -666,7 +733,7 @@ target_link_libraries(trk_test ${Boost_LIBRARIES}
)
add_test(trk_test trk_test)
if(NOT ${GTEST_DIR_LOCAL})
add_dependencies(trk_test gtest-${gtest_RELEASE})
add_dependencies(trk_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION})
else(NOT ${GTEST_DIR_LOCAL})
add_dependencies(trk_test gtest)
endif(NOT ${GTEST_DIR_LOCAL})

View File

@ -1895,12 +1895,13 @@ bool Gnuplot::get_program_path()
else
{
std::list<std::string> ls;
std::string path_str = path;
//split path (one long string) into list ls of strings
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
stringtok(ls,path,";");
stringtok(ls,path_str,";");
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
stringtok(ls,path,":");
stringtok(ls,path_str,":");
#endif
// scan list for Gnuplot program files
@ -1921,10 +1922,8 @@ bool Gnuplot::get_program_path()
tmp = "Can't find gnuplot neither in PATH nor in \"" +
Gnuplot::m_sGNUPlotPath + "\"";
throw GnuplotException(tmp);
Gnuplot::m_sGNUPlotPath = "";
return false;
throw GnuplotException(tmp);
}
}
@ -2046,7 +2045,6 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp)
std::ostringstream except;
except << "Cannot create temporary file \"" << name << "\"";
throw GnuplotException(except.str());
return "";
}
//
@ -2064,7 +2062,8 @@ void Gnuplot::remove_tmpfiles()
if ((tmpfile_list).size() > 0)
{
for (unsigned int i = 0; i < tmpfile_list.size(); i++)
remove( tmpfile_list[i].c_str() );
if(remove( tmpfile_list[i].c_str() ) != 0)
std::cout << "Problem closing files" << std::endl;
Gnuplot::tmpfile_num -= tmpfile_list.size();
}

View File

@ -41,11 +41,11 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "RinexUtilities.hpp"
#include "Rinex3ObsBase.hpp"
#include "Rinex3ObsData.hpp"
#include "Rinex3ObsHeader.hpp"
#include "Rinex3ObsStream.hpp"
#include <gpstk/RinexUtilities.hpp>
#include <gpstk/Rinex3ObsBase.hpp>
#include <gpstk/Rinex3ObsData.hpp>
#include <gpstk/Rinex3ObsHeader.hpp>
#include <gpstk/Rinex3ObsStream.hpp>
#include "concurrent_map.h"
#include "concurrent_queue.h"
#include "control_thread.h"
@ -513,7 +513,7 @@ void ObsGpsL1SystemTest::check_results()
// If a measure exists for this sow, store it
for(it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++)
{
if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms.
if(std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms.
{
pseudorange_ref_aligned.at(prn_id).push_back(*it);
pr_diff.at(prn_id).push_back(it->second - it2->second );
@ -532,7 +532,7 @@ void ObsGpsL1SystemTest::check_results()
// If a measure exists for this sow, store it
for(it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++)
{
if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms.
if(std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms.
{
carrierphase_ref_aligned.at(prn_id).push_back(*it);
cp_diff.at(prn_id).push_back(it->second - it2->second );

View File

@ -0,0 +1,939 @@
/*!
* \file obs_system_test.cc
* \brief This class implements a test for the validation of generated observables.
* \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es
* Antonio Ramos, 2017. antonio.ramos(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include <algorithm>
#include <chrono>
#include <boost/filesystem.hpp>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <numeric>
#include <string>
#include <thread>
#include <unistd.h>
#include <armadillo>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <gpstk/RinexUtilities.hpp>
#include <gpstk/Rinex3ObsBase.hpp>
#include <gpstk/Rinex3ObsData.hpp>
#include <gpstk/Rinex3ObsHeader.hpp>
#include <gpstk/Rinex3ObsStream.hpp>
#include "gnuplot_i.h"
#include "test_flags.h"
#include "concurrent_map.h"
#include "concurrent_queue.h"
#include "control_thread.h"
#include "file_configuration.h"
// For GPS NAVIGATION (L1)
concurrent_queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
DEFINE_string(configuration_file, "./default_configuration.conf", "Path of configuration file");
DEFINE_string(filename_rinex_true, "./default_rinex.txt", "Path of RINEX true observations");
DEFINE_string(filename_rinex_obs, "default_string", "Path of RINEX true observations");
DEFINE_double(pr_error_mean_max, 25.0, "Maximum mean error in pseudorange");
DEFINE_double(pr_error_std_max, 5.0, "Maximum standard deviation in pseudorange");
DEFINE_double(cp_error_mean_max, 5.0, "Maximum mean error in carrier phase");
DEFINE_double(cp_error_std_max, 2.5, "Maximum standard deviation in carrier phase");
DEFINE_double(dp_error_mean_max, 75.0, "Maximum mean error in Doppler frequency");
DEFINE_double(dp_error_std_max, 25.0, "Maximum standard deviation in Doppler frequency");
DEFINE_bool(plot_obs_sys_test, false, "Plots results of ObsSystemTest with gnuplot");
class ObsSystemTest: public ::testing::Test
{
public:
int configure_receiver();
int run_receiver();
void check_results();
bool check_valid_rinex_obs(std::string filename, int rinex_ver); // return true if the file is a valid Rinex observation file.
void read_rinex_files(
std::vector<arma::mat>& pseudorange_ref,
std::vector<arma::mat>& carrierphase_ref,
std::vector<arma::mat>& doppler_ref,
std::vector<arma::mat>& pseudorange_meas,
std::vector<arma::mat>& carrierphase_meas,
std::vector<arma::mat>& doppler_meas,
arma::mat& sow_prn_ref,
int signal_type);
void time_alignment_diff(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff);
void time_alignment_diff_cp(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff);
void time_alignment_diff_pr(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff,
arma::mat& sow_prn_ref);
void compute_pseudorange_error(std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name);
void compute_carrierphase_error(
std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name);
void compute_doppler_error(
std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name);
std::string filename_rinex_obs = FLAGS_filename_rinex_true;
std::string generated_rinex_obs = FLAGS_filename_rinex_obs;
std::string configuration_file_ = FLAGS_configuration_file;
std::shared_ptr<FileConfiguration> config;
bool gps_1C = false;
bool gps_L5 = false;
bool gal_1B = false;
bool gal_E5a = false;
bool internal_rinex_generation = false;
/****************/
const int num_prn_gps = 33;
const int num_prn_gal = 31;
double pseudorange_error_th_mean = FLAGS_pr_error_mean_max;
double pseudorange_error_th_std= FLAGS_pr_error_std_max;
double carrierphase_error_th_mean = FLAGS_cp_error_mean_max;
double carrierphase_error_th_std = FLAGS_cp_error_std_max;
double doppler_error_th_mean = FLAGS_dp_error_mean_max;
double doppler_error_th_std = FLAGS_dp_error_std_max;
};
bool ObsSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver)
{
bool res = false;
if(rinex_ver == 2)
{
res = gpstk::isRinexObsFile(filename);
}
if(rinex_ver == 3)
{
res = gpstk::isRinex3ObsFile(filename);
}
return res;
}
void ObsSystemTest::read_rinex_files(
std::vector<arma::mat>& pseudorange_ref,
std::vector<arma::mat>& carrierphase_ref,
std::vector<arma::mat>& doppler_ref,
std::vector<arma::mat>& pseudorange_meas,
std::vector<arma::mat>& carrierphase_meas,
std::vector<arma::mat>& doppler_meas,
arma::mat& sow_prn_ref,
int signal_type)
{
bool ref_exist = false;
bool meas_exist = false;
gpstk::SatID::SatelliteSystem sat_type = gpstk::SatID::systemUnknown;
int max_prn = 0;
std::string pr_string;
std::string cp_string;
std::string dp_string;
std::string signal_type_string;
sow_prn_ref.reset();
switch(signal_type)
{
case 0: //GPS L1
sat_type = gpstk::SatID::systemGPS;
max_prn = num_prn_gps;
pr_string = "C1C";
cp_string = "L1C";
dp_string = "D1C";
signal_type_string = "GPS L1 C/A";
break;
case 1: //Galileo E1B
sat_type = gpstk::SatID::systemGalileo;
max_prn = num_prn_gal;
pr_string = "C1B";
cp_string = "L1B";
dp_string = "D1B";
signal_type_string = "Galileo E1B";
break;
case 2: //GPS L5
sat_type = gpstk::SatID::systemGPS;
max_prn = num_prn_gps;
pr_string = "C5X";
cp_string = "L5X";
dp_string = "D5X";
signal_type_string = "GPS L5";
break;
case 3: //Galileo E5a
sat_type = gpstk::SatID::systemGalileo;
max_prn = num_prn_gal;
pr_string = "C5X";
cp_string = "L5X";
dp_string = "D5X";
signal_type_string = "Galileo E5a";
break;
}
// Open and read reference RINEX observables file
std::cout << "Read: RINEX " << signal_type_string << " True" << std::endl;
try
{
gpstk::Rinex3ObsStream r_ref(filename_rinex_obs);
r_ref.exceptions(std::ios::failbit);
gpstk::Rinex3ObsData r_ref_data;
gpstk::Rinex3ObsHeader r_ref_header;
gpstk::RinexDatum dataobj;
r_ref >> r_ref_header;
while (r_ref >> r_ref_data)
{
for (int myprn = 1; myprn < max_prn; myprn++)
{
gpstk::SatID prn( myprn, sat_type);
gpstk::CommonTime time = r_ref_data.time;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn);
if( pointer == r_ref_data.obs.end() )
{
// PRN not present; do nothing
}
else
{
dataobj = r_ref_data.getObs(prn, pr_string, r_ref_header);
double P1 = dataobj.data;
pseudorange_ref.at(myprn).insert_rows(pseudorange_ref.at(myprn).n_rows, arma::rowvec({sow, P1}));
dataobj = r_ref_data.getObs(prn, cp_string, r_ref_header);
double L1 = dataobj.data;
carrierphase_ref.at(myprn).insert_rows(carrierphase_ref.at(myprn).n_rows, arma::rowvec({sow, L1}));
dataobj = r_ref_data.getObs(prn, dp_string, r_ref_header);
double D1 = dataobj.data;
doppler_ref.at(myprn).insert_rows(doppler_ref.at(myprn).n_rows, arma::rowvec({sow, D1}));
ref_exist = true;
} // End of 'if( pointer == roe.obs.end() )'
} // end for
} // end while
} // End of 'try' block
catch(const gpstk::FFStreamError& e)
{
std::cout << e;
exit(1);
}
catch(const gpstk::Exception& e)
{
std::cout << e;
exit(1);
}
catch (...)
{
std::cout << "unknown error. I don't feel so well..." << std::endl;
exit(1);
}
// Open and read measured RINEX observables file
std::cout << "Read: RINEX "<< signal_type_string << " measures" << std::endl;
try
{
std::string arg2_gen;
if(internal_rinex_generation)
{
arg2_gen = std::string("./") + generated_rinex_obs;
}
else
{
arg2_gen = generated_rinex_obs;
}
gpstk::Rinex3ObsStream r_meas(arg2_gen);
r_meas.exceptions(std::ios::failbit);
gpstk::Rinex3ObsData r_meas_data;
gpstk::Rinex3ObsHeader r_meas_header;
gpstk::RinexDatum dataobj;
r_meas >> r_meas_header;
while (r_meas >> r_meas_data)
{
double pr_min = 0.0;
double sow_insert = 0.0;
double prn_min = 0.0;
bool set_pr_min = true;
for (int myprn = 1; myprn < max_prn; myprn++)
{
gpstk::SatID prn( myprn, sat_type);
gpstk::CommonTime time = r_meas_data.time;
double sow(static_cast<gpstk::GPSWeekSecond>(time).sow);
gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn);
if( pointer == r_meas_data.obs.end() )
{
// PRN not present; do nothing
}
else
{
dataobj = r_meas_data.getObs(prn, pr_string, r_meas_header);
double P1 = dataobj.data;
pseudorange_meas.at(myprn).insert_rows(pseudorange_meas.at(myprn).n_rows, arma::rowvec({sow, P1}));
if(set_pr_min || (P1 < pr_min))
{
set_pr_min = false;
pr_min = P1;
sow_insert = sow;
prn_min = static_cast<double>(myprn);
}
dataobj = r_meas_data.getObs(prn, cp_string, r_meas_header);
double L1 = dataobj.data;
carrierphase_meas.at(myprn).insert_rows(carrierphase_meas.at(myprn).n_rows, arma::rowvec({sow, L1}));
dataobj = r_meas_data.getObs(prn, dp_string, r_meas_header);
double D1 = dataobj.data;
doppler_meas.at(myprn).insert_rows(doppler_meas.at(myprn).n_rows, arma::rowvec({sow, D1}));
meas_exist = true;
} // End of 'if( pointer == roe.obs.end() )'
} // end for
sow_prn_ref.insert_rows(sow_prn_ref.n_rows, arma::rowvec({sow_insert, pr_min, prn_min}));
} // end while
} // End of 'try' block
catch(const gpstk::FFStreamError& e)
{
std::cout << e;
exit(1);
}
catch(const gpstk::Exception& e)
{
std::cout << e;
exit(1);
}
catch (...)
{
std::cout << "unknown error. I don't feel so well..." << std::endl;
exit(1);
}
EXPECT_TRUE(ref_exist) << "RINEX reference file does not contain " << signal_type_string << " information";
EXPECT_TRUE(meas_exist) << "RINEX generated file does not contain " << signal_type_string << " information";
}
void ObsSystemTest::time_alignment_diff(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff)
{
std::vector<arma::mat>::iterator iter_ref;
std::vector<arma::mat>::iterator iter_meas;
std::vector<arma::vec>::iterator iter_diff;
arma::mat mat_aux;
iter_ref = ref.begin();
iter_diff = diff.begin();
for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++)
{
if( !iter_meas->is_empty() && !iter_ref->is_empty() )
{
arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0));
arma::uword index_min = arma::min(index_);
index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0));
arma::uword index_max = arma::max(index_);
mat_aux = iter_meas->rows(index_min, index_max);
arma::vec ref_aligned;
arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned);
*iter_diff = ref_aligned - mat_aux.col(1);
}
iter_ref++;
iter_diff++;
}
}
void ObsSystemTest::time_alignment_diff_cp(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff)
{
std::vector<arma::mat>::iterator iter_ref;
std::vector<arma::mat>::iterator iter_meas;
std::vector<arma::vec>::iterator iter_diff;
arma::mat mat_aux;
iter_ref = ref.begin();
iter_diff = diff.begin();
for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++)
{
if( !iter_meas->is_empty() && !iter_ref->is_empty() )
{
arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0));
arma::uword index_min = arma::min(index_);
index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0));
arma::uword index_max = arma::max(index_);
mat_aux = iter_meas->rows(index_min, index_max);
mat_aux.col(1) -= arma::min(mat_aux.col(1));
arma::vec ref_aligned;
arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned);
ref_aligned -= arma::min(ref_aligned);
*iter_diff = ref_aligned - mat_aux.col(1);
}
iter_ref++;
iter_diff++;
}
}
void ObsSystemTest::time_alignment_diff_pr(
std::vector<arma::mat>& ref,
std::vector<arma::mat>& meas,
std::vector<arma::vec>& diff,
arma::mat& sow_prn_ref)
{
std::vector<arma::mat>::iterator iter_ref;
std::vector<arma::mat>::iterator iter_meas;
std::vector<arma::vec>::iterator iter_diff;
arma::mat mat_aux;
arma::vec subtraction_meas;
arma::vec subtraction_ref;
arma::mat subtraction_pr_ref = sow_prn_ref;
arma::vec::iterator iter_vec0 = subtraction_pr_ref.begin_col(0);
arma::vec::iterator iter_vec1 = subtraction_pr_ref.begin_col(1);
arma::vec::iterator iter_vec2 = subtraction_pr_ref.begin_col(2);
for(iter_vec1 = subtraction_pr_ref.begin_col(1); iter_vec1 != subtraction_pr_ref.end_col(1); iter_vec1++)
{
arma::vec aux_pr; //vector with only 1 element
arma::vec aux_sow = {*iter_vec0}; //vector with only 1 element
arma::interp1(ref.at(static_cast<int>(*iter_vec2)).col(0),
ref.at(static_cast<int>(*iter_vec2)).col(1),
aux_sow,
aux_pr);
*iter_vec1 = aux_pr(0);
iter_vec0++;
iter_vec2++;
}
iter_ref = ref.begin();
iter_diff = diff.begin();
for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++)
{
if( !iter_meas->is_empty() && !iter_ref->is_empty() )
{
arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0));
arma::uword index_min = arma::min(index_);
index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0));
arma::uword index_max = arma::max(index_);
mat_aux = iter_meas->rows(index_min, index_max);
arma::interp1(sow_prn_ref.col(0), sow_prn_ref.col(1), mat_aux.col(0), subtraction_meas);
mat_aux.col(1) -= subtraction_meas;
arma::vec ref_aligned;
arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned);
arma::interp1(subtraction_pr_ref.col(0), subtraction_pr_ref.col(1), mat_aux.col(0), subtraction_ref);
ref_aligned -= subtraction_ref;
*iter_diff = ref_aligned - mat_aux.col(1);
}
iter_ref++;
iter_diff++;
}
}
int ObsSystemTest::configure_receiver()
{
config = std::make_shared<FileConfiguration>(configuration_file_);
if( config->property("Channels_1C.count", 0) > 0 )
{gps_1C = true;}
if( config->property("Channels_1B.count", 0) > 0 )
{gal_1B = true;}
if( config->property("Channels_5X.count", 0) > 0 )
{gal_E5a = true;}
if( config->property("Channels_7X.count", 0) > 0 ) //NOT DEFINITIVE!!!!!
{gps_L5 = true;}
return 0;
}
int ObsSystemTest::run_receiver()
{
std::shared_ptr<ControlThread> control_thread;
control_thread = std::make_shared<ControlThread>(config);
// start receiver
try
{
control_thread->run();
}
catch(const boost::exception & e)
{
std::cout << "Boost exception: " << boost::diagnostic_information(e);
}
catch(const std::exception & ex)
{
std::cout << "STD exception: " << ex.what();
}
// Get the name of the RINEX obs file generated by the receiver
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
FILE *fp;
std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1");
char buffer[1035];
fp = popen(&argum2[0], "r");
if (fp == NULL)
{
std::cout << "Failed to run command: " << argum2 << std::endl;
return -1;
}
while (fgets(buffer, sizeof(buffer), fp) != NULL)
{
std::string aux = std::string(buffer);
generated_rinex_obs = aux.erase(aux.length() - 1, 1);
internal_rinex_generation = true;
}
pclose(fp);
return 0;
}
void ObsSystemTest::compute_pseudorange_error(
std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name)
{
int prn_id = 0;
std::vector<arma::vec>::iterator iter_diff;
std::vector<double> means;
std::vector<double> stddevs;
std::vector<double> prns;
for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++)
{
if(!iter_diff->is_empty())
{
double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff)));
means.push_back(d_mean);
double d_stddev = arma::stddev(*iter_diff);
stddevs.push_back(d_stddev);
prns.push_back(static_cast<double>(prn_id));
std::cout << "-- RMS pseudorange difference for sat " << prn_id << ": " << d_mean;
std::cout << " +/- " << d_stddev;
std::cout << " [m]" << std::endl;
EXPECT_LT(d_mean, error_th_mean);
EXPECT_LT(d_stddev, error_th_std);
}
prn_id++;
}
if(FLAGS_plot_obs_sys_test == true)
{
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
if(gnuplot_executable.empty())
{
std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
try
{
boost::filesystem::path p(gnuplot_executable);
boost::filesystem::path dir = p.parent_path();
std::string gnuplot_path = dir.native();
Gnuplot::set_GNUPlotPath(gnuplot_path);
Gnuplot g1("linespoints");
g1.set_title(signal_name + " Pseudorange error");
g1.set_grid();
g1.set_xlabel("PRN");
g1.set_ylabel("Pseudorange error [m]");
g1.plot_xy(prns, means, "RMS error");
g1.plot_xy(prns, stddevs, "Standard deviation");
//g1.savetops("FFT_execution_times_extended");
//g1.savetopdf("FFT_execution_times_extended", 18);
g1.showonscreen(); // window output
}
catch (const GnuplotException & ge)
{
std::cout << ge.what() << std::endl;
}
}
}
}
void ObsSystemTest::compute_carrierphase_error(
std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name)
{
int prn_id = 0;
std::vector<double> means;
std::vector<double> stddevs;
std::vector<double> prns;
std::vector<arma::vec>::iterator iter_diff;
for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++)
{
if(!iter_diff->is_empty())
{
double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff)));
means.push_back(d_mean);
double d_stddev = arma::stddev(*iter_diff);
stddevs.push_back(d_stddev);
prns.push_back(static_cast<double>(prn_id));
std::cout << "-- RMS carrier phase difference for sat " << prn_id << ": " << d_mean;
std::cout << " +/- " << d_stddev;
std::cout << " whole cycles" << std::endl;
EXPECT_LT(d_mean, error_th_mean);
EXPECT_LT(d_stddev, error_th_std);
}
prn_id++;
}
if(FLAGS_plot_obs_sys_test == true)
{
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
if(gnuplot_executable.empty())
{
std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
try
{
boost::filesystem::path p(gnuplot_executable);
boost::filesystem::path dir = p.parent_path();
std::string gnuplot_path = dir.native();
Gnuplot::set_GNUPlotPath(gnuplot_path);
Gnuplot g1("linespoints");
g1.set_title(signal_name + " Carrier phase error");
g1.set_grid();
g1.set_xlabel("PRN");
g1.set_ylabel("Carrier phase error [whole cycles]");
g1.plot_xy(prns, means, "RMS error");
g1.plot_xy(prns, stddevs, "Standard deviation");
//g1.savetops("FFT_execution_times_extended");
//g1.savetopdf("FFT_execution_times_extended", 18);
g1.showonscreen(); // window output
}
catch (const GnuplotException & ge)
{
std::cout << ge.what() << std::endl;
}
}
}
}
void ObsSystemTest::compute_doppler_error(
std::vector<arma::vec>& diff,
double error_th_mean, double error_th_std,
std::string signal_name)
{
int prn_id = 0;
std::vector<double> means;
std::vector<double> stddevs;
std::vector<double> prns;
std::vector<arma::vec>::iterator iter_diff;
for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++)
{
if(!iter_diff->is_empty())
{
double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff)));
means.push_back(d_mean);
double d_stddev = arma::stddev(*iter_diff);
stddevs.push_back(d_stddev);
prns.push_back(static_cast<double>(prn_id));
std::cout << "-- RMS Doppler difference for sat " << prn_id << ": " << d_mean;
std::cout << " +/- " << d_stddev;
std::cout << " [Hz]" << std::endl;
EXPECT_LT(d_mean, error_th_mean);
EXPECT_LT(d_stddev, error_th_std);
}
prn_id++;
}
if(FLAGS_plot_obs_sys_test == true)
{
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
if(gnuplot_executable.empty())
{
std::cout << "WARNING: Although the flag plot_obs_sys_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
try
{
boost::filesystem::path p(gnuplot_executable);
boost::filesystem::path dir = p.parent_path();
std::string gnuplot_path = dir.native();
Gnuplot::set_GNUPlotPath(gnuplot_path);
Gnuplot g1("linespoints");
g1.set_title(signal_name + " Doppler error");
g1.set_grid();
g1.set_xlabel("PRN");
g1.set_ylabel("Doppler error [Hz]");
g1.plot_xy(prns, means, "RMS error");
g1.plot_xy(prns, stddevs, "Standard deviation");
//g1.savetops("FFT_execution_times_extended");
//g1.savetopdf("FFT_execution_times_extended", 18);
g1.showonscreen(); // window output
}
catch (const GnuplotException & ge)
{
std::cout << ge.what() << std::endl;
}
}
}
}
void ObsSystemTest::check_results()
{
arma::mat sow_prn_ref;
if(gps_1C)
{
std::vector<arma::mat> pseudorange_ref(num_prn_gps);
std::vector<arma::mat> carrierphase_ref(num_prn_gps);
std::vector<arma::mat> doppler_ref(num_prn_gps);
std::vector<arma::mat> pseudorange_meas(num_prn_gps);
std::vector<arma::mat> carrierphase_meas(num_prn_gps);
std::vector<arma::mat> doppler_meas(num_prn_gps);
read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 0);
// Time alignment and difference computation
std::vector<arma::vec> pr_diff(num_prn_gps);
std::vector<arma::vec> cp_diff(num_prn_gps);
std::vector<arma::vec> dp_diff(num_prn_gps);
time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref);
time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff);
time_alignment_diff(doppler_ref, doppler_meas, dp_diff);
// Results
std::cout << std::endl;
std::cout << std::endl;
std::cout << "GPS L1 C/A obs. results" << std::endl;
// Compute pseudorange error
compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L1 C/A");
// Compute carrier phase error
compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L1 C/A");
// Compute Doppler error
compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L1 C/A");
}
if(gps_L5)
{
std::vector<arma::mat> pseudorange_ref(num_prn_gps);
std::vector<arma::mat> carrierphase_ref(num_prn_gps);
std::vector<arma::mat> doppler_ref(num_prn_gps);
std::vector<arma::mat> pseudorange_meas(num_prn_gps);
std::vector<arma::mat> carrierphase_meas(num_prn_gps);
std::vector<arma::mat> doppler_meas(num_prn_gps);
read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 2);
// Time alignment and difference computation
std::vector<arma::vec> pr_diff(num_prn_gps);
std::vector<arma::vec> cp_diff(num_prn_gps);
std::vector<arma::vec> dp_diff(num_prn_gps);
time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref);
time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff);
time_alignment_diff(doppler_ref, doppler_meas, dp_diff);
// Results
std::cout << std::endl;
std::cout << std::endl;
std::cout << "GPS L5 obs. results" << std::endl;
// Compute pseudorange error
compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L5");
// Compute carrier phase error
compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L5");
// Compute Doppler error
compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L5");
}
if(gal_1B)
{
std::vector<arma::mat> pseudorange_ref(num_prn_gal);
std::vector<arma::mat> carrierphase_ref(num_prn_gal);
std::vector<arma::mat> doppler_ref(num_prn_gal);
std::vector<arma::mat> pseudorange_meas(num_prn_gal);
std::vector<arma::mat> carrierphase_meas(num_prn_gal);
std::vector<arma::mat> doppler_meas(num_prn_gal);
read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 1);
// Time alignment and difference computation
std::vector<arma::vec> pr_diff(num_prn_gal);
std::vector<arma::vec> cp_diff(num_prn_gal);
std::vector<arma::vec> dp_diff(num_prn_gal);
time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref);
time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff);
time_alignment_diff(doppler_ref, doppler_meas, dp_diff);
// Results
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Galileo E1B obs. results" << std::endl;
// Compute pseudorange error
compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E1B");
// Compute carrier phase error
compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E1B");
// Compute Doppler error
compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E1B");
}
if(gal_E5a)
{
std::vector<arma::mat> pseudorange_ref(num_prn_gal);
std::vector<arma::mat> carrierphase_ref(num_prn_gal);
std::vector<arma::mat> doppler_ref(num_prn_gal);
std::vector<arma::mat> pseudorange_meas(num_prn_gal);
std::vector<arma::mat> carrierphase_meas(num_prn_gal);
std::vector<arma::mat> doppler_meas(num_prn_gal);
read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 3);
// Time alignment and difference computation
std::vector<arma::vec> pr_diff(num_prn_gal);
std::vector<arma::vec> cp_diff(num_prn_gal);
std::vector<arma::vec> dp_diff(num_prn_gal);
time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref);
time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff);
time_alignment_diff(doppler_ref, doppler_meas, dp_diff);
// Results
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Galileo E5a obs. results" << std::endl;
// Compute pseudorange error
compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E5a");
// Compute carrier phase error
compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E5a");
// Compute Doppler error
compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E5a");
}
}
TEST_F(ObsSystemTest, Observables_system_test)
{
std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl;
bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3);
ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed. Only RINEX v. 3.00 files are allowed";
std::cout << "The file is valid." << std::endl;
// Configure receiver
configure_receiver();
if(generated_rinex_obs.compare("default_string") == 0)
{
// Run the receiver
ASSERT_EQ( run_receiver(), 0) << "Problem executing the software-defined signal generator";
}
std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << generated_rinex_obs << " ..." << std::endl;
bool is_gen_rinex_obs_valid = false;
if(internal_rinex_generation)
{
is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + generated_rinex_obs, config->property("PVT.rinex_version", 3));
}
else
{
is_gen_rinex_obs_valid = check_valid_rinex_obs(generated_rinex_obs, config->property("PVT.rinex_version", 3));
}
ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << generated_rinex_obs << ", generated by GNSS-SDR, is not well formed.";
std::cout << "The file is valid." << std::endl;
// Check results
check_results();
}
int main(int argc, char **argv)
{
std::cout << "Running GNSS-SDR in Space Observables validation test..." << std::endl;
int res = 0;
try
{
testing::InitGoogleTest(&argc, argv);
}
catch(...) {} // catch the "testing::internal::<unnamed>::ClassUniqueToAlwaysTrue" from gtest
google::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
// Run the Tests
try
{
res = RUN_ALL_TESTS();
}
catch(...)
{
LOG(WARNING) << "Unexpected catch";
}
google::ShutDownCommandLineFlags();
return res;
}

View File

@ -60,6 +60,13 @@ concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
class StaticPositionSystemTest: public ::testing::Test
{
public:
int configure_generator();
int generate_signal();
int configure_receiver();
int run_receiver();
void check_results();
private:
std::string generator_binary;
std::string p1;
std::string p2;
@ -72,12 +79,6 @@ public:
std::string filename_rinex_obs = FLAGS_filename_rinex_obs;
std::string filename_raw_data = FLAGS_filename_raw_data;
int configure_generator();
int generate_signal();
int configure_receiver();
int run_receiver();
void check_results();
void print_results(const std::vector<double> & east,
const std::vector<double> & north,
const std::vector<double> & up);
@ -88,13 +89,12 @@ public:
void geodetic2Enu(const double latitude, const double longitude, const double altitude,
double* east, double* north, double* up);
void geodetic2Ecef(const double latitude, const double longitude, const double altitude,
double* x, double* y, double* z);
std::shared_ptr<InMemoryConfiguration> config;
std::shared_ptr<FileConfiguration> config_f;
std::string generated_kml_file;
private:
void geodetic2Ecef(const double latitude, const double longitude, const double altitude,
double* x, double* y, double* z);
};
@ -521,29 +521,41 @@ void StaticPositionSystemTest::check_results()
double sum__u = std::accumulate(pos_u.begin(), pos_u.end(), 0.0);
double mean__u = sum__u / pos_u.size();
std::stringstream stm;
std::ofstream position_test_file;
if(FLAGS_config_file_ptest.empty())
{
std::cout << "---- ACCURACY ----" << std::endl;
std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
std::cout << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
std::cout << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl;
std::cout << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
std::cout << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl;
std::cout << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl;
std::cout << std::endl;
stm << "---- ACCURACY ----" << std::endl;
stm << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
stm << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl;
stm << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl;
stm << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl;
stm << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl;
stm << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl;
stm << std::endl;
}
std::cout << "---- PRECISION ----" << std::endl;
std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
std::cout << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
std::cout << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl;
std::cout << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "---- PRECISION ----" << std::endl;
stm << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
stm << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl;
stm << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl;
stm << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
std::cout << stm.rdbuf();
std::string output_filename = "position_test_output_" + StaticPositionSystemTest::generated_kml_file.erase(StaticPositionSystemTest::generated_kml_file.length() - 3,3) + "txt";
position_test_file.open(output_filename.c_str());
if(position_test_file.is_open())
{
position_test_file << stm.str();
position_test_file.close();
}
// Sanity Check
double precision_SEP = 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision);

View File

@ -359,96 +359,58 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector<double> & ttff_v, std:
std::string default_str = "default";
source = config_->property("SignalSource.implementation", default_str);
if (ttff_report_file.is_open())
{
ttff_report_file << "---------------------------" << std::endl;
ttff_report_file << " Time-To-First-Fix Report" << std::endl;
ttff_report_file << "---------------------------" << std::endl;
ttff_report_file << "Initial receiver status: ";
if (read_ephemeris)
{
ttff_report_file << "Hot start." << std::endl;
}
else
{
ttff_report_file << "Cold start." << std::endl;
}
ttff_report_file << "A-GNSS: ";
if (agnss && read_ephemeris)
{
ttff_report_file << "Enabled." << std::endl;
}
else
{
ttff_report_file << "Disabled." << std::endl;
}
ttff_report_file << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) ttff_report_file << ttff_ << " ";
ttff_report_file << std::endl;
ttff_report_file << "TTFF mean: " << mean << " [s]" << std::endl;
if (ttff.size() > 0)
{
ttff_report_file << "TTFF max: " << *max_ttff << " [s]" << std::endl;
ttff_report_file << "TTFF min: " << *min_ttff << " [s]" << std::endl;
}
ttff_report_file << "TTFF stdev: " << stdev << " [s]" << std::endl;
ttff_report_file << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
ttff_report_file << "Navigation mode: " << "3D" << std::endl;
std::stringstream stm;
if(source.compare("UHD_Signal_Source"))
{
ttff_report_file << "Source: File" << std::endl;
}
else
{
ttff_report_file << "Source: Live" << std::endl;
}
ttff_report_file << "---------------------------" << std::endl;
}
ttff_report_file.close();
std::cout << "---------------------------" << std::endl;
std::cout << " Time-To-First-Fix Report" << std::endl;
std::cout << "---------------------------" << std::endl;
std::cout << "Initial receiver status: ";
stm << "---------------------------" << std::endl;
stm << " Time-To-First-Fix Report" << std::endl;
stm << "---------------------------" << std::endl;
stm << "Initial receiver status: ";
if (read_ephemeris)
{
std::cout << "Hot start." << std::endl;
stm << "Hot start." << std::endl;
}
else
{
std::cout << "Cold start." << std::endl;
stm << "Cold start." << std::endl;
}
std::cout << "A-GNSS: ";
stm << "A-GNSS: ";
if (agnss && read_ephemeris)
{
std::cout << "Enabled." << std::endl;
stm << "Enabled." << std::endl;
}
else
{
std::cout << "Disabled." << std::endl;
stm << "Disabled." << std::endl;
}
std::cout << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) std::cout << ttff_ << " ";
std::cout << std::endl;
std::cout << "TTFF mean: " << mean << " [s]" << std::endl;
stm << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): ";
for(double ttff_ : ttff) stm << ttff_ << " ";
stm << std::endl;
stm << "TTFF mean: " << mean << " [s]" << std::endl;
if (ttff.size() > 0)
{
std::cout << "TTFF max: " << *max_ttff << " [s]" << std::endl;
std::cout << "TTFF min: " << *min_ttff << " [s]" << std::endl;
stm << "TTFF max: " << *max_ttff << " [s]" << std::endl;
stm << "TTFF min: " << *min_ttff << " [s]" << std::endl;
}
std::cout << "TTFF stdev: " << stdev << " [s]" << std::endl;
std::cout << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
std::cout << "Navigation mode: " << "3D" << std::endl;
stm << "TTFF stdev: " << stdev << " [s]" << std::endl;
stm << "Operating System: " << std::string(HOST_SYSTEM) << std::endl;
stm << "Navigation mode: " << "3D" << std::endl;
if(source.compare("UHD_Signal_Source"))
{
std::cout << "Source: File" << std::endl;
stm << "Source: File" << std::endl;
}
else
{
std::cout << "Source: Live" << std::endl;
stm << "Source: Live" << std::endl;
}
stm << "---------------------------" << std::endl;
std::cout << stm.rdbuf();
if (ttff_report_file.is_open())
{
ttff_report_file << stm.str();
ttff_report_file.close();
}
std::cout << "---------------------------" << std::endl;
}

View File

@ -74,6 +74,9 @@ DECLARE_string(log_dir);
#include "unit-tests/arithmetic/code_generation_test.cc"
#include "unit-tests/arithmetic/fft_length_test.cc"
#include "unit-tests/arithmetic/fft_speed_test.cc"
#if MATIO_TEST
#include "unit-tests/arithmetic/matio_test.cc"
#endif
#include "unit-tests/control-plane/file_configuration_test.cc"
#include "unit-tests/control-plane/in_memory_configuration_test.cc"

View File

@ -0,0 +1,159 @@
/*!
* \file matio_test.cc
* \brief This file implements tests for the matio library
* in long arrays.
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* 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 <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include <matio.h>
#include <cstdio>
#include <gnuradio/gr_complex.h>
TEST(MatioTest, WriteAndReadDoubles)
{
// Write a .mat file
mat_t *matfp;
matvar_t *matvar;
std::string filename = "./test.mat";
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
ASSERT_FALSE(reinterpret_cast<long*>(matfp) == NULL) << "Error creating .mat file";
double x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
size_t dims[2] = {10, 1};
matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, x, 0);
ASSERT_FALSE(reinterpret_cast<long*>(matvar) == NULL) << "Error creating variable for x";
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
Mat_Close(matfp);
// Read a .mat file
mat_t *matfp_read;
matvar_t *matvar_read;
matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY);
ASSERT_FALSE(reinterpret_cast<long*>(matfp_read) == NULL) << "Error reading .mat file";
matvar_read = Mat_VarReadInfo(matfp_read, "x");
ASSERT_FALSE(reinterpret_cast<long*>(matvar_read) == NULL) << "Error reading variable in .mat file";
matvar_read = Mat_VarRead(matfp_read, "x");
double *x_read = reinterpret_cast<double*>(matvar_read->data);
Mat_Close(matfp_read);
for(int i = 0; i < 10; i++)
{
EXPECT_DOUBLE_EQ(x[i], x_read[i]);
}
Mat_VarFree(matvar_read);
ASSERT_EQ(remove(filename.c_str()), 0);
}
TEST(MatioTest, WriteAndReadGrComplex)
{
// Write a .mat file
mat_t *matfp;
matvar_t *matvar1;
std::string filename = "./test3.mat";
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
ASSERT_FALSE(reinterpret_cast<long*>(matfp) == NULL) << "Error creating .mat file";
std::vector<gr_complex> x_v = { {1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}};
const unsigned int size = x_v.size();
float x_real[size];
float x_imag[size];
unsigned int i = 0;
for (std::vector<gr_complex>::const_iterator it = x_v.cbegin(); it != x_v.cend(); it++)
{
x_real[i] = it->real();
x_imag[i] = it->imag();
i++;
}
struct mat_complex_split_t x = {x_real, x_imag};
size_t dims[2] = {static_cast<size_t>(size), 1};
matvar1 = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX);
ASSERT_FALSE(reinterpret_cast<long*>(matvar1) == NULL) << "Error creating variable for x";
std::vector<gr_complex> x2 = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}};
const unsigned int size_y = x2.size();
float y_real[size_y];
float y_imag[size_y];
i = 0;
for (std::vector<gr_complex>::const_iterator it = x2.cbegin(); it != x2.cend(); it++)
{
y_real[i] = it->real();
y_imag[i] = it->imag();
i++;
}
struct mat_complex_split_t y = {y_real, y_imag};
size_t dims_y[2] = {static_cast<size_t>(size_y), 1};
matvar_t *matvar2;
matvar2 = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX);
ASSERT_FALSE(reinterpret_cast<long*>(matvar2) == NULL) << "Error creating variable for y";
Mat_VarWrite(matfp, matvar1, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarWrite(matfp, matvar2, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar1);
Mat_VarFree(matvar2);
Mat_Close(matfp);
// Read a .mat file
mat_t *matfp_read;
matvar_t *matvar_read;
matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY);
ASSERT_FALSE(reinterpret_cast<long*>(matfp_read) == NULL) << "Error reading .mat file";
matvar_read = Mat_VarReadInfo(matfp_read, "x");
ASSERT_FALSE(reinterpret_cast<long*>(matvar_read) == NULL) << "Error reading variable in .mat file";
matvar_read = Mat_VarRead(matfp_read, "x");
mat_complex_split_t *x_read_st = reinterpret_cast<mat_complex_split_t*>(matvar_read->data);
float * x_read_real = reinterpret_cast<float*>(x_read_st->Re);
float * x_read_imag = reinterpret_cast<float*>(x_read_st->Im);
std::vector<gr_complex> x_v_read;
for(unsigned int i = 0; i < size; i++)
{
x_v_read.push_back(gr_complex(x_read_real[i], x_read_imag[i]));
}
Mat_Close(matfp_read);
Mat_VarFree(matvar_read);
for(unsigned int i = 0; i < size; i++)
{
EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real());
EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag());
}
ASSERT_EQ(remove(filename.c_str()), 0);
}

View File

@ -41,9 +41,6 @@ TEST(PassThroughTest, Instantiate)
{
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
config->set_property("Test.item_type", "gr_complex");
config->set_property("Test.vector_size", "2");
std::shared_ptr<Pass_Through> signal_conditioner = std::make_shared<Pass_Through>(config.get(), "Test", 1, 1);
EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str());
unsigned int expected2 = 2;
EXPECT_EQ(expected2, signal_conditioner->vector_size());
}

View File

@ -192,14 +192,14 @@ TEST_F(FirFilterTest, ConnectAndRun)
top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -234,14 +234,14 @@ TEST_F(FirFilterTest, ConnectAndRunGrcomplex)
top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -277,14 +277,14 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts)
top_block->connect(source->get_right_block(), 0, ishort_to_cshort_, 0);
top_block->connect(ishort_to_cshort_, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " std::complex<int16_t> samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -322,14 +322,14 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes)
top_block->connect(source->get_right_block(), 0, ibyte_to_cbyte_, 0);
top_block->connect(ibyte_to_cbyte_, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " std::complex<int8_t> samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -366,13 +366,13 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex)
top_block->connect(source->get_right_block(), 0, ibyte_to_cbyte_, 0);
top_block->connect(ibyte_to_cbyte_, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -116,14 +116,14 @@ TEST_F(NotchFilterLiteTest, ConnectAndRun)
top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -157,13 +157,13 @@ TEST_F(NotchFilterLiteTest, ConnectAndRunGrcomplex)
top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -116,14 +116,14 @@ TEST_F(NotchFilterTest, ConnectAndRun)
top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -157,13 +157,13 @@ TEST_F(NotchFilterTest, ConnectAndRunGrcomplex)
top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -115,14 +115,14 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRun)
top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
@ -156,13 +156,13 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRunGrcomplex)
top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0);
top_block->connect(filter->get_right_block(), 0, null_sink, 0);
}) << "Failure connecting the top_block."<< std::endl;
}) << "Failure connecting the top_block.";
EXPECT_NO_THROW( {
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
}) << "Failure running the top_block.";
std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}