configuration.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device configuration settings 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 
17 #include <ostream>
18 
21 
22 namespace point_one {
23 namespace fusion_engine {
24 namespace messages {
25 
26 // Enforce 4-byte alignment and packing of all data structures and values.
27 // Floating point values are aligned on platforms that require it. This is done
28 // with a combination of setting struct attributes, and manual alignment
29 // within the definitions. See the "Message Packing" section of the README.
30 #pragma pack(push, 1)
31 
32 /**
33  * @brief An identifier for the contents of a parameter configuration message.
34  * @ingroup config_and_ctrl_messages
35  *
36  * See also @ref SetConfigMessage.
37  */
38 enum class ConfigType : uint16_t {
39  INVALID = 0,
40 
41  /**
42  * The location of the device IMU with respect to the vehicle body frame (in
43  * meters).
44  *
45  * Payload format: @ref Point3f
46  */
47  DEVICE_LEVER_ARM = 16,
48 
49  /**
50  * The orientation of the device IMU with respect to the vehicle body axes.
51  *
52  * Payload format: @ref CoarseOrientation
53  */
55 
56  /**
57  * The location of the GNSS antenna with respect to the vehicle body frame (in
58  * meters).
59  *
60  * Payload format: @ref Point3f
61  */
62  GNSS_LEVER_ARM = 18,
63 
64  /**
65  * The offset of the desired output location with respect to the vehicle
66  * body frame (in meters).
67  *
68  * Payload format: @ref Point3f
69  */
70  OUTPUT_LEVER_ARM = 19,
71 
72  /**
73  * Information about the vehicle including model and dimensions.
74  *
75  * Payload format: @ref VehicleDetails
76  */
77  VEHICLE_DETAILS = 20,
78 
79  /**
80  * Information pertaining to wheel speed/rotation measurements.
81  *
82  * Payload format: @ref WheelConfig
83  */
84  WHEEL_CONFIG = 21,
85 
86  /**
87  * Indicates the mode and direction used when capturing vehicle wheel tick
88  * data from a voltage pulse on an I/O pin.
89  *
90  * Payload format: @ref HardwareTickConfig
91  */
93 
94  /**
95  * Configure the UART1 serial baud rate (in bits/second).
96  *
97  * Payload format: `uint32_t`
98  */
99  UART1_BAUD = 256,
100 
101  /**
102  * Configure the UART2 serial baud rate (in bits/second).
103  *
104  * Payload format: `uint32_t`
105  */
106  UART2_BAUD = 257,
107 
108  /**
109  * Force output the diagnostic message set on UART1.
110  *
111  * Payload format: `bool`
112  */
114 
115  /**
116  * Force output the diagnostic message set on UART2.
117  *
118  * Payload format: `bool`
119  */
121 
122  /**
123  * Enable watchdog timer to restart device after fatal errors.
124  *
125  * Payload format: `bool`
126  */
127  ENABLE_WATCHDOG_TIMER = 300,
128 };
129 
130 /**
131  * @brief Get a human-friendly string name for the specified @ref ConfigType.
132  * @ingroup config_and_ctrl_messages
133  *
134  * @param type The desired configuration parameter type.
135  *
136  * @return The corresponding string name.
137  */
138 inline const char* to_string(ConfigType type) {
139  switch (type) {
140  case ConfigType::INVALID:
141  return "Invalid";
142 
144  return "Device Lever Arm";
145 
147  return "Device Coarse Orientation";
148 
150  return "GNSS Lever Arm";
151 
153  return "Output Lever Arm";
154 
156  return "Vehicle Details";
157 
159  return "Wheel Config";
160 
162  return "Hardware Tick Config";
163 
165  return "UART1 Baud Rate";
166 
168  return "UART2 Baud Rate";
169 
171  return "UART1 Diagnostic Messages Enabled";
172 
174  return "UART2 Diagnostic Messages Enabled";
175 
177  return "Watchdog Timer Enabled";
178 
179  default:
180  return "Unrecognized Configuration";
181  }
182 }
183 
184 /**
185  * @brief @ref ConfigType stream operator.
186  * @ingroup config_and_ctrl_messages
187  */
188 inline std::ostream& operator<<(std::ostream& stream, ConfigType type) {
189  stream << to_string(type) << " (" << (int)type << ")";
190  return stream;
191 }
192 
193 /**
194  * @brief The type of a device's configuration settings.
195  * @ingroup config_and_ctrl_messages
196  */
197 enum class ConfigurationSource : uint8_t {
198  ACTIVE = 0, ///< Active configuration currently in use by the device.
199  SAVED = 1, ///< Settings currently saved to persistent storage.
200 };
201 
202 /**
203  * @brief Get a human-friendly string name for the specified @ref
204  * ConfigurationSource.
205  * @ingroup config_and_ctrl_messages
206  *
207  * @param source The desired configuration source.
208  *
209  * @return The corresponding string name.
210  */
211 inline const char* to_string(ConfigurationSource source) {
212  switch (source) {
214  return "Active";
215 
217  return "Saved";
218 
219  default:
220  return "Unrecognized Source";
221  }
222 }
223 
224 /**
225  * @brief @ref ConfigurationSource stream operator.
226  * @ingroup config_and_ctrl_messages
227  */
228 inline std::ostream& operator<<(std::ostream& stream,
229  ConfigurationSource source) {
230  stream << to_string(source) << " (" << (int)source << ")";
231  return stream;
232 }
233 
234 /**
235  * @brief The type configuration save operation to be performed.
236  * @ingroup config_and_ctrl_messages
237  */
238 enum class SaveAction : uint8_t {
239  /** Save all active parameters to persistent storage. */
240  SAVE = 0,
241  /** Revert the active configuration to previously saved values. */
242  REVERT_TO_SAVED = 1,
243  /** Reset the active _and_ saved configuration to default values. */
244  REVERT_TO_DEFAULT = 2,
245 };
246 
247 /**
248  * @brief Get a human-friendly string name for the specified @ref SaveAction.
249  * @ingroup config_and_ctrl_messages
250  *
251  * @param action The desired save operation.
252  *
253  * @return The corresponding string name.
254  */
255 inline const char* to_string(SaveAction action) {
256  switch (action) {
257  case SaveAction::SAVE:
258  return "Save";
259 
261  return "Revert To Saved";
262 
264  return "Revert To Default";
265 
266  default:
267  return "Unknown";
268  }
269 }
270 
271 /**
272  * @brief @ref SaveAction stream operator.
273  * @ingroup config_and_ctrl_messages
274  */
275 inline std::ostream& operator<<(std::ostream& stream, SaveAction action) {
276  stream << to_string(action) << " (" << (int)action << ")";
277  return stream;
278 }
279 
280 /**
281  * @brief Set a user configuration parameter (@ref MessageType::SET_CONFIG,
282  * version 1.0).
283  * @ingroup config_and_ctrl_messages
284  *
285  * The format of the parameter value, @ref config_change_data, is defined by the
286  * the specified @ref config_type (@ref ConfigType). For example, an antenna
287  * lever arm definition may require three 32-bit `float` values, one for each
288  * axis, while a serial port baud rate may be specified as single 32-bit
289  * unsigned integer (`uint32_t`).
290  *
291  * Not all parameters defined in @ref ConfigType are supported on all devices.
292  *
293  * Parameter changes are applied to the device's active configuration
294  * immediately, but are not saved to persistent storage and will be restored to
295  * their previous values on reset. To save configuration settings to persistent
296  * storage, see @ref SaveConfigMessage.
297  *
298  * # Expected Response
299  * The device will respond with a @ref CommandResponseMessage indicating whether
300  * or not the request succeeded.
301  */
302 struct alignas(4) SetConfigMessage : public MessagePayload {
304  static constexpr uint8_t MESSAGE_VERSION = 0;
305 
306  /** Flag to immediately save the config after applying this setting. */
307  static constexpr uint8_t FLAG_APPLY_AND_SAVE = 0x01;
308 
309  /** The type of parameter to be configured. */
311 
312  /** Bitmask of additional flags to modify the command. */
313  uint8_t flags = 0;
314 
315  uint8_t reserved[1] = {0};
316 
317  /** The size of the parameter value, @ref config_change_data (in bytes). */
318  uint32_t config_length_bytes = 0;
319 
320  /**
321  * A pointer to the beginning of the configuration parameter value.
322  *
323  * The size and format of the contents is specified by the @ref config_type.
324  * See @ref ConfigType.
325  */
326  uint8_t config_change_data[0];
327 };
328 
329 /**
330  * @brief Query the value of a user configuration parameter (@ref
331  * MessageType::GET_CONFIG, version 1.0).
332  * @ingroup config_and_ctrl_messages
333  *
334  * # Expected Response
335  * The device will respond with a @ref ConfigResponseMessage containing the
336  * requested parameter value, or a @ref CommandResponseMessage on failure.
337  */
338 struct alignas(4) GetConfigMessage : public MessagePayload {
340  static constexpr uint8_t MESSAGE_VERSION = 0;
341 
342  /** The desired parameter. */
344 
345  /** The config source to request data from (active, saved, etc.). */
347 
348  uint8_t reserved[1] = {0};
349 };
350 
351 /**
352  * @brief Save or reload configuration settings (@ref MessageType::SAVE_CONFIG,
353  * version 1.0).
354  * @ingroup config_and_ctrl_messages
355  *
356  * # Expected Response
357  * The device will respond with a @ref CommandResponseMessage indicating whether
358  * or not the request succeeded.
359  */
360 struct alignas(4) SaveConfigMessage : public MessagePayload {
362  static constexpr uint8_t MESSAGE_VERSION = 0;
363 
364  /** The action to performed. */
366 
367  uint8_t reserved[3] = {0};
368 };
369 
370 /**
371  * @brief Response to a @ref GetConfigMessage request (@ref
372  * MessageType::CONFIG_RESPONSE, version 1.0).
373  * @ingroup config_and_ctrl_messages
374  *
375  * This message is followed by `N` bytes, where `N` is equal to @ref
376  * config_length_bytes that make up the data associated with @ref config_type.
377  * For example if the @ref config_type is @ref ConfigType::UART1_BAUD, the
378  * payload will include a single 32-bit unsigned integer:
379  *
380  * ```
381  * {MessageHeader, ConfigResponseMessage, uint32_t}
382  * ```
383  *
384  * In response to a @ref GetConfigMessage with an invalid or unsupported @ref
385  * ConfigType, @ref config_type in the resulting @ref ConfigResponseMessage will
386  * be set to @ref ConfigType::INVALID, and @ref response will indicate the
387  * reason. Note that all @ref GetConfigMessage requests, including invalid and
388  * rejected requests, will receive a @ref ConfigResponseMessage, not a
389  * @ref CommandResponseMessage.
390  */
391 struct alignas(4) ConfigResponseMessage : public MessagePayload {
393  static constexpr uint8_t MESSAGE_VERSION = 0;
394 
395  /**
396  * Flag to indicate the active value for this configuration differs from the
397  * value saved to persistent memory.
398  */
399  static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED = 0x1;
400 
401  /** The source of the parameter value (active, saved, etc.). */
403 
404  /** Flags that describe the configuration parameter. */
405  uint8_t flags = 0;
406 
407  /** The type of configuration parameter contained in this message. */
409 
410  /** The response status (success, error, etc.). */
412 
413  uint8_t reserved[3] = {0};
414 
415  /** The size of the parameter value, @ref config_change_data (in bytes). */
416  uint32_t config_length_bytes = 0;
417 
418  /**
419  * A pointer to the beginning of the configuration parameter value.
420  *
421  * The size and format of the contents is specified by the @ref config_type.
422  * See @ref ConfigType.
423  */
424  uint8_t config_change_data[0];
425 };
426 
427 /**************************************************************************/ /**
428  * @name Configuration Settings Type Definitions
429  * @{
430  ******************************************************************************/
431 
432 /**
433  * @brief A 3-dimensional vector (used for lever arms, etc.).
434  */
435 struct alignas(4) Point3f {
436  float x = NAN;
437  float y = NAN;
438  float z = NAN;
439 };
440 
441 /**
442  * @brief The orientation of a device with respect to the vehicle body axes.
443  *
444  * A device's orientation is defined by specifying how the +x and +z axes of its
445  * IMU are aligned with the vehicle body axes. For example, in a car:
446  * - `forward,up`: device +x = vehicle +x, device +z = vehicle +z (i.e.,
447  * IMU pointed towards the front of the vehicle).
448  * - `left,up`: device +x = vehicle +y, device +z = vehicle +z (i.e., IMU
449  * pointed towards the left side of the vehicle)
450  * - `up,backward`: device +x = vehicle +z, device +z = vehicle -x (i.e.,
451  * IMU pointed vertically upward, with the top of the IMU pointed towards the
452  * trunk)
453  */
454 struct alignas(4) CoarseOrientation {
455  enum class Direction : uint8_t {
456  FORWARD = 0, ///< Aligned with vehicle +x axis.
457  BACKWARD = 1, ///< Aligned with vehicle -x axis.
458  LEFT = 2, ///< Aligned with vehicle +y axis.
459  RIGHT = 3, ///< Aligned with vehicle -y axis.
460  UP = 4, ///< Aligned with vehicle +z axis.
461  DOWN = 5, ///< Aligned with vehicle -z axis.
462  INVALID = 255
463  };
464 
465  /** The direction of the device +x axis relative to the vehicle body axes. */
467 
468  /** The direction of the device +z axis relative to the vehicle body axes. */
470 
471  uint8_t reserved[2] = {0};
472 };
473 
474 /**
475  * @brief The make and model of the vehicle.
476  * @ingroup config_and_ctrl_messages
477  */
478 enum class VehicleModel : uint16_t {
479  UNKNOWN_VEHICLE = 0,
480  DATASPEED_CD4 = 1,
481  // In general, all J1939 vehicles support a subset of the J1939 standard and
482  // may be set to vehicle model `J1939`. Their 29-bit CAN IDs may differ
483  // based on how the platform assigns message priorities and source
484  // addresses, but the underlying program group number (PGN) and message
485  // contents will be consistent.
486  //
487  // For most vehicles, it is not necessary to specify and particular make and
488  // model.
489  J1939 = 2,
490 
491  LEXUS_CT200H = 20,
492 
493  KIA_SORENTO = 40,
494  KIA_SPORTAGE = 41,
495 
496  AUDI_Q7 = 60,
497  AUDI_A8L = 61,
498 
499  TESLA_MODEL_X = 80,
500  TESLA_MODEL_3 = 81,
501 
502  HYUNDAI_ELANTRA = 100,
503 
504  PEUGEOT_206 = 120,
505 
506  MAN_TGX = 140,
507 
508  FACTION = 160,
509 
510  LINCOLN_MKZ = 180,
511 
512  BMW_7 = 200,
513 };
514 
515 /**
516  * @brief Get a human-friendly string name for the specified @ref VehicleModel.
517  * @ingroup config_and_ctrl_messages
518  *
519  * @param vehicle_model The desired vehicle model.
520  *
521  * @return The corresponding string name.
522  */
523 inline const char* to_string(VehicleModel vehicle_model) {
524  switch (vehicle_model) {
526  return "UNKNOWN";
528  return "DATASPEED_CD4";
529  case VehicleModel::J1939:
530  return "J1939";
532  return "LEXUS_CT200H";
534  return "KIA_SORENTO";
536  return "KIA_SPORTAGE";
538  return "AUDI_Q7";
540  return "AUDI_A8L";
542  return "TESLA_MODEL_X";
544  return "TESLA_MODEL_3";
546  return "HYUNDAI_ELANTRA";
548  return "PEUGEOT_206";
550  return "MAN_TGX";
552  return "FACTION";
554  return "LINCOLN_MKZ";
555  case VehicleModel::BMW_7:
556  return "BMW_7";
557  default:
558  return "UNRECOGNIZED";
559  }
560 }
561 
562 /**
563  * @brief @ref VehicleModel stream operator.
564  * @ingroup config_and_ctrl_messages
565  */
566 inline std::ostream& operator<<(std::ostream& stream,
567  VehicleModel vehicle_model) {
568  stream << to_string(vehicle_model) << " (" << (int)vehicle_model << ")";
569  return stream;
570 }
571 
572 /**
573  * @brief Information about the vehicle including model and dimensions.
574  * @ingroup config_and_ctrl_messages
575  */
576 struct alignas(4) VehicleDetails {
578  uint8_t reserved[10] = {0};
579 
580  /** The distance between the front axle and rear axle (in meters). */
581  float wheelbase_m = NAN;
582 
583  /** The distance between the two front wheels (in meters). */
584  float front_track_width_m = NAN;
585 
586  /** The distance between the two rear wheels (in meters). */
587  float rear_track_width_m = NAN;
588 };
589 
590 /**
591  * @brief The type of vehicle/wheel speed measurements produced by the vehicle.
592  * @ingroup config_and_ctrl_messages
593  */
594 enum class WheelSensorType : uint8_t {
595  /** Wheel/vehicle speed data not available. */
596  NONE = 0,
597  /**
598  * Individual wheel rotation rates, reported as an encoder tick rate (in
599  * ticks/second). Will be scaled to meters/second using the specified scale
600  * factor.
601  */
602  TICK_RATE = 1,
603  /**
604  * Individual wheel rotational angles, reported as accumulated encoder
605  * ticks.
606  * */
607  TICKS = 2,
608  /** Individual wheel speeds, reported in meters/second. */
609  WHEEL_SPEED = 3,
610  /** A single value indicating the vehicle speed (in meters/second). */
611  VEHICLE_SPEED = 4,
612  /** A single wheel rotational angle, reported as accumulated encoder ticks. */
613  VEHICLE_TICKS = 5,
614 };
615 
616 /**
617  * @brief Get a human-friendly string name for the specified @ref
618  * WheelSensorType.
619  * @ingroup config_and_ctrl_messages
620  *
621  * @param wheel_sensor_type The desired wheel sensor type.
622  *
623  * @return The corresponding string name.
624  */
625 inline const char* to_string(WheelSensorType wheel_sensor_type) {
626  switch (wheel_sensor_type) {
627  case WheelSensorType::NONE: {
628  return "None";
629  }
631  return "Tick Rate";
632  }
633  case WheelSensorType::TICKS: {
634  return "Ticks";
635  }
637  return "Wheel Speed";
638  }
640  return "Vehicle Speed";
641  }
643  return "Vehicle Ticks";
644  }
645  default: {
646  return "None";
647  }
648  }
649 }
650 
651 /**
652  * @brief @ref WheelSensorType stream operator.
653  * @ingroup config_and_ctrl_messages
654  */
655 inline std::ostream& operator<<(std::ostream& stream,
656  WheelSensorType wheel_sensor_type) {
657  stream << to_string(wheel_sensor_type) << " (" << (int)wheel_sensor_type
658  << ")";
659  return stream;
660 }
661 
662 /**
663  * @brief The type of vehicle/wheel speed measurements to be applied.
664  * @ingroup config_and_ctrl_messages
665  */
666 enum class AppliedSpeedType : uint8_t {
667  /** Speed data not applied to the system. */
668  NONE = 0,
669  /** Rear wheel speed data to be applied to the system (recommended). */
670  REAR_WHEELS = 1,
671  /** Front wheel speed data to be applied to the system. */
672  FRONT_WHEELS = 2,
673  /** Front and rear wheel speed data to be applied to the system. */
675  /** Individual vehicle speed to be applied to the system. */
676  VEHICLE_BODY = 4,
677 };
678 
679 /**
680  * @brief Get a human-friendly string name for the specified @ref
681  * AppliedSpeedType.
682  * @ingroup config_and_ctrl_messages
683  *
684  * @param applied_speed_type The desired applied speed type.
685  *
686  * @return The corresponding string name.
687  */
688 inline const char* to_string(AppliedSpeedType applied_speed_type) {
689  switch (applied_speed_type) {
690  case AppliedSpeedType::NONE: {
691  return "None";
692  }
694  return "Rear Wheels";
695  }
697  return "Front Wheels";
698  }
700  return "Front and Rear Wheels";
701  }
703  return "Vehicle Body";
704  }
705  default: {
706  return "Unrecognized";
707  }
708  }
709 }
710 
711 /**
712  * @brief @ref AppliedSpeedType stream operator.
713  * @ingroup config_and_ctrl_messages
714  */
715 inline std::ostream& operator<<(std::ostream& stream,
716  AppliedSpeedType applied_speed_type) {
717  stream << to_string(applied_speed_type) << " (" << (int)applied_speed_type
718  << ")";
719  return stream;
720 }
721 
722 /**
723  * @brief Indication of which of the vehicle's wheels are steered.
724  * @ingroup config_and_ctrl_messages
725  */
726 enum class SteeringType : uint8_t {
727  /** Steered wheels unknown. */
728  UNKNOWN = 0,
729  /** Front wheels are steered. */
730  FRONT = 1,
731  /** Front and rear wheels are steered. */
732  FRONT_AND_REAR = 2,
733 };
734 
735 /**
736  * @brief Get a human-friendly string name for the specified @ref SteeringType.
737  * @ingroup config_and_ctrl_messages
738  *
739  * @param steering_type The desired steering type.
740  *
741  * @return The corresponding string name.
742  */
743 inline const char* to_string(SteeringType steering_type) {
744  switch (steering_type) {
745  case SteeringType::UNKNOWN: {
746  return "Unknown Steering";
747  }
748  case SteeringType::FRONT: {
749  return "Front Steering";
750  }
752  return "Front and Rear Steering";
753  }
754  default: {
755  return "Unrecognized";
756  }
757  }
758 }
759 
760 /**
761  * @brief @ref SteeringType stream operator.
762  * @ingroup config_and_ctrl_messages
763  */
764 inline std::ostream& operator<<(std::ostream& stream,
765  SteeringType steering_type) {
766  stream << to_string(steering_type) << " (" << (int)steering_type << ")";
767  return stream;
768 }
769 
770 /**
771  * @brief Vehicle/wheel speed measurement configuration settings.
772  * @ingroup config_and_ctrl_messages
773  *
774  * See:
775  * - @ref WheelSpeedMeasurement
776  * - @ref VehicleSpeedMeasurement
777  * - @ref WheelTickMeasurement
778  * - @ref VehicleTickMeasurement
779  */
780 struct alignas(4) WheelConfig {
781  /**
782  * The type of vehicle/wheel speed measurements produced by the vehicle.
783  */
785 
786  /**
787  * The type of vehicle/wheel speed measurements to be applied to the
788  * navigation solution.
789  */
791 
792  /** Indication of which of the vehicle's wheels are steered. */
794 
795  uint8_t reserved1[1] = {0};
796 
797  /**
798  * The nominal rate at which wheel speed measurements will be provided (in
799  * seconds).
800  */
802 
803  /**
804  * The nominal rate at which wheel tick measurements will be provided (in
805  * seconds).
806  */
808 
809  /**
810  * Ratio between angle of the steering wheel and the angle of the wheels on
811  * the ground.
812  */
813  float steering_ratio = NAN;
814 
815  /**
816  * The scale factor to convert from wheel encoder ticks to distance (in
817  * meters/tick). Used for @ref WheelSensorType::TICKS and
818  * @ref WheelSensorType::TICK_RATE.
819  */
820  float wheel_ticks_to_m = NAN;
821 
822  /**
823  * The maximum value (inclusive) before the wheel tick measurement will roll
824  * over.
825  *
826  * The rollover behavior depends on the value of @ref wheel_ticks_signed. For
827  * example, a maximum value of 10 will work as follows:
828  * - `wheel_ticks_signed == true`: [-11, 10]
829  * - `wheel_ticks_signed == false`: [0, 10]
830  *
831  * Signed values are assumed to be asymmetric, consistent with a typical 2's
832  * complement rollover.
833  */
834  uint32_t wheel_tick_max_value = 0;
835 
836  /**
837  * `true` if the reported wheel tick measurements should be interpreted as
838  * signed integers, or `false` if they should be interpreted as unsigned
839  * integers.
840  *
841  * See @ref wheel_tick_max_value for details.
842  */
843  bool wheel_ticks_signed = false;
844 
845  /**
846  * `true` if the wheel tick measurements increase by a positive amount when
847  * driving forward or backward. `false` if wheel tick measurements decrease
848  * when driving backward.
849  */
851 
852  uint8_t reserved2[2] = {0};
853 };
854 
855 /**
856  * @brief The signal edge to use when capturing a wheel tick voltage signal.
857  * @ingroup config_and_ctrl_messages
858  */
859 enum class TickMode : uint8_t {
860  /** Wheel tick capture disabled. */
861  OFF = 0,
862  /** Capture a wheel tick on the rising edge of the incoming pulse. */
863  RISING_EDGE = 1,
864  /** Capture a wheel tick on the falling edge of the incoming pulse. */
865  FALLING_EDGE = 2,
866 };
867 
868 inline const char* to_string(TickMode tick_mode) {
869  switch (tick_mode) {
870  case TickMode::OFF:
871  return "OFF";
873  return "RISING_EDGE";
875  return "FALLING_EDGE";
876  default:
877  return "UNRECOGNIZED";
878  }
879 }
880 
881 /**
882  * @brief @ref TickMode stream operator.
883  * @ingroup config_and_ctrl_messages
884  */
885 inline std::ostream& operator<<(std::ostream& stream, TickMode tick_mode) {
886  stream << to_string(tick_mode) << " (" << (int)tick_mode << ")";
887  return stream;
888 }
889 
890 /**
891  * @brief The way to interpret an incoming voltage signal, used to indicate
892  * direction of a hardware wheel tick pulse, if available.
893  * @ingroup config_and_ctrl_messages
894  */
895 enum class TickDirection : uint8_t {
896  /** Wheel tick direction not provided. */
897  OFF = 0,
898  /**
899  * Assume vehicle is moving forward when direction signal voltage is high, and
900  * backward when direction signal is low.
901  */
903  /**
904  * Assume vehicle is moving forward when direction signal voltage is low, and
905  * backward when direction signal is high.
906  */
907  FORWARD_ACTIVE_LOW = 2,
908 };
909 
910 inline const char* to_string(TickDirection tick_direction) {
911  switch (tick_direction) {
912  case TickDirection::OFF:
913  return "OFF";
915  return "FORWARD_ACTIVE_HIGH";
917  return "FORWARD_ACTIVE_LOW";
918  default:
919  return "UNRECOGNIZED";
920  }
921 }
922 
923 /**
924  * @brief @ref TickDirection stream operator.
925  * @ingroup config_and_ctrl_messages
926  */
927 inline std::ostream& operator<<(std::ostream& stream,
928  TickDirection tick_direction) {
929  stream << to_string(tick_direction) << " (" << (int)tick_direction << ")";
930  return stream;
931 }
932 
933 /**
934  * @brief Hardware wheel encoder configuration settings.
935  * @ingroup config_and_ctrl_messages
936  *
937  * See @ref VehicleTickMeasurement.
938  */
939 struct alignas(4) HardwareTickConfig {
940  /**
941  * If enabled -- tick mode is not @ref TickMode::OFF -- the device will
942  * accumulate ticks received on the I/O pin, and use them as an indication of
943  * vehicle speed. If enabled, you must also specify @ref wheel_ticks_to_m to
944  * indicate the mapping of wheel tick encoder angle to tire circumference. All
945  * other wheel tick-related parameters such as tick capture rate, rollover
946  * value, etc. will be set internally.
947  *
948  * @warning
949  * Do not enable this feature if a wheel tick voltage signal is not present.
950  */
952 
953  /**
954  * When direction is @ref TickDirection::OFF, the incoming ticks will be
955  * treated as unsigned, meaning the tick count will continue to increase in
956  * either direction of travel. If direction is not @ref TickDirection::OFF,
957  * a second direction I/O pin will be used to indicate the direction of
958  * travel and the accumulated tick count will increase/decrease accordingly.
959  */
961 
962  uint8_t reserved1[2] = {0};
963 
964  /**
965  * The scale factor to convert from wheel encoder ticks to distance (in
966  * meters/tick). Used for @ref WheelSensorType::TICKS and
967  * @ref WheelSensorType::TICK_RATE.
968  */
969  float wheel_ticks_to_m = NAN;
970 };
971 
972 /** @} */
973 
974 /**************************************************************************/ /**
975  * @name Input/Output Stream Control
976  * @{
977  ******************************************************************************/
978 
979 /**
980  * @brief The framing protocol of a message.
981  */
982 enum class ProtocolType : uint8_t {
983  INVALID = 0,
984  FUSION_ENGINE = 1,
985  NMEA = 2,
986  RTCM = 3,
987  /** This is used for requesting the configuration for all protocols. */
988  ALL = 0xFF,
989 };
990 
991 /** Setting message_id to this value acts as a wild card. */
992 constexpr uint16_t ALL_MESSAGES_ID = 0xFFFF;
993 
994 /**
995  * @brief Get a human-friendly string name for the specified @ref
996  * ProtocolType.
997  * @ingroup config_and_ctrl_messages
998  *
999  * @param val The enum to get the string name for.
1000  *
1001  * @return The corresponding string name.
1002  */
1003 inline const char* to_string(ProtocolType val) {
1004  switch (val) {
1005  case ProtocolType::INVALID:
1006  return "Invalid";
1008  return "FusionEngine";
1009  case ProtocolType::NMEA:
1010  return "NMEA";
1011  case ProtocolType::RTCM:
1012  return "RTCM";
1013  case ProtocolType::ALL:
1014  return "ALL";
1015  default:
1016  return "Unrecognized";
1017  }
1018 }
1019 
1020 /**
1021  * @brief @ref ProtocolType stream operator.
1022  * @ingroup config_and_ctrl_messages
1023  */
1024 inline std::ostream& operator<<(std::ostream& stream, ProtocolType val) {
1025  stream << to_string(val) << " (" << (int)val << ")";
1026  return stream;
1027 }
1028 
1029 /**
1030  * @brief Type of I/O interface transport.
1031  */
1032 enum class TransportType : uint8_t {
1033  INVALID = 0,
1034  SERIAL = 1,
1035  FILE = 2,
1036  TCP_CLIENT = 3,
1037  TCP_SERVER = 4,
1038  UDP_CLIENT = 5,
1039  UDP_SERVER = 6,
1040  /**
1041  * Set/get the configuration for the interface on which the command was
1042  * received.
1043  */
1044  CURRENT = 254,
1045  /** Set/get the configuration for the all I/O interfaces. */
1046  ALL = 255,
1047 };
1048 
1049 /**
1050  * @brief Get a human-friendly string name for the specified @ref
1051  * TransportType.
1052  * @ingroup config_and_ctrl_messages
1053  *
1054  * @param val The enum to get the string name for.
1055  *
1056  * @return The corresponding string name.
1057  */
1058 inline const char* to_string(TransportType val) {
1059  switch (val) {
1061  return "Invalid";
1062  case TransportType::SERIAL:
1063  return "Serial";
1064  case TransportType::FILE:
1065  return "File";
1067  return "TCP Client";
1069  return "TCP Server";
1071  return "UDP Client";
1073  return "UDP Server";
1075  return "Current";
1076  case TransportType::ALL:
1077  return "All";
1078  default:
1079  return "Unrecognized";
1080  }
1081 }
1082 
1083 /**
1084  * @brief @ref TransportType stream operator.
1085  * @ingroup config_and_ctrl_messages
1086  */
1087 inline std::ostream& operator<<(std::ostream& stream, TransportType val) {
1088  stream << to_string(val) << " (" << (int)val << ")";
1089  return stream;
1090 }
1091 
1092 /**
1093  * @brief Identifies an I/O interface.
1094  *
1095  * For example, serial port 1 or TCP server 2.
1096  *
1097  * @note
1098  * On most devices, serial ports (UARTs) use 1-based numbering: the first serial
1099  * port is typically index 1 (UART1).
1100  */
1101 struct alignas(4) InterfaceID {
1102  /** The interface's transport type. **/
1104  /** An identifier for the instance of this transport. */
1105  uint8_t index = 0;
1106  uint8_t reserved[2] = {0};
1107 
1108  InterfaceID() = default;
1109 
1110  explicit InterfaceID(TransportType type, uint8_t index = 0)
1111  : type(type), index(index) {}
1112 
1113  bool operator==(const InterfaceID& other) const {
1114  return type == other.type && index == other.index;
1115  }
1116 
1117  bool inline operator!=(const InterfaceID& other) const {
1118  return !(*this == other);
1119  }
1120 };
1121 
1122 /**
1123  * @brief @ref InterfaceID stream operator.
1124  * @ingroup config_and_ctrl_messages
1125  */
1126 inline std::ostream& operator<<(std::ostream& stream, InterfaceID val) {
1127  stream << "[type=" << val.type << ", index=" << (int)val.index << "]";
1128  return stream;
1129 }
1130 
1131 /**
1132  * @brief Integer ID for NMEA messages.
1133  */
1134 enum class NmeaMessageType : uint16_t {
1135  INVALID = 0,
1136 
1137  /**
1138  * @name Standard NMEA Messages
1139  * @{
1140  */
1141  GGA = 1,
1142  GLL = 2,
1143  GSA = 3,
1144  GSV = 4,
1145  RMC = 5,
1146  VTG = 6,
1147  /** @} */
1148 
1149  /**
1150  * @name Point One Proprietary Messages
1151  * @{
1152  */
1153  P1CALSTATUS = 1000,
1154  P1MSG = 1001,
1155  /** @} */
1156 
1157  /**
1158  * @name Quectel Proprietary Messages
1159  * @{
1160  */
1161  PQTMVERNO = 1200,
1162  PQTMVER = 1201,
1163  PQTMGNSS = 1202,
1164  PQTMVERNO_SUB = 1203,
1165  PQTMVER_SUB = 1204,
1166  PQTMTXT = 1205,
1167  /** @} */
1168 };
1169 
1170 /**
1171  * @brief Get a human-friendly string name for the specified @ref
1172  * NmeaMessageType.
1173  * @ingroup config_and_ctrl_messages
1174  *
1175  * @param value The enum to get the string name for.
1176  *
1177  * @return The corresponding string name.
1178  */
1179 inline const char* to_string(NmeaMessageType value) {
1180  switch (value) {
1182  return "INVALID";
1183  case NmeaMessageType::GGA:
1184  return "GGA";
1185  case NmeaMessageType::GLL:
1186  return "GLL";
1187  case NmeaMessageType::GSA:
1188  return "GSA";
1189  case NmeaMessageType::GSV:
1190  return "GSV";
1191  case NmeaMessageType::RMC:
1192  return "RMC";
1193  case NmeaMessageType::VTG:
1194  return "VTG";
1196  return "P1CALSTATUS";
1198  return "P1MSG";
1200  return "PQTMVERNO";
1202  return "PQTMVER";
1204  return "PQTMGNSS";
1206  return "PQTMVERNO_SUB";
1208  return "PQTMVER_SUB";
1210  return "PQTMTXT";
1211  default:
1212  return "Unrecognized";
1213  }
1214 }
1215 
1216 /**
1217  * @brief @ref NmeaMessageType stream operator.
1218  * @ingroup config_and_ctrl_messages
1219  */
1220 inline std::ostream& operator<<(std::ostream& stream, NmeaMessageType val) {
1221  stream << to_string(val) << " (" << (int)val << ")";
1222  return stream;
1223 }
1224 
1225 /**
1226  * @brief The output rate for a message type on an interface.
1227  */
1228 enum class MessageRate : uint8_t {
1229  /**
1230  * Disable output of this message.
1231  */
1232  OFF = 0,
1233  /**
1234  * Output this message each time a new value is available.
1235  */
1236  ON_CHANGE = 1,
1237  /** Alias for @ref MessageRate::ON_CHANGE. */
1238  MAX_RATE = 1,
1239  /**
1240  * Output this message every 10 milliseconds. Not supported for all messages
1241  * or platforms.
1242  */
1243  INTERVAL_10_MS = 2,
1244  /**
1245  * Output this message every 20 milliseconds. Not supported for all messages
1246  * or platforms.
1247  */
1248  INTERVAL_20_MS = 3,
1249  /**
1250  * Output this message every 40 milliseconds. Not supported for all messages
1251  * or platforms.
1252  */
1253  INTERVAL_40_MS = 4,
1254  /**
1255  * Output this message every 50 milliseconds. Not supported for all messages
1256  * or platforms.
1257  */
1258  INTERVAL_50_MS = 5,
1259  /**
1260  * Output this message every 100 milliseconds. Not supported for all messages
1261  * or platforms.
1262  */
1263  INTERVAL_100_MS = 6,
1264  /**
1265  * Output this message every 200 milliseconds. Not supported for all messages
1266  * or platforms.
1267  */
1268  INTERVAL_200_MS = 7,
1269  /**
1270  * Output this message every 500 milliseconds. Not supported for all messages
1271  * or platforms.
1272  */
1273  INTERVAL_500_MS = 8,
1274  /**
1275  * Output this message every second. Not supported for all messages or
1276  * platforms.
1277  */
1278  INTERVAL_1_S = 9,
1279  /**
1280  * Output this message every 2 seconds. Not supported for all messages or
1281  * platforms.
1282  */
1283  INTERVAL_2_S = 10,
1284  /**
1285  * Output this message every 5 seconds. Not supported for all messages or
1286  * platforms.
1287  */
1288  INTERVAL_5_S = 11,
1289  /**
1290  * Output this message every 10 seconds. Not supported for all messages or
1291  * platforms.
1292  */
1293  INTERVAL_10_S = 12,
1294  /**
1295  * Output this message every 30 seconds. Not supported for all messages or
1296  * platforms.
1297  */
1298  INTERVAL_30_S = 13,
1299  /**
1300  * Output this message every 60 seconds. Not supported for all messages or
1301  * platforms.
1302  */
1303  INTERVAL_60_S = 14,
1304  /**
1305  * Restore this message's rate back to its default value.
1306  */
1307  DEFAULT = 255
1308 };
1309 
1310 /**
1311  * @brief Get a human-friendly string name for the specified @ref
1312  * MessageRate.
1313  * @ingroup config_and_ctrl_messages
1314  *
1315  * @param value The enum to get the string name for.
1316  *
1317  * @return The corresponding string name.
1318  */
1319 inline const char* to_string(MessageRate value) {
1320  switch (value) {
1321  case MessageRate::OFF:
1322  return "OFF";
1324  return "ON_CHANGE";
1326  return "INTERVAL_10_MS";
1328  return "INTERVAL_20_MS";
1330  return "INTERVAL_40_MS";
1332  return "INTERVAL_50_MS";
1334  return "INTERVAL_100_MS";
1336  return "INTERVAL_200_MS";
1338  return "INTERVAL_500_MS";
1340  return "INTERVAL_1_S";
1342  return "INTERVAL_2_S";
1344  return "INTERVAL_5_S";
1346  return "INTERVAL_10_S";
1348  return "INTERVAL_30_S";
1350  return "INTERVAL_60_S";
1351  case MessageRate::DEFAULT:
1352  return "DEFAULT";
1353  default:
1354  return "Unrecognized";
1355  }
1356 }
1357 
1358 /**
1359  * @brief @ref MessageRate stream operator.
1360  * @ingroup config_and_ctrl_messages
1361  */
1362 inline std::ostream& operator<<(std::ostream& stream, MessageRate val) {
1363  stream << to_string(val) << " (" << (int)val << ")";
1364  return stream;
1365 }
1366 
1367 /**
1368  * @brief Set the output rate for the requested message types (@ref
1369  * MessageType::SET_MESSAGE_RATE, version 1.0).
1370  *
1371  * Multiple message rates can be configured with a single command if wild cards
1372  * are used for the interface, protocol, or message ID. When multiple messages
1373  * are specified, the following behaviors apply:
1374  * - Messages that are currently @ref MessageRate::OFF will not be changed
1375  * unless the @ref FLAG_INCLUDE_DISABLED_MESSAGES bit is set in the @ref flags
1376  * or the new rate is @ref MessageRate::DEFAULT.
1377  * - If the rate is an interval, it will only affect the messages that support
1378  * being rate controlled.
1379  *
1380  * Setting all the messages on an interface to @ref MessageRate::DEFAULT will
1381  * also restore the default `*_OUTPUT_DIAGNOSTICS_MESSAGES` configuration option
1382  * value for that interface. See @ref ConfigType.
1383  *
1384  * @section set_rate_examples Typical Use Cases
1385  *
1386  * @subsection set_rate_restore Restore Default Settings For All Messages
1387  *
1388  * To restore the default configuration on UART1 for all message types across all
1389  * supported protocols, specify the following:
1390  * - Interface transport type: @ref TransportType::SERIAL
1391  * - Interface index: 1
1392  * - Protocol: @ref ProtocolType::ALL
1393  * - Message ID: @ref ALL_MESSAGES_ID
1394  * - Rate: @ref MessageRate::DEFAULT
1395  *
1396  * @subsection set_rate_restore_nmea Restore Default Settings For All NMEA
1397  *
1398  * To restore the default configuration on UART1 for all NMEA message types,
1399  * specify the following:
1400  * - Interface transport type: @ref TransportType::SERIAL
1401  * - Interface index: 1
1402  * - Protocol: @ref ProtocolType::NMEA
1403  * - Message ID: @ref ALL_MESSAGES_ID
1404  * - Rate: @ref MessageRate::DEFAULT
1405  *
1406  * @subsection set_rate_change_enabled_rate Change UART1 Output Rate To 1 Hz:
1407  *
1408  * To change the rate of all rate-controlled messages (e.g., FusionEngine @ref
1409  * PoseMessage, NMEA GGA) to 1 Hz on UART1, specify the following:
1410  * - Interface transport type: @ref TransportType::SERIAL
1411  * - Interface index: 1
1412  * - Protocol: @ref ProtocolType::ALL
1413  * - Message ID: @ref ALL_MESSAGES_ID
1414  * - Rate: @ref MessageRate::INTERVAL_1_S
1415  *
1416  * @note
1417  * Note that this will not affect any message types that are not rate controlled
1418  * (e.g., @ref MessageType::EVENT_NOTIFICATION).
1419  *
1420  * @subsection set_rate_max_all Change The Uart1 Output Rates For All Messages To Their Max:
1421  *
1422  * To change the rate of all messages to their max rate on UART1, specify the
1423  * following:
1424  * - Interface transport type: @ref TransportType::SERIAL
1425  * - Interface index: 1
1426  * - Protocol: @ref ProtocolType::ALL
1427  * - flags: @ref FLAG_INCLUDE_DISABLED_MESSAGES
1428  * - Message ID: @ref ALL_MESSAGES_ID
1429  * - Rate: @ref MessageRate::ON_CHANGE
1430  *
1431  * @note
1432  * This will enabled every message regardless of whether it's @ref
1433  * MessageRate::OFF or whether or not it's rate controlled.
1434  *
1435  * @subsection set_and_save_rate_max_all Change And Save The UART1 Output Rates For All Messages To Their Max:
1436  *
1437  * To change the rate of all messages to their max rate on UART1, specify the
1438  * following:
1439  * - Interface transport type: @ref TransportType::SERIAL
1440  * - Interface index: 1
1441  * - Protocol: @ref ProtocolType::ALL
1442  * - flags: 0x03 (@ref FLAG_INCLUDE_DISABLED_MESSAGES | @ref FLAG_APPLY_AND_SAVE)
1443  * - Message ID: @ref ALL_MESSAGES_ID
1444  * - Rate: @ref MessageRate::ON_CHANGE
1445  *
1446  * @note
1447  * Both of the bit flags are set for this message. This will cause the
1448  * configuration to be saved to non-volatile memory.
1449  *
1450  * @ingroup config_and_ctrl_messages
1451  *
1452  * # Expected Response
1453  * The device will respond with a @ref CommandResponseMessage indicating whether
1454  * or not the request succeeded.
1455  */
1456 struct alignas(4) SetMessageRate : public MessagePayload {
1458  static constexpr uint8_t MESSAGE_VERSION = 0;
1459 
1460  /** Flag to immediately save the config after applying this setting. */
1461  static constexpr uint8_t FLAG_APPLY_AND_SAVE = 0x01;
1462 
1463  /**
1464  * Flag to apply bulk interval changes to all messages instead of just
1465  * enabled messages.
1466  */
1467  static constexpr uint8_t FLAG_INCLUDE_DISABLED_MESSAGES = 0x02;
1468 
1469  /**
1470  * The output interface to configure. If @ref TransportType::ALL, set rates on
1471  * all supported interfaces.
1472  */
1474 
1475  /**
1476  * The message protocol being configured. If @ref ProtocolType::ALL, set rates
1477  * on all supported protocols and @ref message_id is ignored.
1478  */
1480 
1481  /** Bitmask of additional flags to modify the command. */
1482  uint8_t flags = 0;
1483 
1484  /**
1485  * The ID of the desired message type (e.g., 10000 for FusionEngine
1486  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
1487  * messages. If @ref ALL_MESSAGES_ID, set the rate for all messages on the
1488  * selected interface and protocol.
1489  */
1491 
1492  /** The desired message rate. */
1494 
1495  uint8_t reserved2[3] = {0};
1496 };
1497 
1498 /**
1499  * @brief Get the configured output rate for the he requested message type on
1500  * the specified interface (@ref MessageType::GET_MESSAGE_RATE,
1501  * version 1.0).
1502  * @ingroup config_and_ctrl_messages
1503  *
1504  * Multiple message rates can be requested with a single command if wild cards
1505  * are used for the protocol, or message ID.
1506  *
1507  * # Expected Response
1508  * The device will respond with a @ref MessageRateResponse containing the
1509  * requested values, or a @ref CommandResponseMessage on failure.
1510  */
1511 struct alignas(4) GetMessageRate : public MessagePayload {
1513  static constexpr uint8_t MESSAGE_VERSION = 0;
1514 
1515  /**
1516  * The output interface to be queried.
1517  *
1518  * @ref TransportType::ALL is not supported. To query for multiple transports,
1519  * send separate requests.
1520  */
1522 
1523  /**
1524  * The desired message protocol. If @ref ProtocolType::ALL, return the current
1525  * settings for all supported protocols and @ref message_id is ignored.
1526  */
1528 
1529  /** The source of the parameter value (active, saved, etc.). */
1531 
1532  /**
1533  * The ID of the desired message type (e.g., 10000 for FusionEngine
1534  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
1535  * messages. If @ref ALL_MESSAGES_ID, return the current settings for all
1536  * supported messages on the selected interface and protocol.
1537  */
1539 };
1540 
1541 /**
1542  * @brief An element of a @ref MessageRateResponse message.
1543  * @ingroup config_and_ctrl_messages
1544  */
1545 struct alignas(4) MessageRateResponseEntry {
1546  /**
1547  * Flag to indicate the active value for this configuration differs from the
1548  * value saved to persistent memory.
1549  */
1550  static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED = 0x1;
1551 
1552  /** The protocol of the message being returned. */
1554 
1555  /** Flags that describe the entry. */
1556  uint8_t flags = 0;
1557 
1558  /**
1559  * The ID of the returned message type (e.g., 10000 for FusionEngine
1560  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
1561  * messages.
1562  */
1563  uint16_t message_id = 0;
1564 
1565  /** The current configuration for this message. */
1567 
1568  /**
1569  * The currently active output rate for this message, factoring in effects of
1570  * additional configuration settings that may override the configured rate
1571  * such as enabling diagnostic output.
1572  */
1574 
1575  uint8_t reserved1[2] = {0};
1576 };
1577 
1578 /**
1579  * @brief Response to a @ref GetMessageRate request (@ref
1580  * MessageType::MESSAGE_RATE_RESPONSE, version 1.1).
1581  * @ingroup config_and_ctrl_messages
1582  */
1583 struct alignas(4) MessageRateResponse : public MessagePayload {
1584  static constexpr MessageType MESSAGE_TYPE =
1586  static constexpr uint8_t MESSAGE_VERSION = 1;
1587 
1588  /** The source of the parameter value (active, saved, etc.). */
1590 
1591  /** The response status (success, error, etc.). */
1593 
1594  /** The number of rates reported by this message. */
1595  uint16_t num_rates = 0;
1596 
1597  /** The output interface corresponding with this response. */
1599 
1600  /* This in then followed by an array of num_rates MessageRateResponseEntry */
1601  // MessageRateResponseEntry rates[num_rates]
1602 };
1603 
1604 /** Type of data stored on device. */
1605 enum class DataType : uint8_t {
1606  CALIBRATION_STATE = 0,
1607  CRASH_LOG = 1,
1608  FILTER_STATE = 2,
1609  USER_CONFIG = 3,
1610  INVALID = 255
1611 };
1612 
1613 /**
1614  * @brief Get a string representation of a @ref DataType.
1615  *
1616  * @param type The requested type.
1617  *
1618  * @return The corresponding string name.
1619  */
1620 inline const char* to_string(DataType type) {
1621  switch (type) {
1623  return "CalibrationState";
1624  case DataType::CRASH_LOG:
1625  return "CrashLog";
1627  return "FilterState";
1628  case DataType::USER_CONFIG:
1629  return "UserConfig";
1630  default:
1631  return "Invalid";
1632  }
1633 }
1634 
1635 /**
1636  * @brief @ref DataType stream operator.
1637  * @ingroup config_and_ctrl_messages
1638  */
1639 inline std::ostream& operator<<(std::ostream& stream, DataType val) {
1640  stream << to_string(val) << " (" << (int)val << ")";
1641  return stream;
1642 }
1643 
1644 /**
1645  * @brief Import data from the host to the device (@ref
1646  * MessageType::IMPORT_DATA, version 1.0).
1647  * @ingroup config_and_ctrl_messages
1648  *
1649  * # Expected Response
1650  * The device will respond with a @ref CommandResponseMessage indicating whether
1651  * or not the request succeeded.
1652  */
1653 struct alignas(4) ImportDataMessage {
1655  static constexpr uint8_t MESSAGE_VERSION = 0;
1656  /**
1657  * The type of data being imported.
1658  */
1660  /**
1661  * The location of the data to update (active, saved, etc.). For data that
1662  * doesn't have separate active and saved copies, this parameter is ignored.
1663  */
1665  uint8_t reserved1[2] = {0};
1666  /** @brief Version of data contents. */
1668  uint8_t reserved2[4] = {0};
1669  /** @brief Number of bytes to update. */
1670  uint32_t data_length_bytes = 0;
1671 
1672  /**
1673  * This in then followed by an array of data_length_bytes bytes for the data
1674  * contents.
1675  */
1676  // uint8_t data[data_length_bytes]
1677 };
1678 
1679 /**
1680  * @brief Export data from the device (@ref
1681  * MessageType::EXPORT_DATA, version 1.0).
1682  * @ingroup config_and_ctrl_messages
1683  *
1684  * # Expected Response
1685  * The device will respond with a @ref PlatformStorageDataMessage.
1686  */
1687 struct alignas(4) ExportDataMessage {
1689  static constexpr uint8_t MESSAGE_VERSION = 0;
1690  /**
1691  * The type of data to be exported.
1692  */
1694  /**
1695  * The source to copy this data from. If the data_type doesn't separate active
1696  * and saved data, this will be ignored.
1697  */
1699  uint8_t reserved[2] = {0};
1700 };
1701 
1702 /**
1703  * @brief Message for reporting platform storage data (@ref
1704  * MessageType::PLATFORM_STORAGE_DATA, version 1.0).
1705  * @ingroup config_and_ctrl_messages
1706  *
1707  * See also @ref ExportDataMessage.
1708  *
1709  * Changes:
1710  * - Version 1: Added data_validity field.
1711  * - Version 2: Changed data_validity to a @ref Response enum and added
1712  * @ref source field.
1713  */
1714 struct alignas(4) PlatformStorageDataMessage {
1715  static constexpr MessageType MESSAGE_TYPE =
1717  static constexpr uint8_t MESSAGE_VERSION = 2;
1718 
1719  /**
1720  * They type of data contained in this message.
1721  */
1723  /**
1724  * The status of the specified data type on the device.
1725  */
1727  /**
1728  * The source this data was copied from. If the @ref data_type doesn't separate
1729  * active and saved data, this will be set to @ref
1730  * ConfigurationSource::ACTIVE.
1731  */
1733  uint8_t reserved[1] = {0};
1734  /** Version of data contents. */
1736  /** Number of bytes in data contents. */
1737  uint32_t data_length_bytes = 0;
1738 
1739  /**
1740  * This in then followed by an array of data_length_bytes bytes for the data
1741  * contents.
1742  */
1743  // uint8_t data[data_length_bytes]
1744 };
1745 
1746 /** @} */
1747 
1748 #pragma pack(pop)
1749 
1750 } // namespace messages
1751 } // namespace fusion_engine
1752 } // namespace point_one
1753 
1754 #ifdef _MSC_VER
1755 # pragma warning(pop)
1756 #endif
@ INTERVAL_10_S
Output this message every 10 seconds.
@ IMPORT_DATA
ImportDataMessage
static constexpr uint8_t MESSAGE_VERSION
@ INTERVAL_10_MS
Output this message every 10 milliseconds.
uint16_t message_id
The ID of the desired message type (e.g., 10000 for FusionEngine MessageType::POSE messages).
ConfigType
An identifier for the contents of a parameter configuration message.
Definition: configuration.h:38
float wheel_ticks_to_m
The scale factor to convert from wheel encoder ticks to distance (in meters/tick).
@ VEHICLE_TICKS
A single wheel rotational angle, reported as accumulated encoder ticks.
@ BACKWARD
Aligned with vehicle -x axis.
static constexpr MessageType MESSAGE_TYPE
@ ALL
Set/get the configuration for the all I/O interfaces.
A 3-dimensional vector (used for lever arms, etc.).
bool wheel_ticks_signed
true if the reported wheel tick measurements should be interpreted as signed integers,...
@ INTERVAL_5_S
Output this message every 5 seconds.
@ RTCM
Identifies an I/O interface.
@ PQTMGNSS
TransportType type
The interface's transport type.
@ RMC
ProtocolType protocol
The message protocol being configured.
MessageType
Identifiers for the defined output message types.
Definition: defs.h:32
Response to a GetConfigMessage request (MessageType::CONFIG_RESPONSE, version 1.0).
InterfaceID output_interface
The output interface to be queried.
@ SAVE
Save all active parameters to persistent storage.
static constexpr uint8_t MESSAGE_VERSION
@ OK
Response response
The response status (success, error, etc.).
@ MAX_RATE
Alias for MessageRate::ON_CHANGE.
The orientation of a device with respect to the vehicle body axes.
@ LEXUS_CT200H
@ DEFAULT
Restore this message's rate back to its default value.
uint8_t flags
Flags that describe the entry.
@ INVALID
Hardware wheel encoder configuration settings.
@ NONE
Wheel/vehicle speed data not available.
@ TESLA_MODEL_X
@ DEVICE_LEVER_ARM
The location of the device IMU with respect to the vehicle body frame (in meters).
TickMode
The signal edge to use when capturing a wheel tick voltage signal.
@ DATASPEED_CD4
ConfigType config_type
The type of configuration parameter contained in this message.
@ FORWARD_ACTIVE_LOW
Assume vehicle is moving forward when direction signal voltage is low, and backward when direction si...
@ REVERT_TO_SAVED
Revert the active configuration to previously saved values.
@ BMW_7
@ DOWN
Aligned with vehicle -z axis.
Response response
The status of the specified data type on the device.
InterfaceID()=default
static constexpr MessageType MESSAGE_TYPE
@ FILE
@ UART1_BAUD
Configure the UART1 serial baud rate (in bits/second).
ConfigurationSource config_source
The source of the parameter value (active, saved, etc.).
@ VEHICLE_BODY
Individual vehicle speed to be applied to the system.
@ PQTMVERNO
@ UART1_OUTPUT_DIAGNOSTICS_MESSAGES
Force output the diagnostic message set on UART1.
static constexpr MessageType MESSAGE_TYPE
static constexpr uint8_t MESSAGE_VERSION
static constexpr MessageType MESSAGE_TYPE
@ PQTMVER_SUB
Response to a GetMessageRate request (MessageType::MESSAGE_RATE_RESPONSE, version 1....
@ TESLA_MODEL_3
@ KIA_SPORTAGE
SteeringType
Indication of which of the vehicle's wheels are steered.
@ PQTMVERNO_SUB
uint8_t flags
Bitmask of additional flags to modify the command.
@ HARDWARE_TICK_CONFIG
Indicates the mode and direction used when capturing vehicle wheel tick data from a voltage pulse on ...
@ UNKNOWN_VEHICLE
DataType data_type
The type of data to be exported.
@ INTERVAL_500_MS
Output this message every 500 milliseconds.
@ GLL
uint8_t config_change_data[0]
A pointer to the beginning of the configuration parameter value.
float wheel_update_interval_sec
The nominal rate at which wheel speed measurements will be provided (in seconds).
@ AUDI_Q7
DataType data_type
The type of data being imported.
SaveAction
The type configuration save operation to be performed.
Information about the vehicle including model and dimensions.
MessageRate rate
The desired message rate.
@ INTERVAL_60_S
Output this message every 60 seconds.
ConfigurationSource request_source
The source of the parameter value (active, saved, etc.).
ConfigurationSource source
The location of the data to update (active, saved, etc.).
Set the output rate for the requested message types (MessageType::SET_MESSAGE_RATE,...
@ REVERT_TO_DEFAULT
Reset the active and saved configuration to default values.
uint32_t wheel_tick_max_value
The maximum value (inclusive) before the wheel tick measurement will roll over.
Import data from the host to the device (MessageType::IMPORT_DATA, version 1.0).
@ MESSAGE_RATE_RESPONSE
MessageRateResponse
@ SAVE_CONFIG
SaveConfigMessage
MessageRate configured_rate
The current configuration for this message.
MessageRate
The output rate for a message type on an interface.
static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED
Flag to indicate the active value for this configuration differs from the value saved to persistent m...
uint8_t config_change_data[0]
A pointer to the beginning of the configuration parameter value.
MessageRate effective_rate
The currently active output rate for this message, factoring in effects of additional configuration s...
TickDirection tick_direction
When direction is TickDirection::OFF, the incoming ticks will be treated as unsigned,...
DataType
Type of data stored on device.
float z
@ ACTIVE
Active configuration currently in use by the device.
@ FRONT
Front wheels are steered.
uint32_t config_length_bytes
The size of the parameter value, config_change_data (in bytes).
@ PEUGEOT_206
WheelSensorType wheel_sensor_type
The type of vehicle/wheel speed measurements produced by the vehicle.
SaveAction action
The action to performed.
@ TICK_RATE
Individual wheel rotation rates, reported as an encoder tick rate (in ticks/second).
TransportType
Type of I/O interface transport.
The base class for all message payloads.
Definition: defs.h:531
@ FILTER_STATE
static constexpr MessageType MESSAGE_TYPE
@ INTERVAL_1_S
Output this message every second.
Query the value of a user configuration parameter (MessageType::GET_CONFIG, version 1....
@ ON_CHANGE
Output this message each time a new value is available.
float y
@ INTERVAL_50_MS
Output this message every 50 milliseconds.
@ PQTMVER
@ INVALID
@ INTERVAL_2_S
Output this message every 2 seconds.
@ INTERVAL_100_MS
Output this message every 100 milliseconds.
@ PQTMTXT
@ SERIAL
static constexpr uint8_t FLAG_APPLY_AND_SAVE
Flag to immediately save the config after applying this setting.
bool operator==(const InterfaceID &other) const
@ INVALID
@ INTERVAL_30_S
Output this message every 30 seconds.
@ OFF
Wheel tick capture disabled.
@ TCP_SERVER
ConfigType config_type
The desired parameter.
ProtocolType protocol
The desired message protocol.
Definition: logging.h:36
Get the configured output rate for the he requested message type on the specified interface (MessageT...
Export data from the device (MessageType::EXPORT_DATA, version 1.0).
InterfaceID output_interface
The output interface to configure.
@ CALIBRATION_STATE
@ FRONT_WHEELS
Front wheel speed data to be applied to the system.
DataVersion data_version
Version of data contents.
DataType data_type
They type of data contained in this message.
@ INVALID
uint8_t index
An identifier for the instance of this transport.
@ UP
Aligned with vehicle +z axis.
static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED
Flag to indicate the active value for this configuration differs from the value saved to persistent m...
@ FRONT_AND_REAR_WHEELS
Front and rear wheel speed data to be applied to the system.
bool operator!=(const InterfaceID &other) const
VehicleModel vehicle_model
@ P1MSG
TickMode tick_mode
If enabled – tick mode is not TickMode::OFF – the device will accumulate ticks received on the I/O pi...
@ INVALID
@ CURRENT
Set/get the configuration for the interface on which the command was received.
float rear_track_width_m
The distance between the two rear wheels (in meters).
@ UART2_BAUD
Configure the UART2 serial baud rate (in bits/second).
@ GSV
AppliedSpeedType applied_speed_type
The type of vehicle/wheel speed measurements to be applied to the navigation solution.
@ TICKS
Individual wheel rotational angles, reported as accumulated encoder ticks.
@ AUDI_A8L
static constexpr uint8_t FLAG_INCLUDE_DISABLED_MESSAGES
Flag to apply bulk interval changes to all messages instead of just enabled messages.
Direction
ConfigurationSource config_source
The source of the parameter value (active, saved, etc.).
float steering_ratio
Ratio between angle of the steering wheel and the angle of the wheels on the ground.
@ INTERVAL_200_MS
Output this message every 200 milliseconds.
VehicleModel
The make and model of the vehicle.
@ GET_MESSAGE_RATE
GetMessageRate
@ DEVICE_COARSE_ORIENTATION
The orientation of the device IMU with respect to the vehicle body axes.
@ NMEA
@ INTERVAL_40_MS
Output this message every 40 milliseconds.
float wheelbase_m
The distance between the front axle and rear axle (in meters).
InterfaceID output_interface
The output interface corresponding with this response.
@ LEFT
Aligned with vehicle +y axis.
ConfigType config_type
The type of parameter to be configured.
Response
Command response status indicators.
Definition: defs.h:284
@ LINCOLN_MKZ
float wheel_tick_output_interval_sec
The nominal rate at which wheel tick measurements will be provided (in seconds).
TickDirection
The way to interpret an incoming voltage signal, used to indicate direction of a hardware wheel tick ...
static constexpr MessageType MESSAGE_TYPE
@ OFF
Disable output of this message.
uint32_t data_length_bytes
Number of bytes in data contents.
@ EXPORT_DATA
ExportDataMessage
@ VEHICLE_SPEED
A single value indicating the vehicle speed (in meters/second).
@ GSA
@ UDP_SERVER
@ P1CALSTATUS
@ MAN_TGX
static constexpr uint8_t MESSAGE_VERSION
Direction z_direction
The direction of the device +z axis relative to the vehicle body axes.
ConfigurationSource source
The source to copy this data from.
ConfigurationSource request_source
The config source to request data from (active, saved, etc.).
static constexpr MessageType MESSAGE_TYPE
An element of a MessageRateResponse message.
static constexpr uint8_t MESSAGE_VERSION
Response response
The response status (success, error, etc.).
NmeaMessageType
Integer ID for NMEA messages.
ConfigurationSource source
The source this data was copied from.
@ SET_MESSAGE_RATE
SetMessageRate
uint32_t data_length_bytes
Number of bytes to update.
Save or reload configuration settings (MessageType::SAVE_CONFIG, version 1.0).
@ HYUNDAI_ELANTRA
ProtocolType
The framing protocol of a message.
@ CRASH_LOG
Set a user configuration parameter (MessageType::SET_CONFIG, version 1.0).
@ ENABLE_WATCHDOG_TIMER
Enable watchdog timer to restart device after fatal errors.
static constexpr uint8_t MESSAGE_VERSION
Message for reporting platform storage data (MessageType::PLATFORM_STORAGE_DATA, version 1....
@ VTG
ProtocolType protocol
The protocol of the message being returned.
WheelSensorType
The type of vehicle/wheel speed measurements produced by the vehicle.
SteeringType steering_type
Indication of which of the vehicle's wheels are steered.
uint8_t flags
Flags that describe the configuration parameter.
float wheel_ticks_to_m
The scale factor to convert from wheel encoder ticks to distance (in meters/tick).
bool wheel_ticks_always_increase
true if the wheel tick measurements increase by a positive amount when driving forward or backward.
@ GET_CONFIG
GetConfigMessage
static constexpr uint8_t MESSAGE_VERSION
@ FRONT_AND_REAR
Front and rear wheels are steered.
@ OUTPUT_LEVER_ARM
The offset of the desired output location with respect to the vehicle body frame (in meters).
static constexpr uint8_t MESSAGE_VERSION
@ SAVED
Settings currently saved to persistent storage.
uint16_t message_id
The ID of the returned message type (e.g., 10000 for FusionEngine MessageType::POSE messages).
@ SET_CONFIG
SetConfigMessage
static constexpr uint8_t FLAG_APPLY_AND_SAVE
Flag to immediately save the config after applying this setting.
@ VEHICLE_DETAILS
Information about the vehicle including model and dimensions.
@ NONE
Speed data not applied to the system.
std::ostream & operator<<(std::ostream &stream, ConfigType type)
ConfigType stream operator.
@ WHEEL_CONFIG
Information pertaining to wheel speed/rotation measurements.
Point One FusionEngine output message common definitions.
uint8_t flags
Bitmask of additional flags to modify the command.
Vehicle/wheel speed measurement configuration settings.
@ USER_CONFIG
@ PLATFORM_STORAGE_DATA
PlatformStorageDataMessage
@ WHEEL_SPEED
Individual wheel speeds, reported in meters/second.
uint16_t message_id
The ID of the desired message type (e.g., 10000 for FusionEngine MessageType::POSE messages).
@ FALLING_EDGE
Capture a wheel tick on the falling edge of the incoming pulse.
@ FORWARD_ACTIVE_HIGH
Assume vehicle is moving forward when direction signal voltage is high, and backward when direction s...
static constexpr MessageType MESSAGE_TYPE
uint32_t config_length_bytes
The size of the parameter value, config_change_data (in bytes).
@ GGA
DataVersion data_version
Version of data contents.
@ FACTION
ConfigurationSource
The type of a device's configuration settings.
@ TCP_CLIENT
float x
const char * to_string(ConfigType type)
Get a human-friendly string name for the specified ConfigType.
@ INTERVAL_20_MS
Output this message every 20 milliseconds.
@ REAR_WHEELS
Rear wheel speed data to be applied to the system (recommended).
static constexpr MessageType MESSAGE_TYPE
@ GNSS_LEVER_ARM
The location of the GNSS antenna with respect to the vehicle body frame (in meters).
static constexpr MessageType MESSAGE_TYPE
float front_track_width_m
The distance between the two front wheels (in meters).
@ RIGHT
Aligned with vehicle -y axis.
uint16_t num_rates
The number of rates reported by this message.
static constexpr uint8_t MESSAGE_VERSION
@ KIA_SORENTO
@ FUSION_ENGINE
static constexpr uint8_t MESSAGE_VERSION
A struct representing the version of a data object.
Definition: data_version.h:22
@ OFF
Wheel tick direction not provided.
@ RISING_EDGE
Capture a wheel tick on the rising edge of the incoming pulse.
Direction x_direction
The direction of the device +x axis relative to the vehicle body axes.
@ UART2_OUTPUT_DIAGNOSTICS_MESSAGES
Force output the diagnostic message set on UART2.
InterfaceID(TransportType type, uint8_t index=0)
@ ALL
This is used for requesting the configuration for all protocols.
@ UDP_CLIENT
constexpr uint16_t ALL_MESSAGES_ID
Setting message_id to this value acts as a wild card.
AppliedSpeedType
The type of vehicle/wheel speed measurements to be applied.
@ J1939
@ UNKNOWN
Steered wheels unknown.
@ INVALID
@ FORWARD
Aligned with vehicle +x axis.
@ CONFIG_RESPONSE
ConfigResponseMessage