Witmotion IMU Library  1.3.1~dev_4684448
Open source UART communication library for sensor devices manufactured by WitMotion Shenzhen Co.,Ltd
types.h
Go to the documentation of this file.
1 /*!
2  \file types.h
3  \brief Abstract types collection for Witmotion sensor library
4  \author Andrey Vukolov andrey.vukolov@elettra.eu
5 
6  This header file contains all abstract types and hardware-defined constants to operate Witmotion sensor device.
7 */
8 
9 #ifndef WITMOTION
10 #define WITMOTION
11 #include <cmath>
12 #include <set>
13 #include <inttypes.h>
14 
15 #include <QtCore>
16 #include <QSerialPort>
17 
18 #include "witmotion/version.h"
19 
20 
21 /*!
22  \brief Main namespace of Witmotion UART connection library
23 
24 Upper level namespace containing all the declared constants, parameters, classes, functions.
25 
26 \note It is strictly NOT RECOMMENDED to use this namespace implicitly through `using namespace` directive.
27 */
28 namespace witmotion
29 {
30 
31 static const uint8_t WITMOTION_HEADER_BYTE = 0x55; ///< Packet header byte value (vendor protocol-specific)
32 static const uint8_t WITMOTION_CONFIG_HEADER = 0xFF; ///< Configuration header byte value (vendor protocol-specific)
33 static const uint8_t WITMOTION_CONFIG_KEY = 0xAA; ///< Configuration marker key byte value (vendor protocol-specific)
34 static const float DEG2RAD = M_PI / 180.f; ///< \private
35 
36 /*!
37  \brief Packet type IDs from the vendor-defined protocol
38 
39  If one of the packet type IDs defined here is registered after \ref WITMOTION_HEADER_BYTE in the data flow received from the sensor, the packet header is considered found and the remaining bytes are considered as body of the packet. See \ref util.h for decoder function reference.
40 */
42 {
43  pidRTC = 0x50, ///< Real-Time-Clock: Year from 2000, Month, Day, Hour, Minute, Second (8-bit unsigned integers) + Millisecond (16-bit unsigned integer), representing time passed since last time set up in the \ref ridTimeYearMonth, \ref ridTimeDayHour, \ref ridTimeMinuteSecond and \ref ridTimeMilliseconds registers
44  pidAcceleration = 0x51, ///< Linear accelerations + temperature/reserved field [X-Y-Z] (16-bit binary normalized quasi-floats)
45  pidAngularVelocity = 0x52, ///< Angular velocities + temperature/reserved field [Roll-Pitch-Yaw] (16-bit binary normalized quasi-floats)
46  pidAngles = 0x53, ///< Euler angles + temperature/reserved field [Roll-Pitch-Yaw] (16-bit binary normalized quasi-floats)
47  pidMagnetometer = 0x54, ///< Magnetic field tensity + temperature/reserved field [world X-Y-Z] (16-bit binary normalized quasi-floats)
48  pidDataPortStatus = 0x55, ///< Data port status packet, vendor-defined value
49  pidAltimeter = 0x56, ///< Altimeter + Barometer output (32-bit binary normalized quasi-floats)
50  pidGPSCoordinates = 0x57, ///< GPS: longitude + latitude, if supported by hardware (32-bit binary normalized quasi-floats)
51  pidGPSGroundSpeed = 0x58, ///< GPS: ground speed (32-bit binary normalized quasi-float) + altitude + angular velocity around vertical axis (16-bit binary normalized quasi-floats), if supported by hardware
52  pidOrientation = 0x59, ///< Orientation defined as quaternion [X-Y-Z-W], when available from the sensor firmware (16-bit binary normalized quasi-floats)
53  pidGPSAccuracy = 0x5A ///< GPS: visible satellites + variance vector [East-North-Up] (16-bit binary normalized quasi-floats)
54 };
55 
56 /*!
57  \brief Packet ID set to retrieve descriptions via \ref witmotion_packet_descriptions.
58 
59  Contains values referenced in \ref witmotion_packet_id enumeration to explicitly determine a set of currently supported packet IDs. The packet IDs not referenced here sould not be considered supported.
60 */
62  0x50,
63  0x51,
64  0x52,
65  0x53,
66  0x54,
67  0x55,
68  0x56,
69  0x57,
70  0x58,
71  0x59,
72  0x5A
73 };
74 
75 /*!
76  \brief Packet ID string set to store built-in descriptions for \ref message-enumerator.
77 
78  Contains values referenced in \ref witmotion_packet_id enumeration with corresponding description strings used by \ref message-enumerator application.
79 */
81  {0x50, "Real Time Clock"},
82  {0x51, "Accelerations"},
83  {0x52, "Angular velocities"},
84  {0x53, "Spatial orientation (Euler angles)"},
85  {0x54, "Magnetometer/Magnetic orientation"},
86  {0x55, "Data ports (D0-D3) status"},
87  {0x56, "Barometry/Altimeter"},
88  {0x57, "GPS Coordinates"},
89  {0x58, "GPS Ground Speed"},
90  {0x59, "Spatial orientation (Quaternion)"},
91  {0x5A, "GPS accuracy estimation"}
92 };
93 
94 /*!
95  * \brief Generic structure respresenting the standard 11-byte datapacket defined in Witmotion protocol.
96 */
98 {
99  uint8_t header_byte; ///< Header byte, set constantly to \ref WITMOTION_HEADER_BYTE
100  uint8_t id_byte; ///< Packet type ID, referring to \ref witmotion_packet_id, otherwise the packet is considered of unknown type.
101  union
102  {
103  int8_t raw_signed[8];
104  uint8_t raw[8];
105  int16_t raw_cells[4];
106  int32_t raw_large[2];
107  }datastore; ///< 8-byte internal data storage array represented as C-style memory union. The stored data represented as `int8_t*`, `uint8_t*`, `int16_t*` or `int32_t*` array head pointer.
108  uint8_t crc; ///< Validation CRC for the packet. Calculated as an equivalent to the following operation: \f$ crc = \sum_{i=0}^{i < 10}\times\f$`reinterpret_cast<uint8_t*>(this) + i`
109 };
110 
111 /*!
112  * \brief List of configuration slots (registers) available for the library.
113  *
114  * List of configuration slots (registers) available for the library. The actual availability depends from the actual sensor and installation circuit.
115  * Please refer to the official documentation for detailed explanation.
116 */
118 {
119  ridSaveSettings = 0x00, ///< Saves the settings uploaded in the current bringup session, or resets it to default (if supported). To make factory reset of the sensor, set `raw[0] = 0x01` in \ref witmotion_config_packet instance used.
120  /*!
121  Sets the sensor to calibration mode. The value stored in \ref witmotion_config_packet.setting.`raw[0]` determines device selection:
122  - `0x00` - End calibration
123  - `0x01` - Accelerometer calibration
124  - `0x03` - Altitude reset (only for barometric altimeter)
125  - `0x04` - Yaw [Z] Euler angle origin point reset
126  - `0x07` - Magnetometer calibration
127  - `0x08` - Angle reference reset
128  */
129  ridCalibrate = 0x01,
130  /*!
131  Regulates sensor output. The value stored in \ref witmotion_config_packet.setting.`raw` determines packet ID selection to output from low to high bits by offset. `0` means disabling of the selected data packet output.
132 
133  |`raw[0]` offset|Packet type|`raw[1]` offset| Packet type|
134  |:-------------:|----------:|:-------------:|-----------:|
135  |0|\ref pidRTC|0|\ref pidGPSGroundSpeed|
136  |1|\ref pidAcceleration|1|\ref pidOrientation|
137  |2|\ref pidAngularVelocity|2|\ref pidGPSAccuracy|
138  |3|\ref pidAngles|3|Reserved|
139  |4|\ref pidMagnetometer|4|Reserved|
140  |5|\ref pidDataPortStatus|5|Reserved|
141  |6|\ref pidAltimeter|6|Reserved|
142  |7|\ref pidGPSCoordinates|7|Reserved|
143  */
145  /*!
146  Regulates output frequency. **NOTE**: the maximum available frequency is determined internally by the available bandwidth obtained from \ref ridPortBaudRate.
147  The actual value stored in \ref witmotion_config_packet.setting.`raw[0]` can be determined from the following table. \ref witmotion_config_packet.setting.`raw[1]` is set to `0x00`. Also the table contains argument value for \ref witmotion_output_frequency helper function which is used by the controller applications.
148 
149  |Frequency, Hz|Value |Argument|
150  |:------------|:----:|:------:|
151  |0 (shutdown) |`0x0D`| 0 |
152  |0 (single measurement)|`0x0C`| -1 |
153  |0.1 |`0x01`| -10 |
154  |0.5 |`0x02`| -2 |
155  | 1 |`0x03`| 1 |
156  | 2 |`0x04`| 2 |
157  | 5 |`0x05`| 5 |
158  |10 (default) |`0x06`| 10 |
159  |20 |`0x07`| 20 |
160  |50 |`0x08`| 50 |
161  |100 |`0x09`| 100 |
162  |125 |`0x0A`| 125 |
163  |200 |`0x0B`| 200 |
164  |Maximal available by hardware|`0x0C`|Not supported|
165  */
167  /*!
168  Regulates port baud rate. **NOTE**: the sensor has no possibility of hardware flow control and it cannot report to the system what baud rate should be explicitly used!
169  The actual value stored in \ref witmotion_config_packet.setting.`raw[0]` can be determined from the following table. \ref witmotion_config_packet.setting.`raw[1]` is set to `0x00`.
170  The \ref witmotion_baud_rate helper function argument is accepted as `QSerialPort::BaudRate` enumeration member, so only the speed inticated in that enumeration are explicitly supported.
171  |**Rate, baud**|1200/1400|4800 |9600 |19200 |38400 |57600 |115200|
172  |:-------------|:-------:|:----:|:----:|:----:|:----:|:----:|:----:|
173  |**Value** |`0x00` |`0x01`|`0x02`|`0x03`|`0x04`|`0x05`|`0x06`|
174 
175  This parameter also implicitly sets \ref ridOutputFrequency to the maximal feasible value for the available bandwidth.
176  */
178  ridAccelerationBiasX = 0x05, ///< Sets acceleration zero point bias for X axis, refer to \ref acceleration-bias page for explanation.
179  ridAccelerationBiasY = 0x06, ///< Sets acceleration zero point bias for Y axis, refer to \ref acceleration-bias page for explanation.
180  ridAccelerationBiasZ = 0x07, ///< Sets acceleration zero point bias for Z axis, refer to \ref acceleration-bias page for explanation.
181  ridAngularVelocityBiasX = 0x08, ///< Sets angular velocity zero point bias for X axis. NOT YET PROVEN AS WORKING
182  ridAngularVelocityBiasY = 0x09, ///< Sets angular velocity zero point bias for Y axis. NOT YET PROVEN AS WORKING
183  ridAngularVelocityBiasZ = 0x0A, ///< Sets angular velocity zero point bias for Z axis. NOT YET PROVEN AS WORKING
184  ridMagnetometerBiasX = 0x0B, ///< Sets magnetometer zero point bias for X axis. **MAY BLOCK THE MEASUREMENTS**
185  ridMagnetometerBiasY = 0x0C, ///< Sets magnetometer zero point bias for Y axis. **MAY BLOCK THE MEASUREMENTS**
186  ridMagnetometerBiasZ = 0x0D, ///< Sets magnetometer zero point bias for Z axis. **MAY BLOCK THE MEASUREMENTS**
187  /*!
188  Digital port D0 mode. The values are set only via \ref witmotion_config_packet.setting.`raw[0]` whilst \ref witmotion_config_packet.setting.`raw[1]` is set to 0. Please refer to the following table to determine the exact value needed.
189 
190  |**Description**|Analog input (default)|Digital input|Digital output (high)|Digital output (low)|PWM output|
191  |:--------------|:--------------------:|:-----------:|:-------------------:|:------------------:|:--------:|
192  |**Value** |`0x00` |`0x01` |`0x02` |`0x03` |`0x04` |
193  */
195  /*!
196  Digital port D1 mode. The values are set only via \ref witmotion_config_packet.setting.`raw[0]` whilst \ref witmotion_config_packet.setting.`raw[1]` is set to 0. Please refer to the following table to determine the exact value needed.
197 
198  |**Description**|Analog input (default)|Digital input|Digital output (high)|Digital output (low)|PWM output|
199  |:--------------|:--------------------:|:-----------:|:-------------------:|:------------------:|:--------:|
200  |**Value** |`0x00` |`0x01` |`0x02` |`0x03` |`0x04` |
201 
202  \note If the external GPS receiver is used to obtain world time, and it is compatible with Witmotion serial protocol, the port D1 should be connected to its **TX** pin and turned into GPS receiver port by the special value `0x05` set for this register. The baud rate on which GPS receiver communicates with the sensor, is set via \ref ridGPSBaudRate register.
203  */
205  /*!
206  Digital port D2 mode. The values are set only via \ref witmotion_config_packet.setting.`raw[0]` whilst \ref witmotion_config_packet.setting.`raw[1]` is set to 0. Please refer to the following table to determine the exact value needed.
207 
208  |**Description**|Analog input (default)|Digital input|Digital output (high)|Digital output (low)|PWM output|
209  |:--------------|:--------------------:|:-----------:|:-------------------:|:------------------:|:--------:|
210  |**Value** |`0x00` |`0x01` |`0x02` |`0x03` |`0x04` |
211  */
213  /*!
214  Digital port D3 mode. The values are set only via \ref witmotion_config_packet.setting.`raw[0]` whilst \ref witmotion_config_packet.setting.`raw[1]` is set to 0. Please refer to the following table to determine the exact value needed.
215 
216  |**Description**|Analog input (default)|Digital input|Digital output (high)|Digital output (low)|PWM output|
217  |:--------------|:--------------------:|:-----------:|:-------------------:|:------------------:|:--------:|
218  |**Value** |`0x00` |`0x01` |`0x02` |`0x03` |`0x04` |
219  */
221  ridPortPWMLevelD0 = 0x12, ///< Digital port D0 PWM high level pulse width, microseconds, 16-bit unsigned integer.
222  ridPortPWMLevelD1 = 0x13, ///< Digital port D1 PWM high level pulse width, microseconds, 16-bit unsigned integer.
223  ridPortPWMLevelD2 = 0x14, ///< Digital port D2 PWM high level pulse width, microseconds, 16-bit unsigned integer.
224  ridPortPWMLevelD3 = 0x15, ///< Digital port D3 PWM high level pulse width, microseconds, 16-bit unsigned integer.
225  ridPortPWMPeriodD0 = 0x16, ///< Digital port D0 PWM period length, microseconds, 16-bit unsigned integer.
226  ridPortPWMPeriodD1 = 0x17, ///< Digital port D1 PWM period length, microseconds, 16-bit unsigned integer.
227  ridPortPWMPeriodD2 = 0x18, ///< Digital port D2 PWM period length, microseconds, 16-bit unsigned integer.
228  ridPortPWMPeriodD3 = 0x19, ///< Digital port D3 PWM period length, microseconds, 16-bit unsigned integer.
229  ridIICAddress = 0x1A, ///< Sets up I2C address of the sensor. Default value is `0x50`, 7-bit unsigned integer in \ref witmotion_config_packet.setting.`raw[0]` whilst \ref witmotion_config_packet.setting.`raw[1]` is set to 0.
230  ridLED = 0x1B, ///< Toggles on/off LED indication (for enclosed sensors only).
231  /*!
232  Regulates GPS receiver baud rate on port D1 (see \ref ridPortModeD1). The following table contains value set for \ref witmotion_config_packet.setting.`raw[0]` representing the different baud rates. \ref witmotion_config_packet.setting.`raw[1]` should be set to 0.
233  |**Rate, baud**|1200/1400|4800 |9600 |19200 |38400 |57600 |115200|230400|460800|921600|
234  |:-------------|:-------:|:----:|:----:|:----:|:----:|:----:|:----:|:----:|:----:|:----:|
235  |**Value** |`0x00` |`0x01`|`0x02`|`0x03`|`0x04`|`0x05`|`0x06`|`0x07`|`0x08`|`0x09`|
236  \note Baud rates over 256000 baud should not be considered standard.
237  */
239  /*!
240  Regulates internal filter bandwidth according to \ref witmotion_config_packet.setting.`raw[0]` value. Please refer to the following table for details.
241  | Value |Bandwidth, Hz|
242  |:--------------:|------------:|
243  |`0x00` | 256 |
244  |`0x01` | 184 |
245  |`0x02` | 94 |
246  |`0x03` | 44 |
247  |`0x04` | 21 |
248  |`0x05` | 10 |
249  |`0x06` | 5 |
250 
251  \ref witmotion_config_packet.setting.`raw[1]` should be set to 0. NOT YET PROVEN AS WORKING
252  */
254 
255  /*!
256  Regulates gyroscope value range according to \ref witmotion_config_packet.setting.`raw[0]` value. Please refer to the following table for details.
257  | Value |Range, \f$ deg/s \f$|
258  |:--------------:|--------:|
259  |`0x00` |250 |
260  |`0x01` |500 |
261  |`0x02` |1000 |
262  |`0x03` |2000 |
263 
264  \ref witmotion_config_packet.setting.`raw[1]` should be set to 0. NOT YET PROVEN AS WORKING
265  */
267  /*!
268  Regulates accelerometer value range according to \ref witmotion_config_packet.setting.`raw[0]` value. Please refer to the following table for details.
269  | Value |Range, \f$ m/s^2 \f$|
270  |:--------------:|--------:|
271  |`0x00` |\f$ 2 \cdot g\f$|
272  |`0x01` |\f$ 4 \cdot g\f$|
273  |`0x02` |\f$ 8 \cdot g\f$|
274  |`0x03` |\f$ 16 \cdot g\f$|
275 
276  Here \f$ g = 9.81 m/s^2 \f$. \ref witmotion_config_packet.setting.`raw[1]` should be set to 0. NOT YET PROVEN AS WORKING
277  */
279  ridStandbyMode = 0x22, ///< Toggles dormant mode. \ref witmotion_config_packet.setting.`raw[0]` should be set to `0x01`, \ref witmotion_config_packet.setting.`raw[1]` to 0.
280  ridInstallationDirection = 0x23, ///< Toggles on/off internal rotation transform for vertical installation. \ref witmotion_config_packet.setting.`raw[1]` should be set to 0, \ref witmotion_config_packet.setting.`raw[0]` being to `0x01` allows vertical installation, to `0x00` - horizontal installation.
281  ridTransitionAlgorithm = 0x24, ///< Regulates whether 9-axis (`0x01` in \ref witmotion_config_packet.setting.`raw[0]`) or 6-axis (`0x00`) transition algorithm should be used. \ref witmotion_config_packet.setting.`raw[1]` should be set to 0.
282  ridInstructionStart = 0x2D, ///< Instruction mode. `0x00` in \ref witmotion_config_packet.setting.`raw[0]` means starting instruction mode, `0x01` toggles it off whilst \ref witmotion_config_packet.setting.`raw[1]` is set explicitly to 0.
283 
284  ridTimeYearMonth = 0x30, ///< Sets RTC to the given year (\ref witmotion_config_packet.setting.`raw[0]`) and month (\ref witmotion_config_packet.setting.`raw[1]`). Year is a signed 8-bit integer with zero origin point set to 2000 year Gregorian calendar. Month is digitized to 1-12, unsigned 8-bit integer.
285  ridTimeDayHour = 0x31, ///< Sets RTC to the given day of the month (\ref witmotion_config_packet.setting.`raw[0]`) and hour (\ref witmotion_config_packet.setting.`raw[1]`) in 24H system.
286  ridTimeMinuteSecond = 0x32, ///< Sets RTC to the given minute (\ref witmotion_config_packet.setting.`raw[0]`) and second (\ref witmotion_config_packet.setting.`raw[1]`) in 24H system.
287  ridTimeMilliseconds = 0x33, ///< Sets RTC to the given milliseconds exposed as 16-bit unsigned integer.
288  ridSetAccelerationX = 0x34, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for acceleration on X axis. NOT YET PROVEN AS WORKING
289  ridSetAccelerationY = 0x35, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for acceleration on Y axis. NOT YET PROVEN AS WORKING
290  ridSetAccelerationZ = 0x36, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for acceleration on Z axis. NOT YET PROVEN AS WORKING
291  ridSetAngularVelocityX = 0x37, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for angular velocity on X axis. NOT YET PROVEN AS WORKING
292  ridSetAngularVelocityY = 0x38, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for angular velocity on Y axis. NOT YET PROVEN AS WORKING
293  ridSetAngularVelocityZ = 0x39, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for angular velocity on Z axis. NOT YET PROVEN AS WORKING
294  ridSetMagnetometerX = 0x3A, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for magnetometer on X axis. **MAY BLOCK THE MEASUREMENTS**
295  ridSetMagnetometerY = 0x3B, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for magnetometer on Y axis. **MAY BLOCK THE MEASUREMENTS**
296  ridSetMagnetometerZ = 0x3C, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for magnetometer on Z axis. **MAY BLOCK THE MEASUREMENTS**
297  ridSetAngleRoll = 0x3D, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for Euler angle (roll) over X axis. NOT YET PROVEN AS WORKING
298  ridSetAnglePitch = 0x3E, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for Euler angle (pitch) over Y axis. NOT YET PROVEN AS WORKING
299  ridSetAngleYaw = 0x3F, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for Euler angle (yaw) over Z axis. NOT YET PROVEN AS WORKING
300  ridSetTemperature = 0x40, ///< Sets up origin point or impostor value (needed when the corresponding spatial measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for temperature. NOT YET PROVEN AS WORKING
301  ridSetPortStatusD0 = 0x41, ///< Action unknown, not yet documented by Witmotion
302  ridSetPortStatusD1 = 0x42, ///< Action unknown, not yet documented by Witmotion
303  ridSetPortStatusD2 = 0x43, ///< Action unknown, not yet documented by Witmotion
304  ridSetPortStatusD3 = 0x44, ///< Action unknown, not yet documented by Witmotion
305  ridSetPressureLow = 0x45, ///< Sets up low part of initial value for 32-bit pressure measurement register. NOT YET PROVEN AS WORKING
306  ridSetPressureHigh = 0x46, ///< Sets up high part of initial value for 32-bit pressure measurement register. NOT YET PROVEN AS WORKING
307  ridSetAltitudeLow = 0x47, ///< Sets up low part of initial value for 32-bit altitude measurement register. NOT YET PROVEN AS WORKING
308  ridSetAltitudeHigh = 0x48, ///< Sets up high part of initial value for 32-bit altitude measurement register. NOT YET PROVEN AS WORKING
309  ridSetLongitudeLow = 0x49, ///< Sets up low part of initial value for 32-bit longitude measurement register. NOT YET PROVEN AS WORKING
310  ridSetLongitudeHigh = 0x4A, ///< Sets up high part of initial value for 32-bit longitude measurement register. NOT YET PROVEN AS WORKING
311  ridSetLatitudeLow = 0x4B, ///< Sets up low part of initial value for 32-bit latitude measurement register. NOT YET PROVEN AS WORKING
312  ridSetLatitudeHigh = 0x4C, ///< Sets up high part of initial value for 32-bit latitude measurement register. NOT YET PROVEN AS WORKING
313  ridSetGPSAltitude = 0x4D, ///< Sets up initial or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for GPS altitude measurement. NOT YET PROVEN AS WORKING
314  ridSetGPSYaw = 0x4E, ///< Sets up initial or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for GPS orientation angle measurement. NOT YET PROVEN AS WORKING
315  ridSetGPSGroundSpeedLow = 0x4F, ///< Sets up low part of initial value for 32-bit GPS ground speed measurement register. NOT YET PROVEN AS WORKING
316  ridSetGPSGroundSpeedHigh = 0x50, ///< Sets up high part of initial value for 32-bit GPS ground speed measurement register. NOT YET PROVEN AS WORKING
317  ridSetOrientationX = 0x51, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for orientation quaternion, X component. NOT YET PROVEN AS WORKING
318  ridSetOrientationY = 0x52, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for orientation quaternion, Y component. NOT YET PROVEN AS WORKING
319  ridSetOrientationZ = 0x53, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for orientation quaternion, Z component. NOT YET PROVEN AS WORKING
320  ridSetOrientationW = 0x54, ///< Sets up origin point or impostor value (needed when the measurement is forced for output by \ref ridOutputValueSet but not actually supported by the sensor) for orientation quaternion, W component. NOT YET PROVEN AS WORKING
321 
322  ridGyroscopeAutoCalibrate = 0x63, ///< Toggles on/off automatic precalibration of the gyroscope. \ref witmotion_config_packet.setting.`raw[1]` should be set to 0. `0x01` in \ref witmotion_config_packet.setting.`raw[0]` turns gyroscope automatic precalibration **OFF**. To turn it **ON** the value should be `0x00`.
323 
324  ridUnlockConfiguration = 0x69 ///< "Magic" vendor-defined value for configuration unlock packet `0xFF 0xAA 0x69 0x88 0xB5`.
325 };
326 
327 /*!
328  * \brief Generic structure respresenting the standard 5-byte configuration command defined in Witmotion protocol.
329 */
331 {
332  uint8_t header_byte; ///< Header byte, set constantly to \ref WITMOTION_CONFIG_HEADER
333  uint8_t key_byte; ///< Packet type, constantly set to \ref WITMOTION_CONFIG_KEY
334  uint8_t address_byte; ///< Configuration slot address, refers to the registered values in \ref witmotion_config_register_id
335  union
336  {
337  uint8_t raw[2];
338  uint16_t bin;
339  }setting; ///< 2-byte internal data storage array represented as C-style memory union. The values should be formulated byte-by-byte referring to the actual sensor's documentation.
340 };
341 
342 /*!
343  \brief Abstract base class to program convenience classes for the sensors.
344 
345  This class allows the developer to write handler functions for multithreaded polling timer control, sensor configuration request and data decoding event.
346  It also provides predefined signals to allow the end user to react on actual data acquisition and error occurence events.
347  The common use case for this class is to provide a base interface for the family of sensors supporting the same protocol. Please refer to \ref QBaseSerialWitmotionSensorReader class for actual implementation of the currently supported UART-based protocol.
348 */
350 { Q_OBJECT
351 protected slots:
352  virtual void ReadData() = 0; ///< Protected abstract slot to be implemented in the derived class. The common usage is as a callback for the polling timer thread.
353 public slots:
354  virtual void SendConfig(const witmotion_config_packet& packet) = 0; ///< Public abstract slot to be implemented in the derived class. \param packet accepts the \ref witmotion_config_packet object for being sent to the sensor configuration registers.
355  virtual void RunPoll() = 0; ///< Public abstract slot to be implemented in the derived class. The common use is to start the polling timer thread for the sensors after Qt event loop is started.
356 signals:
357  void Acquired(const witmotion_datapacket& packet); ///< Signal function to be emitted when the data packet is acquired by the polling thread or process. Can only be redefined, not overridden in the class hierarchy.
358  void Error(const QString& description); ///< Signal function to be emitted when the internal error reported in the polling thread or process. Can only be redefined, not overridden in the class hierarchy.
359 };
360 
361 }
362 
363 Q_DECLARE_METATYPE(witmotion::witmotion_datapacket); ///< \private
364 Q_DECLARE_METATYPE(witmotion::witmotion_config_packet); ///< \private
365 
366 #endif