Go to the documentation of this file.
1 
9 #pragma once
10 
11 
12 // stdlib
13 #include <vector>
14 // 3rd party
15 #include <QDebug>
16 #include <QHostAddress>
17 #include <QObject>
18 #include <QPointer>
19 #include <QProcess>
20 #include <QTimer>
21 #include <QUdpSocket>
22 // dfti
23 #include "core/consts.hh"
24 #include "core/qptrutil.hh"
25 #include "rio/rio.hh"
26 #include "settings/settings.hh"
27 #include "uadc/uadc.hh"
28 #include "util/util.hh"
29 #include "vn200/vn200.hh"
30 
31 
32 #define STATE_DATA_SIZE 10
33 
34 
35 namespace dfti {
36 
37 
56 #pragma pack(push, 1) // change structure packing to 1 byte
57 struct StateData
58 {
60  quint64 gpsTimeNs{0};
61 
63  float eulerDeg[3] = {0};
64 
66  float quaternion[4] = {0};
67 
69  float angularRatesRPS[3] = {0};
70 
72  float accelMps2[3] = {0};
73 
75  float iasMps{0};
76 
78  float aoaDeg{0};
79 
81  float aosDeg{0};
82 
84  quint8 numRIOValues{0};
85 
87  float rioValues[STATE_DATA_SIZE] = {0};
88 };
89 #pragma pack(pop) // reset structure packing
90 
91 
125 class Server : public QObject
126 {
127  Q_OBJECT;
128 
129 public:
131 
135  explicit Server(Settings *_settings, QObject* _parent = nullptr);
136 
138  ~Server();
139 
141 
144  void enableUADC(uADC *adc);
145 
147 
150  void enableRIO(RIO *rio);
151 
153 
156  void enableVN200(VN200 *ins);
157 
159 
162  void start(void);
163 
164 public slots:
166  void getRIOData(RIOData data);
167 
169  void getUADCData(uADCData data);
170 
172  void getVN200Data(VN200Data data);
173 
175  void writeData(void);
176 
177 private:
179  QPointer<Settings> settings{nullptr};
180 
182  QPointer<QUdpSocket> socket{nullptr};
183 
185  QHostAddress address{QHostAddress::LocalHost};
186 
188  quint16 port{2701};
189 
191  QPointer<QTimer> writeTimer{nullptr};
192 
194  StateData stateData;
195 };
196 
197 
198 }; // namespace dfti
quint64 gpsTimeNs
INS GPS timestamp.
Definition: server.hh:60
float accelMps2[3]
INS accelerations.
Definition: server.hh:72
DFTI constants.
Structure to hold state data published.
Definition: server.hh:57
Structure to hold uADC data.
Definition: uadc.hh:68
float aosDeg
ADS sideslip angle.
Definition: server.hh:81
Aeroprobe Micro Air Data Computer interface.
float eulerDeg[3]
INS Euler angles.
Definition: server.hh:63
QPointer Utility functions.
Definition: autopilot.cc:12
quint8 numRIOValues
Number of RIO values (up to 10).
Definition: server.hh:84
Settings manager.
Definition: settings.hh:30
Serial driver to acquire data from a generic Remote I/O device.
Definition: rio.hh:67
Serial driver to acquire data from a VN-200 Inertial Navigation System.
Definition: vn200.hh:115
Structure to hold control effector data.
Definition: rio.hh:52
float angularRatesRPS[3]
INS angular rates.
Definition: server.hh:69
float iasMps
ADS indicated airspeed.
Definition: server.hh:75
VectorNav VN-200 Inertial Navigation System interface.
float quaternion[4]
INS quaternion.
Definition: server.hh:66
UDP server for vehicle state data.
Definition: server.hh:125
Structure to hold VN-200 data.
Definition: vn200.hh:38
DFTI settings manager interface.
Utility functions.
Remote I/O logging interface.
Serial driver to acquire data from a Micro Air Data Computer.
Definition: uadc.hh:115
float aoaDeg
ADS angle-of-attack.
Definition: server.hh:78
float rioValues[STATE_DATA_SIZE]
RIO values.
Definition: server.hh:87