Witmotion IMU Library 1.3.1~dev_7ac354c
Open source UART communication library for sensor devices manufactured by WitMotion Shenzhen Co.,Ltd
Loading...
Searching...
No Matches
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
24Upper 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*/
28namespace witmotion
29{
30
31static const uint8_t WITMOTION_HEADER_BYTE = 0x55; ///< Packet header byte value (vendor protocol-specific)
32static const uint8_t WITMOTION_CONFIG_HEADER = 0xFF; ///< Configuration header byte value (vendor protocol-specific)
33static const uint8_t WITMOTION_CONFIG_KEY = 0xAA; ///< Configuration marker key byte value (vendor protocol-specific)
34static 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 */
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`.
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
351protected 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.
353public 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.
356signals:
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
363Q_DECLARE_METATYPE(witmotion::witmotion_datapacket); ///< \private
364Q_DECLARE_METATYPE(witmotion::witmotion_config_packet); ///< \private
365
366#endif
Abstract base class to program convenience classes for the sensors.
Definition types.h:350
virtual void RunPoll()=0
Public abstract slot to be implemented in the derived class. The common use is to start the polling t...
void Error(const QString &description)
Signal function to be emitted when the internal error reported in the polling thread or process....
Main namespace of Witmotion UART connection library.
Definition jy901-uart.h:19
witmotion_config_register_id
List of configuration slots (registers) available for the library.
Definition types.h:118
@ ridPortPWMLevelD3
Digital port D3 PWM high level pulse width, microseconds, 16-bit unsigned integer.
Definition types.h:224
@ ridAngularVelocityBiasY
Sets angular velocity zero point bias for Y axis. NOT YET PROVEN AS WORKING.
Definition types.h:182
@ ridSetMagnetometerY
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:295
@ ridTimeDayHour
Sets RTC to the given day of the month (witmotion_config_packet::setting.`raw[0]`) and hour (witmotio...
Definition types.h:285
@ ridGyroscopeRange
Regulates gyroscope value range according to witmotion_config_packet::setting.
Definition types.h:266
@ ridSetAltitudeHigh
Sets up high part of initial value for 32-bit altitude measurement register. NOT YET PROVEN AS WORKIN...
Definition types.h:308
@ ridPortPWMPeriodD1
Digital port D1 PWM period length, microseconds, 16-bit unsigned integer.
Definition types.h:226
@ ridSetAngleRoll
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:297
@ ridPortPWMLevelD0
Digital port D0 PWM high level pulse width, microseconds, 16-bit unsigned integer.
Definition types.h:221
@ ridGPSBaudRate
Regulates GPS receiver baud rate on port D1 (see ridPortModeD1).
Definition types.h:238
@ ridSetPortStatusD2
Action unknown, not yet documented by Witmotion.
Definition types.h:303
@ ridPortPWMPeriodD3
Digital port D3 PWM period length, microseconds, 16-bit unsigned integer.
Definition types.h:228
@ ridSetAltitudeLow
Sets up low part of initial value for 32-bit altitude measurement register. NOT YET PROVEN AS WORKING...
Definition types.h:307
@ ridSetTemperature
Sets up origin point or impostor value (needed when the corresponding spatial measurement is forced f...
Definition types.h:300
@ ridLED
Toggles on/off LED indication (for enclosed sensors only).
Definition types.h:230
@ ridMagnetometerBiasX
Sets magnetometer zero point bias for X axis. MAY BLOCK THE MEASUREMENTS
Definition types.h:184
@ ridSaveSettings
Saves the settings uploaded in the current bringup session, or resets it to default (if supported)....
Definition types.h:119
@ ridSetLatitudeHigh
Sets up high part of initial value for 32-bit latitude measurement register. NOT YET PROVEN AS WORKIN...
Definition types.h:312
@ ridInstructionStart
Instruction mode. 0x00 in witmotion_config_packet::setting.`raw[0]` means starting instruction mode,...
Definition types.h:282
@ ridIICAddress
Sets up I2C address of the sensor. Default value is 0x50, 7-bit unsigned integer in witmotion_config_...
Definition types.h:229
@ ridSetOrientationZ
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:319
@ ridSetMagnetometerZ
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:296
@ ridSetAccelerationX
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:288
@ ridSetAngularVelocityY
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:292
@ ridSetOrientationY
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:318
@ ridSetPortStatusD0
Action unknown, not yet documented by Witmotion.
Definition types.h:301
@ ridSetPressureHigh
Sets up high part of initial value for 32-bit pressure measurement register. NOT YET PROVEN AS WORKIN...
Definition types.h:306
@ ridMagnetometerBiasY
Sets magnetometer zero point bias for Y axis. MAY BLOCK THE MEASUREMENTS
Definition types.h:185
@ ridSetPressureLow
Sets up low part of initial value for 32-bit pressure measurement register. NOT YET PROVEN AS WORKING...
Definition types.h:305
@ ridPortPWMLevelD1
Digital port D1 PWM high level pulse width, microseconds, 16-bit unsigned integer.
Definition types.h:222
@ ridSetGPSYaw
Sets up initial or impostor value (needed when the measurement is forced for output by ridOutputValue...
Definition types.h:314
@ ridSetMagnetometerX
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:294
@ ridSetAngularVelocityX
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:291
@ ridSetLongitudeHigh
Sets up high part of initial value for 32-bit longitude measurement register. NOT YET PROVEN AS WORKI...
Definition types.h:310
@ ridOutputFrequency
Regulates output frequency.
Definition types.h:166
@ ridSetOrientationW
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:320
@ ridPortModeD2
Digital port D2 mode.
Definition types.h:212
@ ridTransitionAlgorithm
Regulates whether 9-axis (0x01 in witmotion_config_packet::setting.`raw[0]`) or 6-axis (0x00) transit...
Definition types.h:281
@ ridSetAccelerationZ
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:290
@ ridPortPWMPeriodD2
Digital port D2 PWM period length, microseconds, 16-bit unsigned integer.
Definition types.h:227
@ ridSetOrientationX
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:317
@ ridSetAngularVelocityZ
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:293
@ ridAccelerometerRange
Regulates accelerometer value range according to witmotion_config_packet::setting.
Definition types.h:278
@ ridPortModeD3
Digital port D3 mode.
Definition types.h:220
@ ridGyroscopeAutoCalibrate
Toggles on/off automatic precalibration of the gyroscope. witmotion_config_packet::setting....
Definition types.h:322
@ ridSetGPSAltitude
Sets up initial or impostor value (needed when the measurement is forced for output by ridOutputValue...
Definition types.h:313
@ ridPortPWMPeriodD0
Digital port D0 PWM period length, microseconds, 16-bit unsigned integer.
Definition types.h:225
@ ridPortModeD1
Digital port D1 mode.
Definition types.h:204
@ ridTimeYearMonth
Sets RTC to the given year (witmotion_config_packet::setting.`raw[0]`) and month (witmotion_config_pa...
Definition types.h:284
@ ridTimeMilliseconds
Sets RTC to the given milliseconds exposed as 16-bit unsigned integer.
Definition types.h:287
@ ridAngularVelocityBiasX
Sets angular velocity zero point bias for X axis. NOT YET PROVEN AS WORKING.
Definition types.h:181
@ ridInstallationDirection
Toggles on/off internal rotation transform for vertical installation. witmotion_config_packet::settin...
Definition types.h:280
@ ridAccelerationBiasZ
Sets acceleration zero point bias for Z axis, refer to Acceleration bias calculation page for explana...
Definition types.h:180
@ ridStandbyMode
Toggles dormant mode. witmotion_config_packet::setting.`raw[0]` should be set to 0x01,...
Definition types.h:279
@ ridSetPortStatusD3
Action unknown, not yet documented by Witmotion.
Definition types.h:304
@ ridSetGPSGroundSpeedHigh
Sets up high part of initial value for 32-bit GPS ground speed measurement register....
Definition types.h:316
@ ridSetGPSGroundSpeedLow
Sets up low part of initial value for 32-bit GPS ground speed measurement register....
Definition types.h:315
@ ridTimeMinuteSecond
Sets RTC to the given minute (witmotion_config_packet::setting.`raw[0]`) and second (witmotion_config...
Definition types.h:286
@ ridAccelerationBiasX
Sets acceleration zero point bias for X axis, refer to Acceleration bias calculation page for explana...
Definition types.h:178
@ ridPortBaudRate
Regulates port baud rate.
Definition types.h:177
@ ridAccelerationBiasY
Sets acceleration zero point bias for Y axis, refer to Acceleration bias calculation page for explana...
Definition types.h:179
@ ridCalibrate
Sets the sensor to calibration mode.
Definition types.h:129
@ ridOutputValueSet
Regulates sensor output.
Definition types.h:144
@ ridSetPortStatusD1
Action unknown, not yet documented by Witmotion.
Definition types.h:302
@ ridSetAnglePitch
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:298
@ ridMagnetometerBiasZ
Sets magnetometer zero point bias for Z axis. MAY BLOCK THE MEASUREMENTS
Definition types.h:186
@ ridFilterBandwidth
Regulates internal filter bandwidth according to witmotion_config_packet::setting.
Definition types.h:253
@ ridPortModeD0
Digital port D0 mode.
Definition types.h:194
@ ridSetAngleYaw
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:299
@ ridPortPWMLevelD2
Digital port D2 PWM high level pulse width, microseconds, 16-bit unsigned integer.
Definition types.h:223
@ ridSetLongitudeLow
Sets up low part of initial value for 32-bit longitude measurement register. NOT YET PROVEN AS WORKIN...
Definition types.h:309
@ ridUnlockConfiguration
"Magic" vendor-defined value for configuration unlock packet 0xFF 0xAA 0x69 0x88 0xB5.
Definition types.h:324
@ ridSetLatitudeLow
Sets up low part of initial value for 32-bit latitude measurement register. NOT YET PROVEN AS WORKING...
Definition types.h:311
@ ridSetAccelerationY
Sets up origin point or impostor value (needed when the measurement is forced for output by ridOutput...
Definition types.h:289
@ ridAngularVelocityBiasZ
Sets angular velocity zero point bias for Z axis. NOT YET PROVEN AS WORKING.
Definition types.h:183
static const std::map< uint8_t, std::string > witmotion_packet_descriptions
Packet ID string set to store built-in descriptions for message-enumerator.
Definition types.h:80
witmotion_packet_id
Packet type IDs from the vendor-defined protocol.
Definition types.h:42
@ pidRTC
Real-Time-Clock: Year from 2000, Month, Day, Hour, Minute, Second (8-bit unsigned integers) + Millise...
Definition types.h:43
@ pidGPSAccuracy
GPS: visible satellites + variance vector [East-North-Up] (16-bit binary normalized quasi-floats)
Definition types.h:53
@ pidAngles
Euler angles + temperature/reserved field [Roll-Pitch-Yaw] (16-bit binary normalized quasi-floats)
Definition types.h:46
@ pidOrientation
Orientation defined as quaternion [X-Y-Z-W], when available from the sensor firmware (16-bit binary n...
Definition types.h:52
@ pidGPSCoordinates
GPS: longitude + latitude, if supported by hardware (32-bit binary normalized quasi-floats)
Definition types.h:50
@ pidGPSGroundSpeed
GPS: ground speed (32-bit binary normalized quasi-float) + altitude + angular velocity around vertica...
Definition types.h:51
@ pidDataPortStatus
Data port status packet, vendor-defined value.
Definition types.h:48
@ pidAltimeter
Altimeter + Barometer output (32-bit binary normalized quasi-floats)
Definition types.h:49
@ pidMagnetometer
Magnetic field tensity + temperature/reserved field [world X-Y-Z] (16-bit binary normalized quasi-flo...
Definition types.h:47
@ pidAcceleration
Linear accelerations + temperature/reserved field [X-Y-Z] (16-bit binary normalized quasi-floats)
Definition types.h:44
@ pidAngularVelocity
Angular velocities + temperature/reserved field [Roll-Pitch-Yaw] (16-bit binary normalized quasi-floa...
Definition types.h:45
static const uint8_t WITMOTION_HEADER_BYTE
Packet header byte value (vendor protocol-specific)
Definition types.h:31
static const uint8_t WITMOTION_CONFIG_HEADER
Configuration header byte value (vendor protocol-specific)
Definition types.h:32
static const std::set< size_t > witmotion_registered_ids
Packet ID set to retrieve descriptions via witmotion_packet_descriptions.
Definition types.h:61
static const uint8_t WITMOTION_CONFIG_KEY
Configuration marker key byte value (vendor protocol-specific)
Definition types.h:33
Generic structure respresenting the standard 5-byte configuration command defined in Witmotion protoc...
Definition types.h:331
uint8_t key_byte
Packet type, constantly set to WITMOTION_CONFIG_KEY.
Definition types.h:333
uint8_t header_byte
Header byte, set constantly to WITMOTION_CONFIG_HEADER.
Definition types.h:332
uint8_t address_byte
Configuration slot address, refers to the registered values in witmotion_config_register_id.
Definition types.h:334
Generic structure respresenting the standard 11-byte datapacket defined in Witmotion protocol.
Definition types.h:98
uint8_t id_byte
Packet type ID, referring to witmotion_packet_id, otherwise the packet is considered of unknown type.
Definition types.h:100
uint8_t crc
Validation CRC for the packet. Calculated as an equivalent to the following operation: reinterpret_ca...
Definition types.h:108
uint8_t header_byte
Header byte, set constantly to WITMOTION_HEADER_BYTE.
Definition types.h:99