0.5.0
Loading...
Searching...
No Matches
UdpUtil.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 UdpUtil.hpp
10/// @brief Utility for the UDP Send and Receive nodes
11/// @author M. Maier (marcel.maier@ins.uni-stuttgart.de)
12/// @date 2025-07-02
13
14#pragma once
15
16#include <cstdint>
18
19namespace NAV::UdpUtil
20{
21/// Network data stream maximum buffer size in [bytes] (Maximum payload size of a UDP package)
22constexpr static unsigned int MAXIMUM_BYTES = 65507;
23/// Range a port can be in [0, 2^16-1]
24static constexpr std::array<int, 2> PORT_LIMITS = { 0, 65535 };
25
26/// Enum specifying the type of the output message
27enum class MessageType : uint8_t
28{
29 PosVelAtt, ///< Extract PosVelAtt data
30 PosVel, ///< Extract PosVel data
31 Pos, ///< Extract Pos data
32 GnssObs, ///< Extract GnssObs data
33 COUNT, ///< Number of items in the enum
34};
35
36namespace Size
37{
38/// Size of the message type
39constexpr static size_t MSGTYPE = sizeof(uint8_t);
40/// Size of a GPS cycle
41constexpr static size_t GPSCYCLE = sizeof(int32_t);
42/// Size of a GPS week
43constexpr static size_t GPSWEEK = sizeof(int32_t);
44/// Size of a GPS TOW
45constexpr static size_t GPSTOW = sizeof(double);
46/// Size of a Pos (LLA)
47constexpr static size_t POS = 3 * sizeof(double);
48/// Size of a Vel (NED)
49constexpr static size_t VEL = 3 * sizeof(double);
50/// Size of a Quaternion element
51constexpr static size_t QUAT = sizeof(double);
52
53/// Size of a total 'Pos' message
54constexpr static size_t TOTAL_POS = MSGTYPE + GPSCYCLE + GPSWEEK + GPSTOW + POS;
55/// Size of a total 'PosVel' message
56constexpr static size_t TOTAL_POSVEL = TOTAL_POS + VEL;
57/// Size of a total 'PosVelAtt' message
58constexpr static size_t TOTAL_POSVELATT = TOTAL_POSVEL + 4 * QUAT;
59
60/// Size of the size of a GNSS observation
61constexpr static size_t SIZE = sizeof(size_t);
62/// Size of a single GNSS observation
63constexpr static size_t SINGLE_OBSERVATION_DATA = sizeof(GnssObs::ObservationData);
64} // namespace Size
65
66namespace Offset
67{
68/// Offset of the GPS cycle
69constexpr static size_t GPSCYCLE = Size::MSGTYPE;
70/// Offset of the GPS week
71constexpr static size_t GPSWEEK = GPSCYCLE + Size::GPSCYCLE;
72/// Offset of the GPS tow
73constexpr static size_t GPSTOW = GPSWEEK + Size::GPSWEEK;
74/// Offset of the position
75constexpr static size_t POS = GPSTOW + Size::GPSTOW;
76/// Offset of the velocity
77constexpr static size_t VEL = POS + Size::POS;
78/// Offset of the quaternion
79constexpr static size_t QUAT = VEL + Size::VEL;
80
81/// Offset of the GNSS data size
82constexpr static size_t SIZE = Offset::POS;
83/// Offset of the GNSS data
84constexpr static size_t GNSSDATA = SIZE + Size::SIZE;
85} // namespace Offset
86
87} // namespace NAV::UdpUtil
GNSS Observation messages.
static constexpr size_t POS
Offset of the position.
Definition UdpUtil.hpp:75
static constexpr size_t GPSCYCLE
Offset of the GPS cycle.
Definition UdpUtil.hpp:69
static constexpr size_t GPSTOW
Offset of the GPS tow.
Definition UdpUtil.hpp:73
static constexpr size_t SIZE
Offset of the GNSS data size.
Definition UdpUtil.hpp:82
static constexpr size_t QUAT
Offset of the quaternion.
Definition UdpUtil.hpp:79
static constexpr size_t GNSSDATA
Offset of the GNSS data.
Definition UdpUtil.hpp:84
static constexpr size_t VEL
Offset of the velocity.
Definition UdpUtil.hpp:77
static constexpr size_t GPSWEEK
Offset of the GPS week.
Definition UdpUtil.hpp:71
static constexpr size_t TOTAL_POSVELATT
Size of a total 'PosVelAtt' message.
Definition UdpUtil.hpp:58
static constexpr size_t GPSCYCLE
Size of a GPS cycle.
Definition UdpUtil.hpp:41
static constexpr size_t SIZE
Size of the size of a GNSS observation.
Definition UdpUtil.hpp:61
static constexpr size_t QUAT
Size of a Quaternion element.
Definition UdpUtil.hpp:51
static constexpr size_t SINGLE_OBSERVATION_DATA
Size of a single GNSS observation.
Definition UdpUtil.hpp:63
static constexpr size_t MSGTYPE
Size of the message type.
Definition UdpUtil.hpp:39
static constexpr size_t POS
Size of a Pos (LLA)
Definition UdpUtil.hpp:47
static constexpr size_t GPSTOW
Size of a GPS TOW.
Definition UdpUtil.hpp:45
static constexpr size_t GPSWEEK
Size of a GPS week.
Definition UdpUtil.hpp:43
static constexpr size_t TOTAL_POSVEL
Size of a total 'PosVel' message.
Definition UdpUtil.hpp:56
static constexpr size_t VEL
Size of a Vel (NED)
Definition UdpUtil.hpp:49
static constexpr size_t TOTAL_POS
Size of a total 'Pos' message.
Definition UdpUtil.hpp:54
static constexpr unsigned int MAXIMUM_BYTES
Network data stream maximum buffer size in [bytes] (Maximum payload size of a UDP package)
Definition UdpUtil.hpp:22
static constexpr std::array< int, 2 > PORT_LIMITS
Range a port can be in [0, 2^16-1].
Definition UdpUtil.hpp:24
MessageType
Enum specifying the type of the output message.
Definition UdpUtil.hpp:28
@ PosVel
Extract PosVel data.
Definition UdpUtil.hpp:30
@ GnssObs
Extract GnssObs data.
Definition UdpUtil.hpp:32
@ COUNT
Number of items in the enum.
Definition UdpUtil.hpp:33
@ PosVelAtt
Extract PosVelAtt data.
Definition UdpUtil.hpp:29
@ Pos
Extract Pos data.
Definition UdpUtil.hpp:31
Stores the satellites observations.
Definition GnssObs.hpp:46