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 
22 
23 namespace dfti {
24 
25 
27 
34 bool validateVN200Checksum(QByteArray pkt);
35 
36 
38 struct VN200Data
39 {
41 
45  quint64 gpsTimeNs = 0;
47 
51  float eulerDeg[3] = {0};
53 
60  float quaternion[4] = {0};
62 
66  float angularRatesRPS[3] = {0};
68 
75  double posDegDegM[3] = {0};
77 
81  float velNedMps[3] = {0};
83 
87  float accelMps2[3] = {0};
88 };
89 
90 
92 
115 class VN200 : public SerialSensor
116 {
117  Q_OBJECT;
118 
119 public:
121 
125  explicit VN200(Settings *_settings, QObject* _parent = nullptr);
126 
128 
133  const QByteArray header{"\xfa\x01\xfa\x01"};
134 
135 public slots:
137  void readData(void);
138 
139 signals:
141  void gpsAvailable(bool flag);
142 
144  void measurementUpdate(VN200Data data);
145 
146 private:
148 
154  QByteArray buf;
155 
157  void copyPacketToData(void);
158 
160  static const quint8 packetSize{102};
161 
162 #pragma pack(push, 1) // change structure packing to 1 byte
163 
169  struct VN200Packet {
170  quint8 sync = 0;
171  quint8 outputGroups = 0;
172  quint16 outputFields = 0;
173  quint64 timeGPS = 0;
174  float euler[3] = {0};
175  float quaternion[4] = {0};
176  float angularRate[3] = {0};
177  double position[3] = {0};
178  float velocity[3] = {0};
179  float accel[3] = {0};
180  };
181 #pragma pack(pop) // reset structure packing
182 
184  VN200Data data;
185 
187  VN200Packet *packet{nullptr};
188 };
189 
190 
191 }; // namespace dfti
quint64 gpsTimeNs
GPS time.
Definition: vn200.hh:45
Serial IO Sensor interface.
Base class for interfacing with sensors over a serial port (UART/RS-232).
Definition: serialsensor.hh:30
float eulerDeg[3]
Euler Angles.
Definition: vn200.hh:51
float accelMps2[3]
Accelerations.
Definition: vn200.hh:87
double posDegDegM[3]
Lat-Long-Alt Position.
Definition: vn200.hh:75
Definition: autopilot.cc:12
float quaternion[4]
Quaternion.
Definition: vn200.hh:60
Settings manager.
Definition: settings.hh:30
Serial driver to acquire data from a VN-200 Inertial Navigation System.
Definition: vn200.hh:115
float angularRatesRPS[3]
Angular Rates.
Definition: vn200.hh:66
Structure to hold VN-200 data.
Definition: vn200.hh:38
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:81