82 if (j.contains(
"port"))
84 j.at(
"port").get_to(
_port);
94 _socket = boost::asio::ip::udp::socket(
_io_context, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(),
static_cast<uint16_t
>(
_port)));
96 catch (
const std::exception& )
98 LOG_ERROR(
"{}: Port {} is already in use. Choose a different port for this instance.",
nameId(),
_port);
139 [
this](boost::system::error_code errorRcvd, std::size_t bytesRcvd) {
140 if ((!errorRcvd) && (bytesRcvd > 0))
142 auto obs = std::make_shared<PosVelAtt>();
151 Eigen::Quaterniond n_Quat_b{};
152 n_Quat_b.x() =
_data.at(6);
153 n_Quat_b.y() =
_data.at(7);
154 n_Quat_b.z() =
_data.at(8);
155 n_Quat_b.w() =
_data.at(9);
158 auto gpsC =
static_cast<int32_t
>(
_data.at(10));
159 auto gpsW =
static_cast<int32_t
>(
_data.at(11));
160 auto gpsT =
static_cast<long double>(
_data.at(12));
162 obs->setPosVelAtt_n(posLLA, vel_n, n_Quat_b);
163 obs->insTime =
InsTime(gpsC, gpsW, gpsT);
169 LOG_ERROR(
"Error receiving the UDP network stream.");
nlohmann::json json
json namespace
Text Help Marker (?) with Tooltip.
Utility class for logging to console and file.
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Keeps track of the current real/simulation time.
The class is responsible for all time-related tasks.
ImVec2 _guiConfigDefaultWindowSize
Node(std::string name)
Constructor.
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
bool _onlyRealTime
Whether the node can run in post-processing or only real-time.
void invokeCallbacks(size_t portIndex, const std::shared_ptr< const NodeData > &data)
Calls all registered callbacks on the specified output port.
bool _hasConfig
Flag if the config window should be shown.
static std::string type()
Returns the type of the data class.
static std::string category()
String representation of the Class Category.
UdpRecv()
Default constructor.
void asyncReceive()
Polls the next data.
void guiConfig() override
ImGui config window which is shown on double click.
bool initialize() override
Initialize the node.
static constexpr std::array< int, 2 > PORT_LIMITS
Range a port can be in [0, 2^16-1].
~UdpRecv() override
Destructor.
boost::asio::io_context _io_context
Asynchronous receive fct.
bool _isStartup
Startup handler: used in 'initialize()' to differentiate between startup and re-initialization.
bool resetNode() override
Resets the node. Moves the read cursor to the start.
std::array< double, 13 > _data
Network data stream array.
std::thread _recvThread
Receiver thread.
bool _running
Flag that indicates the running data link.
void restore(const json &j) override
Restores the node from a json object.
static constexpr size_t OUTPUT_PORT_INDEX_NODE_DATA
Object (NodeData)
json save() const override
Saves the node into a json object.
std::string type() const override
String representation of the Class Type.
boost::asio::ip::udp::socket _socket
Boost udp socket.
static std::string typeStatic()
String representation of the Class Type.
static constexpr unsigned int _maxBytes
Network data stream maximum buffer size in [bytes].
int _port
UDP port number.
void deinitialize() override
Deinitialize the node.
boost::asio::ip::udp::endpoint _sender_endpoint
Boost udp endpoint.
static float windowFontRatio()
Ratio to multiply for GUI window elements.
bool InputIntL(const char *label, int *v, int v_min, int v_max, int step, int step_fast, ImGuiInputTextFlags flags)
Shows a value limited InputText GUI element for 'int'.
OutputPin * CreateOutputPin(Node *node, const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier, OutputPin::PinData data=static_cast< void * >(nullptr), int idx=-1)
Create an Output Pin object.
void ApplyChanges()
Signals that there have been changes to the flow.
Asynchronous data link - receiver node.