Developmental Flight Test Instrumentation
vn200.hh
Go to the documentation of this file.
1 
9 #pragma once
10 
11 
12 // stdlib
13 #include <cmath>
14 #include <cstring>
15 // 3rd party
16 #include <QDebug>
17 #include <QObject>
18 // dfti
19 #include "sensor/serialsensor.hh"
20 #include "settings/settings.hh"
21 #include "util/util.hh"
22 
23 
24 namespace dfti {
25 
26 
28 
35 bool validateVN200Checksum(QByteArray pkt);
36 
37 
39 struct VN200Data
40 {
42 
46  quint64 gpsTimeNs = 0;
48 
52  float eulerDeg[3] = {0};
54 
61  float quaternion[4] = {0};
63 
67  float angularRatesRPS[3] = {0};
69 
76  double posDegDegM[3] = {0};
78 
82  float velNedMps[3] = {0};
84 
88  float accelMps2[3] = {0};
89 };
90 
91 
93 
116 class VN200 : public SerialSensor
117 {
118  Q_OBJECT;
119 
120 public:
122 
126  explicit VN200(Settings *_settings, QObject* _parent = nullptr);
127 
129 
134  const QByteArray header{"\xfa\x01\xfa\x01"};
135 
136 public slots:
138  void readData(void);
139 
140 signals:
142  void gpsAvailable(bool flag);
143 
145  void measurementUpdate(VN200Data data);
146 
147 private:
149 
155  QByteArray buf;
156 
158  void copyPacketToData(void);
159 
161  static const quint8 packetSize{102};
162 
163 #pragma pack(push, 1) // change structure packing to 1 byte
164 
170  struct VN200Packet {
171  quint8 sync = 0;
172  quint8 outputGroups = 0;
173  quint16 outputFields = 0;
174  quint64 timeGPS = 0;
175  float euler[3] = {0};
176  float quaternion[4] = {0};
177  float angularRate[3] = {0};
178  double position[3] = {0};
179  float velocity[3] = {0};
180  float accel[3] = {0};
181  };
182 #pragma pack(pop) // reset structure packing
183 
185  VN200Data data;
186 
188  VN200Packet *packet{nullptr};
189 };
190 
191 
192 }; // namespace dfti
quint64 gpsTimeNs
GPS time.
Definition: vn200.hh:46
Serial IO Sensor interface.
Base class for interfacing with sensors over a serial port (UART/RS-232).
Definition: serialsensor.hh:28
float eulerDeg[3]
Euler Angles.
Definition: vn200.hh:52
float accelMps2[3]
Accelerations.
Definition: vn200.hh:88
double posDegDegM[3]
Lat-Long-Alt Position.
Definition: vn200.hh:76
Definition: autopilot.cc:12
float quaternion[4]
Quaternion.
Definition: vn200.hh:61
Settings manager.
Definition: settings.hh:30
Serial driver to acquire data from a VN-200 Inertial Navigation System.
Definition: vn200.hh:116
float angularRatesRPS[3]
Angular Rates.
Definition: vn200.hh:67
Structure to hold VN-200 data.
Definition: vn200.hh:39
DFTI settings manager interface.
bool validateVN200Checksum(QByteArray pkt)
Validate the VN-200 packet checksum.
Definition: vn200.cc:132
float velNedMps[3]
NED Velocity.
Definition: vn200.hh:82
Utility functions.