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

Add the ability to read Galileo almanac XML files provided by the European GNSS Service Centre

Files available at https://www.gsc-europa.eu/system-status/almanac-data
This commit adds as a new dependency the library PugiXML
If the library is not found, it is downloaded and built when doing 'make'
This commit is contained in:
Carles Fernandez 2018-11-11 13:43:00 +01:00
commit 6653d0ef5f
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
11 changed files with 192 additions and 11 deletions

View File

@ -352,7 +352,7 @@ set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1")
set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master")
set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6")
set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.13")
set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.9")
################################################################################
@ -1216,6 +1216,53 @@ if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERS
endif(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERSION})
################################################################################
# PugiXML - https://pugixml.org/
################################################################################
find_package(PugiXML QUIET)
if(PugiXML_FOUND)
message(STATUS "PugiXML has been found. Reading of GSA Galileo almanac XML files enabled.")
else(PugiXML_FOUND)
message(STATUS " PugiXML v${GNSSSDR_PUGIXML_LOCAL_VERSION} will be downloaded and built automatically when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'.")
set(PUGIXML_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
set(TOOLCHAIN_ARG "")
if(EXISTS $ENV{OECORE_TARGET_SYSROOT})
set(PUGIXML_COMPILER "")
set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake")
endif(EXISTS $ENV{OECORE_TARGET_SYSROOT})
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml
GIT_TAG v${GNSSSDR_PUGIXML_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
CMAKE_ARGS ${PUGIXML_COMPILER} ${TOOLCHAIN_ARG}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
else(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(
pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml
GIT_TAG v${GNSSSDR_PUGIXML_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}
CMAKE_ARGS ${PUGIXML_COMPILER} ${TOOLCHAIN_ARG}
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX}
INSTALL_COMMAND ""
)
endif(CMAKE_VERSION VERSION_LESS 3.2)
set(PUGIXML_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}pugixml${CMAKE_STATIC_LIBRARY_SUFFIX} )
set(PUGIXML_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml/pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION}/src )
set(PUGIXML_LOCAL true)
endif(PugiXML_FOUND)
################################################################################
# USRP Hardware Driver (UHD) - OPTIONAL

View File

@ -64,7 +64,8 @@ $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time
libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev \
libboost-serialization-dev liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr \
libblas-dev liblapack-dev libarmadillo-dev libgflags-dev libgoogle-glog-dev \
libgnutls-openssl-dev libpcap-dev python-mako python-six libmatio-dev libgtest-dev
libgnutls-openssl-dev libpcap-dev python-mako python-six libmatio-dev libpugixml-dev \
libgtest-dev
~~~~~~
Please note that the required files from `libgtest-dev` were moved to `googletest` in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and moved back again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic".
@ -85,7 +86,7 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel cmake git boost-devel
boost-date-time boost-system boost-filesystem boost-thread boost-chrono \
boost-serialization log4cpp-devel gnuradio-devel gr-osmosdr-devel \
blas-devel lapack-devel matio-devel armadillo-devel gflags-devel \
glog-devel openssl-devel libpcap-devel python-mako python-six
glog-devel openssl-devel libpcap-devel python-mako python-six pugixml-devel
~~~~~~
Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux).
@ -102,7 +103,7 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel libtool \
hdf5-devel cmake git boost-devel boost-date-time boost-system \
boost-filesystem boost-thread boost-chrono boost-serialization \
log4cpp-devel gnuradio-devel gr-osmosdr-devel blas-devel lapack-devel \
armadillo-devel openssl-devel libpcap-devel python-mako python-six
armadillo-devel openssl-devel libpcap-devel python-mako python-six pugixml-devel
~~~~~~
Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux).
@ -113,7 +114,7 @@ If you are using Arch Linux (with base-devel group installed):
~~~~~~
$ pacman -S cmake git boost boost-libs log4cpp libvolk gnuradio gnuradio-osmosdr \
blas lapack gflags google-glog openssl python2-mako python2-six \
blas lapack gflags google-glog openssl pugixml python2-mako python2-six \
libmatio libpcap gtest
~~~~~~
@ -547,6 +548,7 @@ $ sudo port install google-glog +gflags
$ sudo port install py27-mako
$ sudo port install py27-six
$ sudo port install matio
$ sudo port install pugixml
~~~~~~
You also might need to activate a Python installation. The list of installed versions can be retrieved with:
@ -586,6 +588,7 @@ $ brew install armadillo
$ brew install glog gflags gnutls
$ brew install gnuradio
$ brew install libmatio
$ brew install pugixml
$ pip install mako
$ pip install six
~~~~~~

View File

@ -0,0 +1,69 @@
# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
# Find the pugixml XML parsing library.
#
# Sets the usual variables expected for find_package scripts:
#
# PUGIXML_INCLUDE_DIR - header location
# PUGIXML_LIBRARIES - library to link against
# PUGIXML_FOUND - true if pugixml was found.
find_path (PUGIXML_INCLUDE_DIR
NAMES pugixml.hpp
PATHS ${PUGIXML_HOME}/include
/usr/include
/usr/local/include
/opt/local/include)
find_library (PUGIXML_LIBRARY
NAMES pugixml
PATHS ${PUGIXML_HOME}/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr/lib/arm-linux-gnueabi
/usr/lib/arm-linux-gnueabihf
/usr/lib/i386-linux-gnu
/usr/lib/mips-linux-gnu
/usr/lib/mips64el-linux-gnuabi64
/usr/lib/mipsel-linux-gnu
/usr/lib/powerpc64le-linux-gnu
/usr/lib/s390x-linux-gnu
/usr/local/lib
/opt/local/lib
/usr/lib
/usr/lib64
/usr/local/lib64 )
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (PugiXML DEFAULT_MSG PUGIXML_LIBRARY
PUGIXML_INCLUDE_DIR)
if (PUGIXML_FOUND)
set (PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
if (NOT PugiXML_FIND_QUIETLY)
message (STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}")
message (STATUS "PugiXML library = ${PUGIXML_LIBRARY}")
endif (NOT PugiXML_FIND_QUIETLY)
else (PUGIXML_FOUND)
message (STATUS "PugiXML not found.")
endif(PUGIXML_FOUND)
mark_as_advanced (PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)

View File

@ -45,6 +45,7 @@ include_directories(
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
)
list(SORT CORE_LIBS_HEADERS)
@ -52,4 +53,8 @@ list(SORT CORE_LIBS_SOURCES)
add_library(rx_core_lib ${CORE_LIBS_SOURCES} ${CORE_LIBS_HEADERS})
source_group(Headers FILES ${CORE_LIBS_HEADERS})
target_link_libraries(rx_core_lib supl_library)
target_link_libraries(rx_core_lib supl_library ${PUGIXML_LIBRARY})
if(PUGIXML_LOCAL)
add_dependencies(rx_core_lib pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION})
endif(PUGIXML_LOCAL)

View File

@ -32,6 +32,7 @@
*/
#include "gnss_sdr_supl_client.h"
#include <pugixml.hpp>
#include <cmath>
#include <utility>
@ -842,11 +843,61 @@ bool gnss_sdr_supl_client::load_gal_almanac_xml(const std::string file_name)
boost::archive::xml_iarchive xml(ifs);
gal_almanac_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", this->gal_almanac_map);
LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites";
}
catch (std::exception& e)
{
LOG(WARNING) << e.what() << "File: " << file_name;
// Maybe the file is from https://www.gsc-europa.eu/system-status/almanac-data ?
return this->read_gal_almanac_from_gsa(file_name);
}
LOG(INFO) << "Loaded Galileo almanac map data with " << this->gal_almanac_map.size() << " satellites";
return true;
}
bool gnss_sdr_supl_client::read_gal_almanac_from_gsa(const std::string file_name)
{
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(file_name.c_str());
if (!result)
{
LOG(WARNING) << "Error loading file " << file_name << ":" << result.description();
return false;
}
for (pugi::xml_node almanac : doc.child("signalData")
.child("body")
.child("Almanacs")
.children("svAlmanac"))
{
Galileo_Almanac gal_alm;
try
{
uint32_t prn = static_cast<uint32_t>(std::stoi(almanac.child_value("SVID")));
gal_alm.i_satellite_PRN = prn;
gal_alm.i_Toa = std::stoi(almanac.child("almanac").child_value("t0a"));
gal_alm.i_WNa = std::stoi(almanac.child("almanac").child_value("wna"));
gal_alm.i_IODa = std::stoi(almanac.child("almanac").child_value("iod"));
gal_alm.d_Delta_i = std::stod(almanac.child("almanac").child_value("deltai"));
gal_alm.d_M_0 = std::stod(almanac.child("almanac").child_value("deltai"));
gal_alm.d_e_eccentricity = std::stod(almanac.child("almanac").child_value("ecc"));
gal_alm.d_Delta_sqrt_A = std::stod(almanac.child("almanac").child_value("aSqRoot"));
gal_alm.d_OMEGA0 = std::stod(almanac.child("almanac").child_value("omega0"));
gal_alm.d_OMEGA = std::stod(almanac.child("almanac").child_value("w"));
gal_alm.d_OMEGA_DOT = std::stod(almanac.child("almanac").child_value("omegaDot"));
gal_alm.d_A_f0 = std::stod(almanac.child("almanac").child_value("af0"));
gal_alm.d_A_f1 = std::stod(almanac.child("almanac").child_value("af1"));
gal_alm.E5b_HS = std::stoi(almanac.child("svINavSignalStatus").child_value("statusE5b"));
gal_alm.E1B_HS = std::stoi(almanac.child("svINavSignalStatus").child_value("statusE1B"));
gal_alm.E5a_HS = std::stoi(almanac.child("svFNavSignalStatus").child_value("statusE5a"));
this->gal_almanac_map[static_cast<int>(prn)] = gal_alm;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
}
if (this->gal_almanac_map.empty())
{
return false;
}
return true;

View File

@ -77,6 +77,7 @@ private:
supl_ctx_t ctx;
// assistance data
supl_assist_t assist;
bool read_gal_almanac_from_gsa(const std::string file_name);
public:
// SUPL SERVER INFO

View File

@ -157,6 +157,7 @@ include_directories(
${GFlags_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${OPT_RECEIVER_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
)

View File

@ -241,8 +241,8 @@ bool ControlThread::read_assistance_from_XML()
std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model_xml", cnav_utc_default_xml_filename);
std::string eph_glo_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename);
std::string glo_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_utc_model_xml", glo_utc_default_xml_filename);
std::string gal_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_almanacl_xml", gal_almanac_default_xml_filename);
std::string gps_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_almanacl_xml", gps_almanac_default_xml_filename);
std::string gal_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_almanac_xml", gal_almanac_default_xml_filename);
std::string gps_almanac_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_almanac_xml", gps_almanac_default_xml_filename);
if (configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false) == true)
{
@ -258,7 +258,8 @@ bool ControlThread::read_assistance_from_XML()
cnav_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_cnav_utc_model_xml", cnav_utc_default_xml_filename);
eph_glo_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename);
glo_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_utc_model_xml", glo_utc_default_xml_filename);
gal_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_almanacl_xml", gal_almanac_default_xml_filename);
gal_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_almanac_xml", gal_almanac_default_xml_filename);
gps_almanac_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_almanac_xml", gps_almanac_default_xml_filename);
}
std::cout << "Trying to read GNSS ephemeris from XML file(s)..." << std::endl;

View File

@ -61,6 +61,7 @@ include_directories(
${ARMADILLO_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${GNSS_SDR_OPTIONAL_HEADERS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
${OPT_GNSSSDR_INCLUDE_DIRS}

View File

@ -376,6 +376,7 @@ set(LIST_INCLUDE_DIRS
${VOLK_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
${MATIO_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${GNSS_SDR_TEST_OPTIONAL_HEADERS}
)

View File

@ -43,6 +43,7 @@ include_directories(
${GNURADIO_BLOCKS_INCLUDE_DIRS}
${ARMADILLO_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIR}
${VOLK_GNSSSDR_INCLUDE_DIRS}
)