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 
18 
19 namespace point_one {
20 namespace fusion_engine {
21 namespace messages {
22 
23 // Enforce 4-byte alignment and packing of all data structures and values.
24 // Floating point values are aligned on platforms that require it. This is done
25 // with a combination of setting struct attributes, and manual alignment
26 // within the definitions. See the "Message Packing" section of the README.
27 #pragma pack(push, 1)
28 
29 /**
30  * @defgroup config_and_ctrl_messages Device Configuration and Control Message Definitions
31  * @brief Messages for controlling device configuration and operation.
32  * @ingroup messages
33  *
34  * When a configuration/control message is received, a device typically responds
35  * with either a @ref CommandResponseMessage or another appropriate response.
36  * For example, a @ref MessageRequest requesting @ref MessageType::VERSION_INFO
37  * may result in a @ref VersionInfoMessage response, or a @ref
38  * CommandResponseMessage indicating that directly requesting version messages
39  * is not supported. See the documentation for the individual control messages
40  * for details on the expected response.
41  *
42  * See also @ref messages.
43  */
44 
45 /**
46  * @brief Response to indicate if command was processed successfully (@ref
47  * MessageType::COMMAND_RESPONSE, version 1.0).
48  * @ingroup config_and_ctrl_messages
49  */
50 struct alignas(4) CommandResponseMessage : public MessagePayload {
52  static constexpr uint8_t MESSAGE_VERSION = 0;
53 
54  /** The sequence number of the command that triggered this response. */
55  uint32_t source_seq_number = 0;
56 
57  /** The response status (success, error, etc.). */
59 
60  uint8_t reserved[3] = {0};
61 };
62 
63 /**
64  * @brief Request transmission of a specified message type, (@ref
65  * MessageType::MESSAGE_REQUEST, version 1.0).
66  * @ingroup config_and_ctrl_messages
67  *
68  * On success, the device will output the requested message type.
69  *
70  * Not all message types may be requested explicitly. If a message type cannot
71  * be requested on demand or is not supported, the device will respond with a
72  * @ref Response::UNSUPPORTED_FEATURE message.
73  *
74  * @note
75  * The generated response may not immediately follow the request if other
76  * outbound messages are already enqueued to be sent.
77  *
78  * # Expected Response
79  * The requested message type, or @ref CommandResponseMessage on error.
80  */
81 struct alignas(4) MessageRequest : public MessagePayload {
83  static constexpr uint8_t MESSAGE_VERSION = 0;
84 
85  /** The desired message type. */
87 
88  uint8_t reserved[2] = {0};
89 };
90 
91 /**
92  * @brief Perform a software or hardware reset (@ref MessageType::RESET_REQUEST,
93  * version 1.0).
94  * @ingroup config_and_ctrl_messages
95  *
96  * This message contains a bitmask indicating the set of components to be reset.
97  * Helper bitmasks are provided for common reset operations.
98  *
99  * # Expected Response
100  * The device will respond with a @ref CommandResponseMessage indicating whether
101  * or not the request succeeded.
102  */
103 struct alignas(4) ResetRequest : public MessagePayload {
105  static constexpr uint8_t MESSAGE_VERSION = 0;
106 
107  /**
108  * @name Runtime State Reset
109  * @{
110  */
111  /** Restart the navigation engine, but do not clear its position estimate. */
112  static constexpr uint32_t RESTART_NAVIGATION_ENGINE = 0x00000001;
113  /** Delete all GNSS corrections information. */
114  static constexpr uint32_t RESET_GNSS_CORRECTIONS = 0x00000002;
115  /** @} */
116 
117  /**
118  * @name Clear Short Lived Data
119  * @{
120  */
121  /**
122  * Reset the navigation engine's estimate of position, velocity, and
123  * orientation.
124  */
125  static constexpr uint32_t RESET_POSITION_DATA = 0x00000100;
126  /** Delete all saved satellite ephemeris. */
127  static constexpr uint32_t RESET_EPHEMERIS = 0x00000200;
128  /**
129  * Reset bias estimates, and other IMU corrections that are typically
130  * estimated quickly.
131  */
132  static constexpr uint32_t RESET_FAST_IMU_CORRECTIONS = 0x00000400;
133  /** @} */
134 
135  /**
136  * @name Clear Long Lived Data
137  * @{
138  */
139  /**
140  * Reset all stored navigation engine data, including position, velocity, and
141  * orientation state, as well as all IMU corrections (fast and slow) and
142  * other training data.
143  */
144  static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA = 0x00001000;
145  /**
146  * Reset the device calibration data.
147  *
148  * @note
149  * This does _not_ reset any existing navigation engine state. It is
150  * recommended that you set @ref RESET_NAVIGATION_ENGINE_DATA as well under
151  * normal circumstances.
152  */
153  static constexpr uint32_t RESET_CALIBRATION_DATA = 0x00002000;
154  /** @} */
155 
156  /**
157  * @name Clear Configuration Data
158  * @{
159  */
160  /** Clear all configuration data. */
161  static constexpr uint32_t RESET_CONFIG = 0x00100000;
162  /** @} */
163 
164  /**
165  * @name Restart Hardware Modules
166  * @{
167  */
168  /** Restart the GNSS measurement engine. */
169  static constexpr uint32_t RESTART_GNSS_MEASUREMENT_ENGINE = 0x01000000;
170  /** Reboot the navigation processor. */
171  static constexpr uint32_t REBOOT_NAVIGATION_PROCESSOR = 0x02000000;
172  /** @} */
173 
174  /**
175  * @name Device Reset Bitmasks
176  * @{
177  */
178  /**
179  * Perform a device hot start.
180  *
181  * A hot start is typically used to restart the navigation engine in a
182  * deterministic state, particularly for logging purposes.
183  *
184  * To be reset:
185  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
186  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
187  *
188  * Not reset:
189  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
190  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
191  * - Training parameters (slowly estimated IMU corrections, temperature
192  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
193  * - Calibration data (@ref RESET_CALIBRATION_DATA)
194  * - User configuration settings (@ref RESET_CONFIG)
195  * - GNSS measurement engine (@ref RESTART_GNSS_MEASUREMENT_ENGINE)
196  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
197  */
198  static constexpr uint32_t HOT_START = 0x000000FF;
199 
200  /**
201  * Perform a device warm start.
202  *
203  * A warm start is typically used to reset the device's estimate of position
204  * and kinematic state in case of error.
205  *
206  * To be reset:
207  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
208  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
209  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
210  *
211  * Not reset:
212  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
213  * - Training parameters (slowly estimated IMU corrections, temperature
214  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
215  * - Calibration data (@ref RESET_CALIBRATION_DATA)
216  * - User configuration settings (@ref RESET_CONFIG)
217  * - GNSS measurement engine (@ref RESTART_GNSS_MEASUREMENT_ENGINE)
218  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
219  */
220  static constexpr uint32_t WARM_START = 0x000001FF;
221 
222  /**
223  * Perform a device cold start.
224  *
225  * A cold start is typically used to reset the device's state estimate in the
226  * case of error that cannot be resolved by a @ref WARM_START.
227  *
228  * To be reset:
229  * - The navigation engine (@ref RESTART_NAVIGATION_ENGINE)
230  * - All runtime data (GNSS corrections (@ref RESET_GNSS_CORRECTIONS), etc.)
231  * - Position, velocity, orientation (@ref RESET_POSITION_DATA)
232  * - Fast IMU corrections (@ref RESET_FAST_IMU_CORRECTIONS)
233  * - GNSS measurement engine (@ref RESTART_GNSS_MEASUREMENT_ENGINE)
234  *
235  * Not reset:
236  * - Training parameters (slowly estimated IMU corrections, temperature
237  * compensation, etc.; @ref RESET_NAVIGATION_ENGINE_DATA)
238  * - Calibration data (@ref RESET_CALIBRATION_DATA)
239  * - User configuration settings (@ref RESET_CONFIG)
240  * - Reboot navigation processor (@ref REBOOT_NAVIGATION_PROCESSOR)
241  *
242  * @note
243  * To reset training or calibration data as well, set the @ref
244  * RESET_NAVIGATION_ENGINE_DATA and @ref RESET_CALIBRATION_DATA bits.
245  */
246  static constexpr uint32_t COLD_START = 0x01000FFF;
247 
248  /**
249  * Restart mask to set all persistent data, including calibration and user
250  * configuration, back to factory defaults.
251  */
252  static constexpr uint32_t FACTORY_RESET = 0xFFFFFFFF;
253  /** @} */
254 
255  /** Bit mask of functionality to reset. */
256  uint32_t reset_mask = 0;
257 };
258 
259 /**
260  * @brief Software and hardware version information, (@ref
261  * MessageType::VERSION_INFO, version 1.0).
262  * @ingroup config_and_ctrl_messages
263  *
264  * This message contains version strings for each of the following, where
265  * available:
266  * - Firmware - The current version of the platform software/firmware being used
267  * - Engine - The version of Point One FusionEngine being used
268  * - Hardware - The version of the platform hardware being used
269  * - GNSS Receiver - The version of firmware being used by the device's GNSS
270  * receiver
271  *
272  * The message payload specifies the length of each string (in bytes). It is
273  * followed by each of the listed version strings consecutively. The strings are
274  * _not_ null terminated.
275  *
276  * ```
277  * {MessageHeader, VersionInfoMessage, "Firmware Version", "Engine Version",
278  * "Hardware Version", "Receiver Version"}
279  * ```
280  */
281 struct alignas(4) VersionInfoMessage : public MessagePayload {
283  static constexpr uint8_t MESSAGE_VERSION = 0;
284 
285  /** The current system timestamp (in ns).*/
286  int64_t system_time_ns = 0;
287 
288  /** The length of the firmware version string (in bytes). */
289  uint8_t fw_version_length = 0;
290 
291  /** The length of the FusionEngine version string (in bytes). */
293 
294  /** The length of the hardware version string (in bytes). */
295  uint8_t hw_version_length = 0;
296 
297  /** The length of the GNSS receiver version string (in bytes). */
298  uint8_t rx_version_length = 0;
299 
300  uint8_t reserved[4] = {0};
301 
302  /**
303  * The beginning of the firmware version string.
304  *
305  * All other version strings follow immediately after this one in the data
306  * buffer. For example, the FusionEngine version string can be obtained as
307  * follows:
308  * ```cpp
309  * std::string engine_version_str(
310  * fw_version_str + message.fw_version_length,
311  * message.engine_version_length);
312  * ```
313  */
314  char fw_version_str[0];
315 };
316 
317 /**
318  * @brief Notification of a system event for logging purposes (@ref
319  * MessageType::EVENT_NOTIFICATION, version 1.0).
320  * @ingroup config_and_ctrl_messages
321  */
322 struct alignas(4) EventNotificationMessage : public MessagePayload {
323  enum class EventType : uint8_t {
324  LOG = 0,
325  RESET = 1,
326  CONFIG_CHANGE = 2,
327  };
328 
329  static const char* to_string(EventType type) {
330  switch (type) {
331  case EventType::LOG:
332  return "Log";
333 
334  case EventType::RESET:
335  return "Reset";
336 
338  return "Config Change";
339 
340  default:
341  return "Unknown";
342  }
343  }
344 
346  static constexpr uint8_t MESSAGE_VERSION = 0;
347 
348  /** The type of event that occurred. */
350 
351  uint8_t reserved1[3] = {0};
352 
353  /** The current system timestamp (in ns).*/
354  int64_t system_time_ns = 0;
355 
356  /** A bitmask of flags associated with the event. */
357  uint64_t event_flags = 0;
358 
359  /** The number of bytes in the @ref event_description string. */
361 
362  uint8_t reserved2[2] = {0};
363 
364  /**
365  * This is a dummy entry to provide a pointer to this offset.
366  *
367  * This is used for populating string describing the event, where applicable.
368  */
370 };
371 
372 /**
373  * @brief Perform a device shutdown (@ref
374  * MessageType::SHUTDOWN_REQUEST, version 1.0).
375  * @ingroup config_and_ctrl_messages
376  *
377  * # Expected Response
378  * The device will respond with a @ref CommandResponseMessage indicating whether
379  * or not the request succeeded.
380  */
381 struct alignas(4) ShutdownRequest : public MessagePayload {
383  static constexpr uint8_t MESSAGE_VERSION = 0;
384  /** A bitmask of flags associated with the event. */
385  uint64_t shutdown_flags = 0;
386  uint8_t reserved1[8] = {0};
387 };
388 
389 #pragma pack(pop)
390 
391 } // namespace messages
392 } // namespace fusion_engine
393 } // namespace point_one
394 
395 #ifdef _MSC_VER
396 # pragma warning(pop)
397 #endif
@ LOG
static constexpr uint32_t RESET_FAST_IMU_CORRECTIONS
Reset bias estimates, and other IMU corrections that are typically estimated quickly.
Definition: control.h:132
uint64_t shutdown_flags
A bitmask of flags associated with the event.
Definition: control.h:385
MessageType
Identifiers for the defined output message types.
Definition: defs.h:32
@ OK
Request transmission of a specified message type, (MessageType::MESSAGE_REQUEST, version 1....
Definition: control.h:81
Response response
The response status (success, error, etc.).
Definition: control.h:58
@ COMMAND_RESPONSE
CommandResponseMessage
@ SHUTDOWN_REQUEST
ShutdownRequest
@ CONFIG_CHANGE
static constexpr uint32_t RESTART_NAVIGATION_ENGINE
Restart the navigation engine, but do not clear its position estimate.
Definition: control.h:112
@ INVALID
Invalid message type.
static constexpr uint32_t RESET_CALIBRATION_DATA
Reset the device calibration data.
Definition: control.h:153
uint8_t fw_version_length
The length of the firmware version string (in bytes).
Definition: control.h:289
Software and hardware version information, (MessageType::VERSION_INFO, version 1.0).
Definition: control.h:281
static constexpr uint32_t RESET_NAVIGATION_ENGINE_DATA
Reset all stored navigation engine data, including position, velocity, and orientation state,...
Definition: control.h:144
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:382
uint64_t event_flags
A bitmask of flags associated with the event.
Definition: control.h:357
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:282
static constexpr uint32_t FACTORY_RESET
Restart mask to set all persistent data, including calibration and user configuration,...
Definition: control.h:252
uint8_t rx_version_length
The length of the GNSS receiver version string (in bytes).
Definition: control.h:298
uint16_t event_description_len_bytes
The number of bytes in the event_description string.
Definition: control.h:360
Notification of a system event for logging purposes (MessageType::EVENT_NOTIFICATION,...
Definition: control.h:322
The base class for all message payloads.
Definition: defs.h:531
@ RESET_REQUEST
ResetRequest
@ VERSION_INFO
VersionInfoMessage
static constexpr uint32_t WARM_START
Perform a device warm start.
Definition: control.h:220
static constexpr uint32_t HOT_START
Perform a device hot start.
Definition: control.h:198
Definition: logging.h:36
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:346
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:354
static const char * to_string(EventType type)
Definition: control.h:329
Perform a software or hardware reset (MessageType::RESET_REQUEST, version 1.0).
Definition: control.h:103
EventType type
The type of event that occurred.
Definition: control.h:349
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:83
uint8_t hw_version_length
The length of the hardware version string (in bytes).
Definition: control.h:295
uint32_t source_seq_number
The sequence number of the command that triggered this response.
Definition: control.h:55
static constexpr uint32_t RESET_CONFIG
Clear all configuration data.
Definition: control.h:161
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:82
char * event_description[0]
This is a dummy entry to provide a pointer to this offset.
Definition: control.h:369
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:283
static constexpr uint32_t RESET_GNSS_CORRECTIONS
Delete all GNSS corrections information.
Definition: control.h:114
EventType
Definition: control.h:323
Response
Command response status indicators.
Definition: defs.h:284
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:51
static constexpr uint32_t REBOOT_NAVIGATION_PROCESSOR
Reboot the navigation processor.
Definition: control.h:171
static constexpr uint32_t COLD_START
Perform a device cold start.
Definition: control.h:246
int64_t system_time_ns
The current system timestamp (in ns).
Definition: control.h:286
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:104
uint8_t engine_version_length
The length of the FusionEngine version string (in bytes).
Definition: control.h:292
static constexpr uint32_t RESTART_GNSS_MEASUREMENT_ENGINE
Restart the GNSS measurement engine.
Definition: control.h:169
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:52
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:105
static constexpr MessageType MESSAGE_TYPE
Definition: control.h:345
Response to indicate if command was processed successfully (MessageType::COMMAND_RESPONSE,...
Definition: control.h:50
static constexpr uint8_t MESSAGE_VERSION
Definition: control.h:383
Perform a device shutdown (MessageType::SHUTDOWN_REQUEST, version 1.0).
Definition: control.h:381
Point One FusionEngine output message common definitions.
char fw_version_str[0]
The beginning of the firmware version string.
Definition: control.h:314
uint32_t reset_mask
Bit mask of functionality to reset.
Definition: control.h:256
@ EVENT_NOTIFICATION
EventNotificationMessage
static constexpr uint32_t RESET_EPHEMERIS
Delete all saved satellite ephemeris.
Definition: control.h:127
static constexpr uint32_t RESET_POSITION_DATA
Reset the navigation engine's estimate of position, velocity, and orientation.
Definition: control.h:125
MessageType message_type
The desired message type.
Definition: control.h:86
@ MESSAGE_REQUEST
MessageRequest
@ RESET