28#include <boost/system/detail/error_code.hpp>
96 if (
auto* connectedPin = link.getConnectedPin())
98 outputPins.front().recreateLink(*connectedPin);
125 if (j.contains(
"port"))
127 j.at(
"port").get_to(
_port);
129 if (j.contains(
"outputType"))
165 _socket = boost::asio::ip::udp::socket(
_io_context, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(),
static_cast<uint16_t
>(
_port)));
167 catch (
const std::exception& )
169 LOG_ERROR(
"{}: Port {} is already in use. Choose a different port for this instance.",
nameId(),
_port);
210 [
this](boost::system::error_code errorRcvd, std::size_t bytesRcvd) {
211 if ((!errorRcvd) && (bytesRcvd > 0))
215 LOG_DATA(
"{}: Received {} bytes (message type {})",
nameId(), bytesRcvd, fmt::underlying(msgType));
232 auto obs = std::make_shared<PosVelAtt>();
234 obs->insTime =
InsTime(gpsCycle, gpsWeek, gpsTow);
237 Eigen::Vector3d posLLA{};
241 Eigen::Vector3d vel_n{};
245 Eigen::Quaterniond n_Quat_b{};
251 obs->setPosVelAtt_n(posLLA, vel_n, n_Quat_b);
262 auto obs = std::make_shared<PosVel>();
264 obs->insTime =
InsTime(gpsCycle, gpsWeek, gpsTow);
267 Eigen::Vector3d posLLA{};
271 Eigen::Vector3d vel_n{};
274 obs->setPosVel_n(posLLA, vel_n);
285 auto obs = std::make_shared<Pos>();
287 obs->insTime =
InsTime(gpsCycle, gpsWeek, gpsTow);
290 Eigen::Vector3d posLLA{};
293 obs->setPosition_lla(posLLA);
304 auto gnssObs = std::make_shared<GnssObs>();
305 gnssObs->insTime =
InsTime(gpsCycle, gpsWeek, gpsTow);
307 size_t byteSizeGnssData{};
311 "The UdpRecv node received a not dividable amount of bytes for the GnssObs data.");
312 LOG_DATA(
"{}: {} GNSS signals ({} bytes)",
nameId(), sizeGnssData, byteSizeGnssData);
325 LOG_ERROR(
"{}: Error receiving the UDP network stream: {}, Received bytes: {}",
nameId(), errorRcvd.what(), bytesRcvd);
#define INS_ASSERT_USER_ERROR(_EXP, _MSG)
Assert function with message.
Combo representing an enumeration.
nlohmann::json json
json namespace
GNSS Observation messages.
The class is responsible for all time-related tasks.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
#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...
Position, Velocity and Attitude Storage Class.
Structs identifying a unique satellite.
Utility for the UDP Send and Receive nodes.
static std::string type()
Returns the type of the data class.
The class is responsible for all time-related tasks.
ImVec2 _guiConfigDefaultWindowSize
std::vector< OutputPin > outputPins
List of output pins.
Node(std::string name)
Constructor.
OutputPin * CreateOutputPin(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.
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 type()
Returns the type of the data class.
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.
UdpUtil::MessageType _outputType
The selected output type in the GUI.
bool initialize() override
Initialize the node.
~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.
std::array< char, UdpUtil::MAXIMUM_BYTES > _charArray
The array that contains the data from the UDP stream.
bool resetNode() override
Resets the node. Moves the read cursor to the start.
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.
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'.
static constexpr size_t POS
Offset of the position.
static constexpr size_t GPSCYCLE
Offset of the GPS cycle.
static constexpr size_t GPSTOW
Offset of the GPS tow.
static constexpr size_t SIZE
Offset of the GNSS data size.
static constexpr size_t QUAT
Offset of the quaternion.
static constexpr size_t GNSSDATA
Offset of the GNSS data.
static constexpr size_t VEL
Offset of the velocity.
static constexpr size_t GPSWEEK
Offset of the GPS week.
static constexpr size_t GPSCYCLE
Size of a GPS cycle.
static constexpr size_t SIZE
Size of the size of a GNSS observation.
static constexpr size_t QUAT
Size of a Quaternion element.
static constexpr size_t SINGLE_OBSERVATION_DATA
Size of a single GNSS observation.
static constexpr size_t MSGTYPE
Size of the message type.
static constexpr size_t POS
Size of a Pos (LLA)
static constexpr size_t GPSTOW
Size of a GPS TOW.
static constexpr size_t GPSWEEK
Size of a GPS week.
static constexpr size_t VEL
Size of a Vel (NED)
static constexpr unsigned int MAXIMUM_BYTES
Network data stream maximum buffer size in [bytes] (Maximum payload size of a UDP package)
static constexpr std::array< int, 2 > PORT_LIMITS
Range a port can be in [0, 2^16-1].
MessageType
Enum specifying the type of the output message.
@ PosVel
Extract PosVel data.
@ GnssObs
Extract GnssObs data.
@ COUNT
Number of items in the enum.
@ PosVelAtt
Extract PosVelAtt data.
void ApplyChanges()
Signals that there have been changes to the flow.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
Stores the satellites observations.
Identifies a satellite signal (satellite frequency and number)
Asynchronous data link - receiver node.