0.4.1
Loading...
Searching...
No Matches
SkydelNetworkStream.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9/// @file SkydelNetworkStream.hpp
10/// @brief Node receiving UDP packages from the Skydel GNSS simulator Instinct plugin
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2021-04-19
13
14#pragma once
15
16#ifdef _WIN32
17 // Set the proper SDK version before including boost/Asio
18 #include <SDKDDKVer.h>
19 // Note boost/ASIO includes Windows.h.
20 #include <boost/asio.hpp>
21#else // _WIN32
22 #include <boost/asio.hpp>
23#endif //_WIN32
24
26
27#include <cstdlib>
28#include <thread>
29#include <string>
30#include <vector>
31
33
34namespace NAV::experimental
35{
36/// SkydelNetworkStream Sensor Class
38{
39 public:
40 /// @brief Default constructor
42 /// @brief Destructor
43 ~SkydelNetworkStream() override;
44 /// @brief Copy constructor
46 /// @brief Move constructor
48 /// @brief Copy assignment operator
50 /// @brief Move assignment operator
52
53 /// @brief String representation of the Class Type
54 [[nodiscard]] static std::string typeStatic();
55
56 /// @brief String representation of the Class Type
57 [[nodiscard]] std::string type() const override;
58
59 /// @brief String representation of the Class Category
60 [[nodiscard]] static std::string category();
61
62 /// @brief ImGui config window which is shown on double click
63 /// @attention Don't forget to set _hasConfig to true in the constructor of the node
64 void guiConfig() override;
65
66 /// @brief Resets the node. It is guaranteed that the node is initialized when this is called.
67 bool resetNode() override;
68
69 private:
70 constexpr static size_t OUTPUT_PORT_INDEX_IMU_OBS = 0; ///< @brief Port number of the Skydel-ImuObs output
71 constexpr static size_t OUTPUT_PORT_INDEX_GNSS_OBS = 1; ///< @brief Port number of the Skydel-GnssObs output
72
73 /// @brief Initialize the node
74 bool initialize() override;
75
76 /// @brief Deinitialize the node
77 void deinitialize() override;
78
79 /// Asynchronous receive fct
80 boost::asio::io_context _ioservice;
81
82 /// @brief Receive Skydel network stream data
83 void do_receive();
84
85 /// Thread for receiver fct
86 std::thread _testThread;
87
88 /// Network data stream buffer size (boost::asio)
89 constexpr static unsigned int _maxLength = 1024;
90
91 /// Network data stream array
92 std::array<char, _maxLength> _data{};
93
94 /// Boost udp endpoint
95 boost::asio::ip::udp::endpoint _senderEndpoint;
96 /// Boost udp socket
97 boost::asio::ip::udp::socket _socket;
98
99 /// Stop handler: once true, the asynchronous receive function stops
100 bool _stop = false;
101 /// Startup handler: used in 'initialize()' to differentiate between startup and re-initialization
102 bool _isStartup = true;
103
104 /// Time point where the first package has been received
105 std::chrono::steady_clock::time_point _startPoint;
106
107 /// Stores the time of the last received message
109
110 /// Counter for received packages
112
113 /// # of packages for averaging dataRate (minimum is '2', since two time points are required to calculate a data rate)
115
116 /// Data rate of the received network stream [Hz]
117 double _dataRate = 0.0;
118
119 /// Counter for packages that are skipped until data rate is shown
121
122 /// # of packages that are skipped until data rate is shown
123 int _startNow = 20;
124};
125
126} // namespace NAV::experimental
Abstract IMU Class.
The class is responsible for all time-related tasks.
Imu(const Imu &)=delete
Copy constructor.
std::thread _testThread
Thread for receiver fct.
std::string type() const override
String representation of the Class Type.
void deinitialize() override
Deinitialize the node.
bool initialize() override
Initialize the node.
void guiConfig() override
ImGui config window which is shown on double click.
boost::asio::ip::udp::endpoint _senderEndpoint
Boost udp endpoint.
SkydelNetworkStream & operator=(SkydelNetworkStream &&)=delete
Move assignment operator.
int _startCounter
Counter for packages that are skipped until data rate is shown.
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
SkydelNetworkStream(SkydelNetworkStream &&)=delete
Move constructor.
SkydelNetworkStream & operator=(const SkydelNetworkStream &)=delete
Copy assignment operator.
static constexpr size_t OUTPUT_PORT_INDEX_IMU_OBS
Port number of the Skydel-ImuObs output.
static constexpr size_t OUTPUT_PORT_INDEX_GNSS_OBS
Port number of the Skydel-GnssObs output.
bool _isStartup
Startup handler: used in 'initialize()' to differentiate between startup and re-initialization.
int _packageCount
Counter for received packages.
static std::string category()
String representation of the Class Category.
bool _stop
Stop handler: once true, the asynchronous receive function stops.
static std::string typeStatic()
String representation of the Class Type.
boost::asio::io_context _ioservice
Asynchronous receive fct.
std::array< char, _maxLength > _data
Network data stream array.
uint64_t _lastMessageTime
Stores the time of the last received message.
boost::asio::ip::udp::socket _socket
Boost udp socket.
SkydelNetworkStream(const SkydelNetworkStream &)=delete
Copy constructor.
std::chrono::steady_clock::time_point _startPoint
Time point where the first package has been received.
double _dataRate
Data rate of the received network stream [Hz].
static constexpr unsigned int _maxLength
Network data stream buffer size (boost::asio)
void do_receive()
Receive Skydel network stream data.