control.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device operation control messages.
3  * @file
4  ******************************************************************************/
5 
6 #pragma once
7 
8 // If we are compiling under MSVC, disable warning C4200:
9 // nonstandard extension used: zero-sized array in struct/union
10 // Zero-sized arrays are supported by MSVC, GCC, and Clang, and we use them as
11 // convenience placeholders for variable sized message payloads.
12 #ifdef _MSC_VER
13 # pragma warning(push)
14 # pragma warning(disable : 4200)
15 #endif
16 
19 
20 namespace point_one {
21 namespace fusion_engine {
22 namespace messages {
23 
24 // Enforce 4-byte alignment and packing of all data structures and values.
25 // Floating point values are aligned on platforms that require it. This is done
26 // with a combination of setting struct attributes, and manual alignment
27 // within the definitions. See the "Message Packing" section of the README.
28 #pragma pack(push, 1)
29 
30 /**
31  * @defgroup config_and_ctrl_messages Device Configuration and Control Message Definitions
32  * @brief Messages for controlling device configuration and operation.
33  * @ingroup messages
34  *
35  * When a configuration/control message is received, a device typically responds
36  * with either a @ref CommandResponseMessage or another appropriate response.
37  * For example, a @ref MessageRequest requesting @ref MessageType::VERSION_INFO
38  * may result in a @ref VersionInfoMessage response, or a @ref
39  * CommandResponseMessage indicating that directly requesting version messages
40  * is not supported. See the documentation for the individual control messages
41  * for details on the expected response.
42  *
43  * See also @ref messages.
44  */
45 
46 /**
47  * @brief Response to indicate if command was processed successfully (@ref
48  * MessageType::COMMAND_RESPONSE, version 1.0).
49  * @ingroup config_and_ctrl_messages
50  */
51 struct alignas(4) CommandResponseMessage : public MessagePayload {
53  static constexpr uint8_t MESSAGE_VERSION = 0;
54 
55  /** The sequence number of the command that triggered this response. */
56  uint32_t source_seq_number = 0;
57 
58  /** The response status (success, error, etc.). */
60 
61  uint8_t reserved[3] = {0};
62 };
63 
64 /**
65  * @brief Request transmission of a specified message type, (@ref
66  * MessageType::MESSAGE_REQUEST, version 1.0).
67  * @ingroup config_and_ctrl_messages
68  *
69  * On success, the device will output the requested message type.
70  *
71  * Not all message types may be requested explicitly. If a message type cannot
72  * be requested on demand or is not supported, the device will respond with a
73  * @ref Response::UNSUPPORTED_FEATURE message.
74  *
75  * @note
76  * The generated response may not immediately follow the request if other
77  * outbound messages are already enqueued to be sent.
78  *
79  * # Expected Response
80  * The requested message type, or @ref CommandResponseMessage on error.
81  */
82 struct alignas(4) MessageRequest : public MessagePayload {
84  static constexpr uint8_t MESSAGE_VERSION = 0;
85 
86  /** The desired message type. */
88 
89  uint8_t reserved[2] = {0};
90 };
91 
92 /**
93  * @brief Perform a software or hardware reset (@ref MessageType::RESET_REQUEST,
94  * version 1.0).
95  * @ingroup config_and_ctrl_messages
96  *
97  * This message contains a bitmask indicating the set of components to be reset.
98  * Helper bitmasks are provided for common reset operations.
99  *
100  * # Expected Response
101  * The device will respond with a @ref CommandResponseMessage indicating whether
102  * or not the request succeeded.
103  */
104 struct alignas(4) ResetRequest : public MessagePayload {
106  static constexpr uint8_t MESSAGE_VERSION = 0;
107 
108  /**
109  * @name Runtime State Reset
110  * @{
111  */
112  /** Restart the navigation engine, but do not clear its position estimate. */
113  static constexpr uint32_t RESTART_NAVIGATION_ENGINE = 0x00000001;
114  /** Delete all GNSS corrections information. */
115  static constexpr uint32_t RESET_GNSS_CORRECTIONS = 0x00000002;
116  /** @} */
117 
118  /**
119  * @name Clear Short Lived Data
120  * @{
121  */
122  /**
123  * Reset the navigation engine's estimate of position, velocity, and
124  * orientation.
125  */
126  static constexpr uint32_t RESET_POSITION_DATA = 0x00000100;
127  /** Delete all saved satellite ephemeris. */
128  static constexpr uint32_t RESET_EPHEMERIS = 0x00000200;
129  /**
130  * Reset bias estimates, and other IMU corrections that are typically
131  * estimated quickly.
132  */
133  static constexpr uint32_t RESET_FAST_IMU_CORRECTIONS = 0x00000400;
134  /** @} */
135 
136  /**
137  * @name Clear Long Lived Data
138  * @{
139  */
140  /**
141  * Reset all stored navigation engine data, including position, velocity, and
142  * orientation state (same as @ref RESET_POSITION_DATA), plus all IMU
143  * corrections and other training data.
144  */
145  static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA = 0x00001000;
146  /**
147  * Reset the device calibration data.
148  *
149  * @note
150  * This does _not_ reset any existing navigation engine state. It is
151  * recommended that you set @ref RESET_NAVIGATION_ENGINE_DATA as well under
152  * normal circumstances.
153  */
154  static constexpr uint32_t RESET_CALIBRATION_DATA = 0x00002000;
155  /** @} */
156 
157  /**
158  * @name Clear Configuration Data
159  * @{
160  */
161  /** Clear all configuration data. */
162  static constexpr uint32_t RESET_CONFIG = 0x00100000;
163  /** @} */
164 
165  /**
166  * @name Software Reboot And Special Reset Modes
167  * @{
168  */
169  /**
170  * Reboot the GNSS measurement engine (GNSS receiver), in addition to
171  * performing any other requested resets (e.g., @ref RESET_EPHEMERIS). If no
172  * other resets are specified, the GNSS receiver will reboot and should
173  * perform a hot start.
174  */
175  static constexpr uint32_t REBOOT_GNSS_MEASUREMENT_ENGINE = 0x01000000;
176  /** Reboot the navigation processor. */
177  static constexpr uint32_t REBOOT_NAVIGATION_PROCESSOR = 0x02000000;
178  /**
179  * Perform a diagnostic log reset to guarantee deterministic performance for
180  * data post-processing and diagnostic support.
181  *
182  * Diagnostic log resets are useful when capturing data to be sent to Point
183  * One for analysis and support. Performing a diagnostic reset guarantees that
184  * the performance of the device seen in real time can be reproduced during
185  * post-processing.
186  *
187  * This reset performs the following:
188  * - Restart the navigation engine (@ref RESTART_NAVIGATION_ENGINE)
189  * - Clear any stored data in RAM that was received since startup such as
190  * ephemeris or GNSS corrections
191  * - This is _not_ the same as @ref RESET_EPHEMERIS; this action does not
192  * reset ephemeris data stored in persistent storage
193  * - Flush internal data buffers on the device
194  *
195  * Note that this does _not_ reset the navigation engine's position data,
196  * training parameters, or calibration. If the navigation engine has existing
197  * position information, it will be used.
198  *
199  * This reset may be combined with other resets as needed to clear additional
200  * information.
201  */
202  static constexpr uint32_t DIAGNOSTIC_LOG_RESET = 0x04000000;
203  /** @} */
204 
205  /**
206  * @name Device Reset Bitmasks
207  * @{
208  */
209  /**
210  * Perform a device hot start.
211  *
212  * This will reset the navigation engine into a known state, using previously
213  * stored position and time information. The device will begin navigating
214  * immediately if possible.
215  *
216  * To be reset:
217  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
218  *
219  * Not reset/performed:
220  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
221  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
222  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
223  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
224  * - Training parameters (slowly estimated IMU corrections, temperature
225  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
226  * - Calibration data (@ref RESET_CALIBRATION_DATA)
227  * - User configuration settings (@ref RESET_CONFIG)
228  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
229  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
230  */
231  static constexpr uint32_t HOT_START = 0x00000001;
232 
233  /**
234  * Perform a device warm start.
235  *
236  * During a warm start, the device retains its knowledge of approximate
237  * position and time, plus almanac data if available, but resets all ephemeris
238  * data. As a result, the device will need to download ephemeris data before
239  * continuing to navigate with GNSS.
240  *
241  * To be reset:
242  * - The navigation engine (i.e., perform a hot start, @ref
243  * RESTART_NAVIGATION_ENGINE)
244  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
245  *
246  * Not reset/performed:
247  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
248  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
249  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
250  * - Training parameters (slowly estimated IMU corrections, temperature
251  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
252  * - Calibration data (@ref RESET_CALIBRATION_DATA)
253  * - User configuration settings (@ref RESET_CONFIG)
254  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
255  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
256  */
257  static constexpr uint32_t WARM_START = 0x00000201;
258 
259  /**
260  * Perform a PVT reset: reset all position, velocity, orientation, and time
261  * information (i.e., the navigation engine's kinematic state).
262  *
263  * A PVT reset is typically used to reset the kinematic portion of the
264  * navigation engine's state if you are experiencing errors on startup or
265  * after a @ref HOT_START.
266  *
267  * To be reset:
268  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
269  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
270  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
271  *
272  * Not reset/performed:
273  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
274  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
275  * - Training parameters (slowly estimated IMU corrections, temperature
276  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
277  * - Calibration data (@ref RESET_CALIBRATION_DATA)
278  * - User configuration settings (@ref RESET_CONFIG)
279  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
280  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
281  */
282  static constexpr uint32_t PVT_RESET = 0x000001FF;
283 
284  /**
285  * Perform a device cold start.
286  *
287  * A cold start is typically used to reset the device's state estimate in the
288  * case of error that cannot be resolved by a @ref WARM_START.
289  *
290  * To be reset:
291  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
292  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
293  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
294  * - GNSS ephemeris data (@ref RESET_EPHEMERIS)
295  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
296  *
297  * Not reset/performed:
298  * - Training parameters (slowly estimated IMU corrections, temperature
299  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
300  * - Calibration data (@ref RESET_CALIBRATION_DATA)
301  * - User configuration settings (@ref RESET_CONFIG)
302  * - Reboot GNSS measurement engine (@ref REBOOT_GNSS_MEASUREMENT_ENGINE)
303  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
304  *
305  * @note
306  * To reset training or calibration data as well, set the @ref
307  * RESET_NAVIGATION_ENGINE_DATA and @ref RESET_CALIBRATION_DATA bits.
308  */
309  static constexpr uint32_t COLD_START = 0x00000FFF;
310 
311  /**
312  * Restart mask to set all persistent data, including calibration and user
313  * configuration, back to factory defaults.
314  */
315  static constexpr uint32_t FACTORY_RESET = 0xFFFFFFFF;
316  /** @} */
317 
318  /** Bit mask of functionality to reset. */
319  uint32_t reset_mask = 0;
320 };
321 
322 /**
323  * @brief Software and hardware version information, (@ref
324  * MessageType::VERSION_INFO, version 1.0).
325  * @ingroup config_and_ctrl_messages
326  *
327  * This message contains version strings for each of the following, where
328  * available:
329  * - Firmware - The current version of the platform software/firmware being used
330  * - Engine - The version of Point One FusionEngine being used
331  * - Hardware - The version of the platform hardware being used
332  * - GNSS Receiver - The version of firmware being used by the device's GNSS
333  * receiver
334  *
335  * The message payload specifies the length of each string (in bytes). It is
336  * followed by each of the listed version strings consecutively. The strings are
337  * _not_ null terminated.
338  *
339  * ```
340  * {MessageHeader, VersionInfoMessage, "Firmware Version", "Engine Version",
341  * "Hardware Version", "Receiver Version"}
342  * ```
343  */
344 struct alignas(4) VersionInfoMessage : public MessagePayload {
346  static constexpr uint8_t MESSAGE_VERSION = 0;
347 
348  /** The current system timestamp (in ns).*/
349  int64_t system_time_ns = 0;
350 
351  /** The length of the firmware version string (in bytes). */
352  uint8_t fw_version_length = 0;
353 
354  /** The length of the FusionEngine version string (in bytes). */
356 
357  /** The length of the hardware version string (in bytes). */
358  uint8_t hw_version_length = 0;
359 
360  /** The length of the GNSS receiver version string (in bytes). */
361  uint8_t rx_version_length = 0;
362 
363  uint8_t reserved[4] = {0};
364 
365  /**
366  * The beginning of the firmware version string.
367  *
368  * All other version strings follow immediately after this one in the data
369  * buffer. For example, the FusionEngine version string can be obtained as
370  * follows:
371  * ```cpp
372  * std::string engine_version_str(
373  * fw_version_str + message.fw_version_length,
374  * message.engine_version_length);
375  * ```
376  */
377  char fw_version_str[0];
378 };
379 
380 /**
381  * @brief Notification of a system event for logging purposes (@ref
382  * MessageType::EVENT_NOTIFICATION, version 1.0).
383  * @ingroup config_and_ctrl_messages
384  */
385 struct alignas(4) EventNotificationMessage : public MessagePayload {
386  enum class EventType : uint8_t {
387  /**
388  * Event containing a logged message string from the device.
389  */
390  LOG = 0,
391  /**
392  * Event indicating a device reset occurred. The event flags will be set to
393  * the requested reset bitmask, if applicable (see @ref ResetRequest). The
394  * payload will contain a string describing the cause of the reset.
395  */
396  RESET = 1,
397  /**
398  * Notification that the user configuration has been changed. Intended for
399  * diagnostic purposes.
400  */
401  CONFIG_CHANGE = 2,
402  /**
403  * Notification that the user performed a command (e.g., configuration
404  * request, fault injection enable/disable).
405  */
406  COMMAND = 3,
407  /**
408  * Record containing the response to a user command. Response events are not
409  * output on the interface on which the command was received; that interface
410  * will receive the response itself.
411  */
412  COMMAND_RESPONSE = 4,
413  };
414 
416  switch (type) {
417  case EventType::LOG:
418  return "Log";
419 
420  case EventType::RESET:
421  return "Reset";
422 
424  return "Config Change";
425 
426  case EventType::COMMAND:
427  return "Command";
428 
430  return "Command Response";
431 
432  default:
433  return "Unknown";
434  }
435  }
436 
438  static constexpr uint8_t MESSAGE_VERSION = 0;
439 
440  /** The type of event that occurred. */
442 
443  uint8_t reserved1[3] = {0};
444 
445  /** The current system timestamp (in ns).*/
446  int64_t system_time_ns = 0;
447 
448  /** A bitmask of flags associated with the event. */
449  uint64_t event_flags = 0;
450 
451  /** The number of bytes in the @ref event_description string. */
453 
454  uint8_t reserved2[2] = {0};
455 
456  /**
457  * This is a dummy entry to provide a pointer to this offset.
458  *
459  * This is used for populating string describing the event, or other binary
460  * content where applicable.
461  */
463 };
464 
465 /**
466  * @brief Perform a device shutdown (@ref
467  * MessageType::SHUTDOWN_REQUEST, version 1.0).
468  * @ingroup config_and_ctrl_messages
469  *
470  * # Expected Response
471  * The device will respond with a @ref CommandResponseMessage indicating whether
472  * or not the request succeeded.
473  */
474 struct alignas(4) ShutdownRequest : public MessagePayload {
476  static constexpr uint8_t MESSAGE_VERSION = 0;
477  /** A bitmask of flags associated with the event. */
478  uint64_t shutdown_flags = 0;
479  uint8_t reserved1[8] = {0};
480 };
481 
482 #pragma pack(pop)
483 
484 } // namespace messages
485 } // namespace fusion_engine
486 } // namespace point_one
487 
488 #ifdef _MSC_VER
489 # pragma warning(pop)
490 #endif
@ LOG
Event containing a logged message string from the device.
static constexpr uint32_t RESET_FAST_IMU_CORRECTIONS
Reset bias estimates, and other IMU corrections that are typically estimated quickly.
Definition: control.h:133
uint64_t shutdown_flags
A bitmask of flags associated with the event.
Definition: control.h:478
MessageType
Identifiers for the defined output message types.
Definition: defs.h:35
Library portability helper definitions.
@ OK
Request transmission of a specified message type, (MessageType::MESSAGE_REQUEST, version 1....
Definition: control.h:82
Response response
The response status (success, error, etc.).
Definition: control.h:59
@ COMMAND_RESPONSE
CommandResponseMessage
@ SHUTDOWN_REQUEST
ShutdownRequest
@ CONFIG_CHANGE
Notification that the user configuration has been changed.
static constexpr uint32_t RESTART_NAVIGATION_ENGINE
Restart the navigation engine, but do not clear its position estimate.
Definition: control.h:113
@ INVALID
Invalid message type.
static constexpr uint32_t RESET_CALIBRATION_DATA
Reset the device calibration data.
Definition: control.h:154
uint8_t fw_version_length
The length of the firmware version string (in bytes).
Definition: control.h:352
Software and hardware version information, (MessageType::VERSION_INFO, version 1.0).
Definition: control.h:344
@ COMMAND_RESPONSE
Record containing the response to a user command.
static constexpr uint32_t REBOOT_GNSS_MEASUREMENT_ENGINE
Reboot the GNSS measurement engine (GNSS receiver), in addition to performing any other requested res...
Definition: control.h:175
static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA
Reset all stored navigation engine data, including position, velocity, and orientation state (same as...
Definition: control.h:145
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:475
uint64_t event_flags
A bitmask of flags associated with the event.
Definition: control.h:449
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:345
static constexpr uint32_t FACTORY_RESET
Restart mask to set all persistent data, including calibration and user configuration,...
Definition: control.h:315
uint8_t rx_version_length
The length of the GNSS receiver version string (in bytes).
Definition: control.h:361
uint16_t event_description_len_bytes
The number of bytes in the event_description string.
Definition: control.h:452
Notification of a system event for logging purposes (MessageType::EVENT_NOTIFICATION,...
Definition: control.h:385
The base class for all message payloads.
Definition: defs.h:540
@ RESET_REQUEST
ResetRequest
static P1_CONSTEXPR_FUNC const char * to_string(EventType type)
Definition: control.h:415
@ VERSION_INFO
VersionInfoMessage
static constexpr uint32_t WARM_START
Perform a device warm start.
Definition: control.h:257
static constexpr uint32_t HOT_START
Perform a device hot start.
Definition: control.h:231
GNSS signal and frequency type definitions.
Definition: logging.h:36
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:438
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:446
Perform a software or hardware reset (MessageType::RESET_REQUEST, version 1.0).
Definition: control.h:104
EventType type
The type of event that occurred.
Definition: control.h:441
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:84
static constexpr uint32_t PVT_RESET
Perform a PVT reset: reset all position, velocity, orientation, and time information (i....
Definition: control.h:282
uint8_t hw_version_length
The length of the hardware version string (in bytes).
Definition: control.h:358
uint32_t source_seq_number
The sequence number of the command that triggered this response.
Definition: control.h:56
static constexpr uint32_t RESET_CONFIG
Clear all configuration data.
Definition: control.h:162
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:83
char * event_description[0]
This is a dummy entry to provide a pointer to this offset.
Definition: control.h:462
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:346
static constexpr uint32_t RESET_GNSS_CORRECTIONS
Delete all GNSS corrections information.
Definition: control.h:115
EventType
Definition: control.h:386
Response
Command response status indicators.
Definition: defs.h:265
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:52
static constexpr uint32_t REBOOT_NAVIGATION_PROCESSOR
Reboot the navigation processor.
Definition: control.h:177
static constexpr uint32_t COLD_START
Perform a device cold start.
Definition: control.h:309
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:349
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:105
uint8_t engine_version_length
The length of the FusionEngine version string (in bytes).
Definition: control.h:355
#define P1_CONSTEXPR_FUNC
Definition: portability.h:58
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:53
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:106
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:437
Response to indicate if command was processed successfully (MessageType::COMMAND_RESPONSE,...
Definition: control.h:51
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:476
Perform a device shutdown (MessageType::SHUTDOWN_REQUEST, version 1.0).
Definition: control.h:474
Point One FusionEngine output message common definitions.
char fw_version_str[0]
The beginning of the firmware version string.
Definition: control.h:377
uint32_t reset_mask
Bit mask of functionality to reset.
Definition: control.h:319
static constexpr uint32_t DIAGNOSTIC_LOG_RESET
Perform a diagnostic log reset to guarantee deterministic performance for data post-processing and di...
Definition: control.h:202
@ EVENT_NOTIFICATION
EventNotificationMessage
static constexpr uint32_t RESET_EPHEMERIS
Delete all saved satellite ephemeris.
Definition: control.h:128
static constexpr uint32_t RESET_POSITION_DATA
Reset the navigation engine's estimate of position, velocity, and orientation.
Definition: control.h:126
MessageType message_type
The desired message type.
Definition: control.h:87
@ MESSAGE_REQUEST
MessageRequest
@ RESET
Event indicating a device reset occurred.
@ COMMAND
Notification that the user performed a command (e.g., configuration request, fault injection enable/d...