1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Add monitor block to send data stream to a remote GUI

This commit is contained in:
Álvaro Cebrián Juan 2018-07-03 13:25:43 +02:00
parent 2ff637125e
commit 619b2ee624
10 changed files with 380 additions and 1 deletions

View File

@ -19,4 +19,4 @@
add_subdirectory(system_parameters)
add_subdirectory(libs)
add_subdirectory(receiver)
add_subdirectory(monitor)

View File

@ -0,0 +1,37 @@
# Copyright (C) 2012-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/>.
#
set(CORE_MONITOR_LIBS_SOURCES
gnss_synchro_monitor.cc
gnss_synchro_udp_sink.cc
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/core/system_parameters
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
file(GLOB CORE_MONITOR_LIBS_HEADERS "*.h")
list(SORT CORE_MONITOR_LIBS_HEADERS)
add_library(core_monitor_lib ${CORE_MONITOR_LIBS_SOURCES} ${CORE_MONITOR_LIBS_HEADERS})
source_group(Headers FILES ${CORE_MONITOR_LIBS_HEADERS})
target_link_libraries(core_monitor_lib ${Boost_LIBRARIES})

View File

@ -0,0 +1,92 @@
/*!
* \file gnss_synchro_monitor.cc
* \brief Interface of a Position Velocity and Time computation block
* \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "gnss_synchro_monitor.h"
#include "gnss_synchro.h"
#include <glog/logging.h>
#include <algorithm>
#include <iostream>
using google::LogMessage;
gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels,
int output_rate_ms,
int udp_port,
std::vector<std::string> udp_addresses)
{
return gnss_synchro_monitor_sptr(new gnss_synchro_monitor(n_channels,
output_rate_ms,
udp_port,
udp_addresses));
}
gnss_synchro_monitor::gnss_synchro_monitor(unsigned int n_channels,
int output_rate_ms,
int udp_port,
std::vector<std::string> udp_addresses) : gr::sync_block("gnss_synchro_monitor",
gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)),
gr::io_signature::make(0, 0, 0))
{
d_output_rate_ms = output_rate_ms;
d_nchannels = n_channels;
udp_sink_ptr = std::unique_ptr<Gnss_Synchro_Udp_Sink>(new Gnss_Synchro_Udp_Sink(udp_addresses, udp_port));
}
gnss_synchro_monitor::~gnss_synchro_monitor()
{
}
int gnss_synchro_monitor::work(int noutput_items, gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items __attribute__((unused)))
{
const Gnss_Synchro** in = reinterpret_cast<const Gnss_Synchro**>(&input_items[0]); // Get the input buffer pointer
for (int epoch = 0; epoch < noutput_items; epoch++)
{
// ############ 1. READ PSEUDORANGES ####
for (unsigned int i = 0; i < d_nchannels; i++)
{
//if (in[i][epoch].Flag_valid_pseudorange)
// {
// }
//todo: send the gnss_synchro objects
std::vector<Gnss_Synchro> stocks;
stocks.push_back(in[i][epoch]);
udp_sink_ptr->write_gnss_synchro(stocks);
}
}
return noutput_items;
}

View File

@ -0,0 +1,81 @@
/*!
* \file gnss_synchro_monitor.h
* \brief Interface of a Position Velocity and Time computation block
* \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_GNSS_SYNCHRO_MONITOR_H
#define GNSS_SDR_GNSS_SYNCHRO_MONITOR_H
#include "gnss_synchro_udp_sink.h"
#include <gnuradio/sync_block.h>
#include <fstream>
#include <utility>
#include <string>
class gnss_synchro_monitor;
typedef boost::shared_ptr<gnss_synchro_monitor> gnss_synchro_monitor_sptr;
gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels,
int output_rate_ms,
int udp_port,
std::vector<std::string> udp_addresses);
/*!
* \brief This class implements a block that computes the PVT solution with Galileo E1 signals
*/
class gnss_synchro_monitor : public gr::sync_block
{
private:
friend gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int nchannels,
int output_rate_ms,
int udp_port,
std::vector<std::string> udp_addresses);
unsigned int d_nchannels;
int d_output_rate_ms;
std::unique_ptr<Gnss_Synchro_Udp_Sink> udp_sink_ptr;
public:
gnss_synchro_monitor(unsigned int nchannels,
int output_rate_ms,
int udp_port,
std::vector<std::string> udp_addresses);
~gnss_synchro_monitor(); //!< Default destructor
int work(int noutput_items, gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items);
};
#endif

View File

@ -0,0 +1,69 @@
/*!
* \file gnss_synchro_udp_sink.cc
* \brief Implementation of a class that sends serialized Gnss_Synchro
* objects over udp to one or multiple endponits
* \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "gnss_synchro_udp_sink.h"
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <sstream>
#include <iostream>
Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const unsigned short& port) : socket{io_service}
{
for (auto address : addresses)
{
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port);
endpoints.push_back(endpoint);
}
}
bool Gnss_Synchro_Udp_Sink::write_gnss_synchro(std::vector<Gnss_Synchro> stocks)
{
std::ostringstream archive_stream;
boost::archive::binary_oarchive oa{archive_stream};
oa << stocks;
std::string outbound_data = archive_stream.str();
for (auto endpoint : endpoints)
{
socket.open(endpoint.protocol(), error);
socket.connect(endpoint, error);
try
{
socket.send(boost::asio::buffer(outbound_data));
}
catch (boost::system::system_error const& e)
{
return false;
}
}
return true;
}

View File

@ -0,0 +1,53 @@
/*!
* \file gnss_synchro_udp_sink.h
* \brief Interface of a class that sends serialized Gnss_Synchro objects
* over udp to one or multiple endponits
* \author Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SYNCHRO_UDP_SINK_H_
#define GNSS_SYNCHRO_UDP_SINK_H_
#include <boost/asio.hpp>
#include "gnss_synchro.h"
class Gnss_Synchro_Udp_Sink
{
public:
Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const unsigned short &port);
bool write_gnss_synchro(std::vector<Gnss_Synchro> stocks);
private:
boost::asio::io_service io_service;
boost::asio::ip::udp::socket socket;
boost::system::error_code error;
std::vector<boost::asio::ip::udp::endpoint> endpoints;
std::vector<Gnss_Synchro> stocks;
};
#endif /* GNSS_SYNCHRO_UDP_SINK_H_ */

View File

@ -111,6 +111,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/core/libs/supl
${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp
${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl
${CMAKE_SOURCE_DIR}/src/core/monitor
${CMAKE_SOURCE_DIR}/src/algorithms/libs
${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/libs
${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters
@ -178,4 +179,5 @@ target_link_libraries(gnss_rx ${Boost_LIBRARIES}
pvt_adapters
pvt_lib
rx_core_lib
core_monitor_lib
)

View File

@ -4,6 +4,7 @@
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Luis Esteve, 2012. luis(at)epsilon-formacion.com
* Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es
* Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* -------------------------------------------------------------------------
*
@ -496,6 +497,25 @@ void GNSSFlowgraph::connect()
return;
}
// GNSS SYNCHRO MONITOR
if (enable_monitor_)
{
try
{
for (unsigned int i = 0; i < channels_count_; i++)
{
top_block_->connect(observables_->get_right_block(), i, GnssSynchroMonitor_, i);
}
}
catch (const std::exception& e)
{
LOG(WARNING) << "Can't connect observables to Monitor block";
LOG(ERROR) << e.what();
top_block_->disconnect_all();
return;
}
}
// Activate acquisition in enabled channels
for (unsigned int i = 0; i < channels_count_; i++)
{
@ -1091,6 +1111,25 @@ void GNSSFlowgraph::init()
set_channels_state();
applied_actions_ = 0;
DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels.";
/*
* Instantiate the receiver monitor block, if required
*/
enable_monitor_ = configuration_->property("Monitor.enable_monitor", false);
std::vector<std::string> udp_addr_vec;
std::string address_string = configuration_->property("Monitor.client_addresses", std::string("127.0.0.1"));
//todo: split the string in substrings using the separator and fill the address vector.
udp_addr_vec.push_back(address_string);
if (enable_monitor_)
{
GnssSynchroMonitor_ = gr::basic_block_sptr(new gnss_synchro_monitor(channels_count_,
configuration_->property("Monitor.output_rate_ms", 1),
configuration_->property("Monitor.udp_port", 1234),
udp_addr_vec));
}
}

View File

@ -4,6 +4,7 @@
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Luis Esteve, 2011. luis(at)epsilon-formacion.com
* Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es
* Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
*
* It contains a signal source,
* a signal conditioner, a set of channels, an observables block and a pvt.
@ -39,6 +40,7 @@
#include "GPS_L1_CA.h"
#include "gnss_signal.h"
#include "gnss_sdr_sample_counter.h"
#include "gnss_synchro_monitor.h"
#include <gnuradio/top_block.h>
#include <gnuradio/msg_queue.h>
#include <gnuradio/blocks/null_source.h>
@ -185,6 +187,9 @@ private:
std::vector<unsigned int> channels_state_;
std::mutex signal_list_mutex;
bool enable_monitor_;
gr::basic_block_sptr GnssSynchroMonitor_;
};
#endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/

View File

@ -307,6 +307,7 @@ set(LIST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/src/core/libs/supl
${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-rrlp
${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl
${CMAKE_SOURCE_DIR}/src/core/monitor
${CMAKE_SOURCE_DIR}/src/algorithms/libs
${CMAKE_SOURCE_DIR}/src/algorithms/libs/rtklib
${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/adapters