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