1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-18 21:23:02 +00:00

Add work on OSNMA receiver

This commit is contained in:
Carles Fernandez 2023-05-23 12:11:53 +02:00
parent d8a3ae005d
commit 916dde2174
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
14 changed files with 411 additions and 2 deletions

View File

@ -213,6 +213,19 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
#else
boost::bind(&rtklib_pvt_gs::msg_handler_has_data, this, _1));
#endif
#endif
// Galileo OSNMA messages port in
this->message_port_register_in(pmt::mp("OSNMA_to_PVT"));
this->set_msg_handler(pmt::mp("OSNMA_to_PVT"),
#if HAS_GENERIC_LAMBDA
[this](auto&& PH1) { msg_handler_osnma(PH1); });
#else
#if USE_BOOST_BIND_PLACEHOLDERS
boost::bind(&rtklib_pvt_gs::msg_handler_osnma, this, boost::placeholders::_1));
#else
boost::bind(&rtklib_pvt_gs::msg_handler_osnma, this, _1));
#endif
#endif
d_initial_carrier_phase_offset_estimation_rads = std::vector<double>(nchannels, 0.0);
@ -1633,6 +1646,20 @@ void rtklib_pvt_gs::msg_handler_has_data(const pmt::pmt_t& msg)
}
void rtklib_pvt_gs::msg_handler_osnma(const pmt::pmt_t& msg)
{
try
{
const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code();
// Process NMA data
}
catch (const wht::bad_any_cast& e)
{
LOG(WARNING) << "msg_handler_osnma Bad any_cast: " << e.what();
}
}
std::map<int, Gps_Ephemeris> rtklib_pvt_gs::get_gps_ephemeris_map() const
{
return d_internal_pvt_solver->gps_ephemeris_map;

View File

@ -144,6 +144,8 @@ private:
void msg_handler_has_data(const pmt::pmt_t& msg);
void msg_handler_osnma(const pmt::pmt_t& msg);
void initialize_and_apply_carrier_phase_offset();
void apply_rx_clock_offset(std::map<int, Gnss_Synchro>& observables_map,

View File

@ -105,6 +105,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_enable_reed_solomon_inav(false),
d_valid_timetag(false),
d_E6_TOW_set(false),
d_there_are_e1_channels(conf.there_are_e1_channels),
d_there_are_e6_channels(conf.there_are_e6_channels)
{
// prevent telemetry symbols accumulation in output buffers
@ -114,12 +115,19 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
// Control messages to tracking block
this->message_port_register_out(pmt::mp("telemetry_to_trk"));
if (d_there_are_e1_channels)
{
// register OSM out
this->message_port_register_out(pmt::mp("OSNMA_from_TLM"));
}
if (d_there_are_e6_channels)
{
// register Gal E6 messages HAS out
this->message_port_register_out(pmt::mp("E6_HAS_from_TLM"));
// register TOW from map out
this->message_port_register_out(pmt::mp("TOW_from_TLM"));
// register TOW to TLM input
this->message_port_register_in(pmt::mp("TOW_to_TLM"));
// handler for input port
@ -503,8 +511,26 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in
if (d_band == '1' && d_inav_nav.have_new_nma() == true)
{
const std::shared_ptr<OSNMA_msg> tmp_obj = std::make_shared<OSNMA_msg>(d_inav_nav.get_osnma_msg());
// this->message_port_pub(pmt::mp("whatever"), pmt::make_any(tmp_obj));
std::cout << "Galileo OSNMA message received in channel " << d_channel << " from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("OSNMA_from_TLM"), pmt::make_any(tmp_obj));
uint8_t nma_status = (tmp_obj->hkroot[0] & 0b11000000) << 6;
std::string nma_status_string;
if (nma_status == 0)
{
nma_status_string = std::string("(Reserved mode)");
}
else if (nma_status == 1)
{
nma_status_string = std::string("(Test mode)");
}
else if (nma_status == 2)
{
nma_status_string = std::string("(Operational mode)");
}
else if (nma_status == 3)
{
nma_status_string = std::string("(Do not use mode)");
}
std::cout << "Galileo OSNMA message " << nma_status_string << " received in channel " << d_channel << " from satellite " << d_satellite << std::endl;
}
}

View File

@ -151,6 +151,7 @@ private:
bool d_enable_reed_solomon_inav;
bool d_valid_timetag;
bool d_E6_TOW_set;
bool d_there_are_e1_channels;
bool d_there_are_e6_channels;
};

View File

@ -30,6 +30,11 @@ void Tlm_Conf::SetFromConfiguration(const ConfigurationInterface *configuration,
const std::string default_crc_stats_dumpname("telemetry_crc_stats");
dump_crc_stats_filename = configuration->property(role + ".dump_crc_stats_filename", default_crc_stats_dumpname);
enable_navdata_monitor = configuration->property("NavDataMonitor.enable_monitor", false);
if (configuration->property("Channels_1B.count", 0) > 0)
{
there_are_e1_channels = true;
}
if (configuration->property("Channels_E6.count", 0) > 0)
{
there_are_e6_channels = true;

View File

@ -42,6 +42,7 @@ public:
bool enable_reed_solomon{false}; // for INAV message in Galileo E1B
bool dump_crc_stats{false}; // telemetry CRC statistics
bool enable_navdata_monitor{false};
bool there_are_e1_channels{false};
bool there_are_e6_channels{false};
};

View File

@ -21,6 +21,7 @@ set(CORE_LIBS_SOURCES
nav_message_monitor.cc
nav_message_udp_sink.cc
galileo_tow_map.cc
osnma_msg_receiver.cc
)
set(CORE_LIBS_HEADERS
@ -37,6 +38,7 @@ set(CORE_LIBS_HEADERS
serdes_nav_message.h
nav_message_monitor.h
galileo_tow_map.h
osnma_msg_receiver.h
)
if(ENABLE_FPGA)

View File

@ -0,0 +1,124 @@
/*!
* \file osnma_msg_receiver.cc
* \brief GNU Radio block that processes Galileo OSNMA data received from
* Galileo E1B telemetry blocks. After successful decoding, sends the content to
* the PVT block.
* \author Carles Fernandez-Prades, 2023. cfernandez(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "osnma_msg_receiver.h"
#include "display.h" // for colors in terminal
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include <glog/logging.h> // for DLOG
#include <gnuradio/io_signature.h> // for gr::io_signature::make
#include <bitset>
#include <cstdint>
#include <iostream>
#include <typeinfo> // for typeid
#if HAS_GENERIC_LAMBDA
#else
#include <boost/bind/bind.hpp>
#endif
#if PMT_USES_BOOST_ANY
#include <boost/any.hpp>
namespace wht = boost;
#else
#include <any>
namespace wht = std;
#endif
osnma_msg_receiver_sptr osnma_msg_receiver_make()
{
return osnma_msg_receiver_sptr(new osnma_msg_receiver());
}
osnma_msg_receiver::osnma_msg_receiver() : gr::block("osnma_msg_receiver",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
{
// register OSNMA input message port from telemetry blocks
this->message_port_register_in(pmt::mp("OSNMA_from_TLM"));
// register OSNMA output message port to PVT block
this->message_port_register_out(pmt::mp("OSNMA_to_PVT"));
this->set_msg_handler(pmt::mp("OSNMA_from_TLM"),
#if HAS_GENERIC_LAMBDA
[this](auto&& PH1) { msg_handler_osnma(PH1); });
#else
#if USE_BOOST_BIND_PLACEHOLDERS
boost::bind(&osnma_msg_receiver::msg_handler_osnma, this, boost::placeholders::_1));
#else
boost::bind(&osnma_msg_receiver::msg_handler_osnma, this, _1));
#endif
#endif
}
void osnma_msg_receiver::msg_handler_osnma(const pmt::pmt_t& msg)
{
gr::thread::scoped_lock lock(d_setlock); // require mutex with msg_handler_osnma function called by the scheduler
try
{
const size_t msg_type_hash_code = pmt::any_ref(msg).type().hash_code();
if (msg_type_hash_code == typeid(OSNMA_msg).hash_code())
{
const auto nma_msg = wht::any_cast<OSNMA_msg>(pmt::any_ref(msg));
process_osnma_message(nma_msg);
}
else
{
LOG(WARNING) << "osnma_msg_receiver received an unknown object type!";
}
}
catch (const wht::bad_any_cast& e)
{
LOG(WARNING) << "osnma_msg_receiver Bad any_cast: " << e.what();
}
// Send the resulting decoded NMA data (if available) to PVT
if (d_new_data == true)
{
auto osnma_data_ptr = std::make_shared<OSNMA_data>(d_osnma_data);
this->message_port_pub(pmt::mp("OSNMA_to_PVT"), pmt::make_any(osnma_data_ptr));
d_new_data = false;
DLOG(INFO) << "NMA info sent to the PVT block through the OSNMA_to_PVT async message port";
}
}
void osnma_msg_receiver::process_osnma_message(const OSNMA_msg& osnma_msg)
{
auto hkroot_msg = osnma_msg.hkroot;
read_nma_header(hkroot_msg[0]);
read_dsm_header(hkroot_msg[1]);
}
void osnma_msg_receiver::read_nma_header(uint8_t nma_header)
{
d_osnma_data.d_nma_header.nmas = (nma_header & 0b11000000) << 6;
d_osnma_data.d_nma_header.cid = (nma_header & 0b00110000) << 4;
d_osnma_data.d_nma_header.cpks = (nma_header & 0b00001110) << 1;
d_osnma_data.d_nma_header.reserved = ((nma_header & 0b00000001) ? true : false);
}
void osnma_msg_receiver::read_dsm_header(uint8_t dsm_header)
{
d_osnma_data.d_dsm_header.dsm_id = (dsm_header & 0b11110000) << 4;
d_osnma_data.d_dsm_header.dsm_block_id = dsm_header & 0b00001111;
}

View File

@ -0,0 +1,66 @@
/*!
* \file osnma_msg_receiver.h
* \brief GNU Radio block that processes Galileo OSNMA data received from
* Galileo E1B telemetry blocks. After successful decoding, sends the content to
* the PVT block.
* \author Carles Fernandez-Prades, 2023. cfernandez(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_OSNMA_MSG_RECEIVER_H
#define GNSS_SDR_OSNMA_MSG_RECEIVER_H
#include "galileo_inav_message.h" // for OSNMA_msg
#include "gnss_block_interface.h" // for gnss_shared_ptr
#include "osnma_data.h"
#include <gnuradio/block.h> // for gr::block
#include <pmt/pmt.h> // for pmt::pmt_t
/** \addtogroup Core
* \{ */
/** \addtogroup Core_Receiver_Library
* \{ */
class osnma_msg_receiver;
using osnma_msg_receiver_sptr = gnss_shared_ptr<osnma_msg_receiver>;
osnma_msg_receiver_sptr osnma_msg_receiver_make();
/*!
* \brief GNU Radio block that receives asynchronous OSNMA messages
* from the telemetry blocks, stores them in memory, and decodes OSNMA info
* when enough data have been received.
* The decoded OSNMA data is sent to the PVT block.
*/
class osnma_msg_receiver : public gr::block
{
public:
~osnma_msg_receiver() = default; //!< Default destructor
private:
friend osnma_msg_receiver_sptr osnma_msg_receiver_make();
osnma_msg_receiver();
void msg_handler_osnma(const pmt::pmt_t& msg);
void process_osnma_message(const OSNMA_msg& osnma_msg);
void read_nma_header(uint8_t nma_header);
void read_dsm_header(uint8_t dsm_header);
OSNMA_data d_osnma_data{};
bool d_new_data{false};
};
/** \} */
/** \} */
#endif // GNSS_SDR_OSNMA_MSG_RECEIVER_H

View File

@ -76,6 +76,7 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
connected_(false),
running_(false),
multiband_(GNSSFlowgraph::is_multiband()),
enable_osnma_rx_(false),
enable_e6_has_rx_(false)
{
enable_fpga_offloading_ = configuration_->property("GNSS-SDR.enable_FPGA", false);
@ -114,6 +115,16 @@ void GNSSFlowgraph::init()
galileo_tow_map_ = nullptr;
}
if (configuration_->property("Channels_1B.count", 0) > 0)
{
enable_osnma_rx_ = true;
osnma_rx_ = osnma_msg_receiver_make();
}
else
{
osnma_rx_ = nullptr;
}
// 1. read the number of RF front-ends available (one file_source per RF front-end)
int sources_count_deprecated = configuration_->property("Receiver.sources_count", 1);
sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated);
@ -490,6 +501,14 @@ int GNSSFlowgraph::connect_desktop_flowgraph()
}
}
if (enable_osnma_rx_)
{
if (connect_osnma() != 0)
{
return 1;
}
}
// Activate acquisition in enabled channels
for (int i = 0; i < channels_count_; i++)
{
@ -609,6 +628,14 @@ int GNSSFlowgraph::connect_fpga_flowgraph()
}
}
if (enable_osnma_rx_)
{
if (connect_osnma() != 0)
{
return 1;
}
}
check_desktop_conf_in_fpga_env();
LOG(INFO) << "The GNU Radio flowgraph for the current GNSS-SDR configuration with FPGA off-loading has been successfully connected";
@ -1334,6 +1361,42 @@ int GNSSFlowgraph::connect_monitors()
}
int GNSSFlowgraph::connect_osnma()
{
try
{
bool gal_e1_channels = false;
for (int i = 0; i < channels_count_; i++)
{
const std::string gnss_signal = channels_.at(i)->get_signal().get_signal_str();
switch (mapStringValues_[gnss_signal])
{
case evGAL_1B:
top_block_->msg_connect(channels_.at(i)->get_right_block(), pmt::mp("OSNMA_from_TLM"), osnma_rx_, pmt::mp("OSNMA_from_TLM"));
gal_e1_channels = true;
break;
default:
break;
}
}
if (gal_e1_channels == true)
{
top_block_->msg_connect(osnma_rx_, pmt::mp("OSNMA_to_PVT"), pvt_->get_left_block(), pmt::mp("OSNMA_to_PVT"));
}
}
catch (const std::exception& e)
{
LOG(ERROR) << "Can't connect Galileo OSNMA msg ports: " << e.what();
top_block_->disconnect_all();
return 1;
}
DLOG(INFO) << "Galileo OSNMA message ports connected";
return 0;
}
int GNSSFlowgraph::connect_gal_e6_has()
{
try

View File

@ -30,6 +30,7 @@
#include "galileo_tow_map.h"
#include "gnss_sdr_sample_counter.h"
#include "gnss_signal.h"
#include "osnma_msg_receiver.h"
#include "pvt_interface.h"
#include <gnuradio/blocks/null_sink.h> // for null_sink
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
@ -179,6 +180,7 @@ private:
int connect_channels_to_observables();
int connect_observables_to_pvt();
int connect_monitors();
int connect_osnma();
int connect_gal_e6_has();
int connect_gnss_synchro_monitor();
int connect_acquisition_monitor();
@ -234,6 +236,7 @@ private:
channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels
galileo_e6_has_msg_receiver_sptr gal_e6_has_rx_;
galileo_tow_map_sptr galileo_tow_map_;
osnma_msg_receiver_sptr osnma_rx_;
gnss_sdr_sample_counter_sptr ch_out_sample_counter_;
#if ENABLE_FPGA
@ -290,6 +293,7 @@ private:
bool enable_tracking_monitor_;
bool enable_navdata_monitor_;
bool enable_fpga_offloading_;
bool enable_osnma_rx_;
bool enable_e6_has_rx_;
};

View File

@ -27,6 +27,7 @@ set(SYSTEM_PARAMETERS_SOURCES
glonass_gnav_ephemeris.cc
glonass_gnav_utc_model.cc
glonass_gnav_navigation_message.cc
osnma_data.cc
reed_solomon.cc
)
@ -89,6 +90,7 @@ set(SYSTEM_PARAMETERS_HEADERS
MATH_CONSTANTS.h
reed_solomon.h
galileo_has_page.h
osnma_data.h
)
list(SORT SYSTEM_PARAMETERS_HEADERS)

View File

@ -0,0 +1,17 @@
/*!
* \file osnma_data.cc
* \brief Class for Galileo OSNMA data storage
* \author Carles Fernandez-Prades, 2020-2023 cfernandez(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "osnma_data.h"

View File

@ -0,0 +1,69 @@
/*!
* \file osnma_data.h
* \brief Class for Galileo OSNMA data storage
* \author Carles Fernandez-Prades, 2020-2023 cfernandez(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_OSNMA_DATA_H
#define GNSS_SDR_OSNMA_DATA_H
#include <array>
#include <cstdint>
#include <string>
#include <vector>
/** \addtogroup Core
* \{ */
/** \addtogroup System_Parameters
* \{ */
struct nma_header
{
uint8_t nmas;
uint8_t cid;
uint8_t cpks;
bool reserved;
};
struct dsm_header
{
uint8_t dsm_id;
uint8_t dsm_block_id;
};
/*!
* \brief This class handles ONSMA data
* See https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galileo_OSNMA_User_ICD_for_Test_Phase_v1.0.pdf
*/
class OSNMA_data
{
public:
OSNMA_data() = default;
std::string itn; // bitset<1024>
std::string npk;
std::string p_dp;
nma_header d_nma_header;
dsm_header d_dsm_header;
uint8_t nb_dp;
uint8_t mid;
uint8_t npkt;
uint8_t npktid;
};
/** \} */
/** \} */
#endif // GNSS_SDR_OSNMA_DATA_H