0.2.0
Loading...
Searching...
No Matches
udpRecv.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
13
14#pragma once
15
17
19#include <boost/asio.hpp>
20#include <string>
21
22namespace NAV
23{
25class UdpRecv : public Node
26{
27 public:
31 ~UdpRecv() override;
33 UdpRecv(const UdpRecv&) = delete;
35 UdpRecv(UdpRecv&&) = delete;
37 UdpRecv& operator=(const UdpRecv&) = delete;
40
42 [[nodiscard]] static std::string typeStatic();
43
45 [[nodiscard]] std::string type() const override;
46
48 [[nodiscard]] static std::string category();
49
52 void guiConfig() override;
53
55 [[nodiscard]] json save() const override;
56
59 void restore(const json& j) override;
60
62 bool resetNode() override;
63
64 private:
65 constexpr static size_t OUTPUT_PORT_INDEX_NODE_DATA = 0;
66
68 bool initialize() override;
69
71 void deinitialize() override;
72
74 void asyncReceive();
75
77 int _port = 4567;
78
80 static constexpr std::array<int, 2> PORT_LIMITS = { 0, 65535 };
81
83 boost::asio::io_context _io_context;
85 boost::asio::ip::udp::socket _socket;
87 boost::asio::ip::udp::endpoint _sender_endpoint;
88
90 std::thread _recvThread;
91
93 bool _running = false;
95 bool _isStartup = true;
96
98 std::chrono::steady_clock::time_point _startPoint;
99
101 constexpr static unsigned int _maxBytes = 104;
102
104 std::array<double, 13> _data{};
105};
106} // namespace NAV
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Node Class.
Position, Velocity and Attitude Storage Class.
Abstract parent class for all nodes.
Definition Node.hpp:86
UDP Client.
Definition udpRecv.hpp:26
UdpRecv()
Default constructor.
void guiConfig() override
ImGui config window which is shown on double click.
static std::string typeStatic()
String representation of the Class Type.
~UdpRecv() override
Destructor.
UdpRecv(UdpRecv &&)=delete
Move constructor.
bool resetNode() override
Resets the node. Moves the read cursor to the start.
UdpRecv & operator=(const UdpRecv &)=delete
Copy assignment operator.
static std::string category()
String representation of the Class Category.
UdpRecv & operator=(UdpRecv &&)=delete
Move assignment operator.
void restore(const json &j) override
Restores the node from a json object.
UdpRecv(const UdpRecv &)=delete
Copy constructor.
json save() const override
Saves the node into a json object.
std::string type() const override
String representation of the Class Type.