0.4.1
Loading...
Searching...
No Matches
Delay.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 Delay.hpp
10/// @brief Delay Node
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2021-02-01
13
14#pragma once
15
17
18#include "util/Eigen.hpp"
19
20#include <deque>
21
22namespace NAV::experimental
23{
24/// @brief Delays messages by buffering them
25class Delay : public Node
26{
27 public:
28 /// @brief Default constructor
29 Delay();
30 /// @brief Destructor
31 ~Delay() override;
32 /// @brief Copy constructor
33 Delay(const Delay&) = delete;
34 /// @brief Move constructor
35 Delay(Delay&&) = delete;
36 /// @brief Copy assignment operator
37 Delay& operator=(const Delay&) = delete;
38 /// @brief Move assignment operator
39 Delay& operator=(Delay&&) = delete;
40
41 /// @brief String representation of the Class Type
42 [[nodiscard]] static std::string typeStatic();
43
44 /// @brief String representation of the Class Type
45 [[nodiscard]] std::string type() const override;
46
47 /// @brief String representation of the Class Category
48 [[nodiscard]] static std::string category();
49
50 /// @brief ImGui config window which is shown on double click
51 /// @attention Don't forget to set _hasConfig to true in the constructor of the node
52 void guiConfig() override;
53
54 /// @brief Saves the node into a json object
55 [[nodiscard]] json save() const override;
56
57 /// @brief Restores the node from a json object
58 /// @param[in] j Json object with the node state
59 void restore(const json& j) override;
60
61 /// @brief Called when a new link is to be established
62 /// @param[in] startPin Pin where the link starts
63 /// @param[in] endPin Pin where the link ends
64 /// @return True if link is allowed, false if link is rejected
65 bool onCreateLink(OutputPin& startPin, InputPin& endPin) override;
66
67 private:
68 constexpr static size_t OUTPUT_PORT_INDEX_FLOW = 0; ///< @brief Flow
69 constexpr static size_t INPUT_PORT_INDEX_FLOW = 0; ///< @brief Flow
70
71 /// @brief Initialize the node
72 bool initialize() override;
73
74 /// @brief Deinitialize the node
75 void deinitialize() override;
76
77 /// @brief Delays the observation
78 /// @param[in] queue Queue with all the received data messages
79 /// @param[in] pinIdx Index of the pin the data is received on
80 void delayObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
81
82 /// @brief The amount to delay messages for
83 int _delayLength = 1;
84
85 /// @brief Buffer to delay data
86 std::deque<std::shared_ptr<const NodeData>> _buffer;
87};
88
89} // namespace NAV::experimental
Vector space operations.
nlohmann::json json
json namespace
Node Class.
Input pins of nodes.
Definition Pin.hpp:491
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:707
Node(std::string name)
Constructor.
Definition Node.cpp:30
Output pins of nodes.
Definition Pin.hpp:338
Delay & operator=(Delay &&)=delete
Move assignment operator.
json save() const override
Saves the node into a json object.
Definition Delay.cpp:71
bool onCreateLink(OutputPin &startPin, InputPin &endPin) override
Called when a new link is to be established.
Definition Delay.cpp:106
Delay(const Delay &)=delete
Copy constructor.
Delay(Delay &&)=delete
Move constructor.
void guiConfig() override
ImGui config window which is shown on double click.
Definition Delay.cpp:53
static constexpr size_t INPUT_PORT_INDEX_FLOW
Flow.
Definition Delay.hpp:69
int _delayLength
The amount to delay messages for.
Definition Delay.hpp:83
Delay & operator=(const Delay &)=delete
Copy assignment operator.
static std::string category()
String representation of the Class Category.
Definition Delay.cpp:48
Delay()
Default constructor.
Definition Delay.cpp:20
~Delay() override
Destructor.
Definition Delay.cpp:33
static constexpr size_t OUTPUT_PORT_INDEX_FLOW
Flow.
Definition Delay.hpp:68
std::string type() const override
String representation of the Class Type.
Definition Delay.cpp:43
void delayObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Delays the observation.
Definition Delay.cpp:137
void deinitialize() override
Deinitialize the node.
Definition Delay.cpp:101
std::deque< std::shared_ptr< const NodeData > > _buffer
Buffer to delay data.
Definition Delay.hpp:86
static std::string typeStatic()
String representation of the Class Type.
Definition Delay.cpp:38
bool initialize() override
Initialize the node.
Definition Delay.cpp:92
void restore(const json &j) override
Restores the node from a json object.
Definition Delay.cpp:82