Skip to main content

defs.h File

Point One FusionEngine output message common definitions. More...

Included Headers

#include <cmath> #include <cstdint> #include <string> #include "point_one/fusion_engine/common/portability.h" #include "point_one/fusion_engine/messages/signal_defs.h"

Namespaces Index

namespacepoint_one

GNSS signal and frequency type definitions. More...

namespacefusion_engine
namespacemessages

Classes Index

structMessageHeader

The header present at the beginning of every message. More...

structMessagePayload

The base class for all message payloads. More...

structTimestamp

Generic timestamp representation. More...

Description

Point One FusionEngine output message common definitions.

File Listing

The file content with the documentation metadata removed is:

1/**************************************************************************/ /**
2 * @brief Point One FusionEngine output message common definitions.
3 * @file
4 ******************************************************************************/
5
6#pragma once
7
8#include <cmath> // For NAN
9#include <cstdint>
10#include <string>
11
14
15namespace point_one {
16namespace fusion_engine {
17namespace messages {
18
19// Enforce 4-byte alignment and packing of all data structures and values.
20// Floating point values are aligned on platforms that require it. This is done
21// with a combination of setting struct attributes, and manual alignment
22// within the definitions. See the "Message Packing" section of the README.
23#pragma pack(push, 1)
24
25/**
26 * @defgroup enum_definitions Common Enumeration Definitions
27 * @{
28 */
29
30/**
31 * @brief Identifiers for the defined output message types.
32 * @ingroup messages
33 */
34enum class MessageType : uint16_t {
35 INVALID = 0, ///< Invalid message type
36
37 // Navigation solution messages.
38 POSE = 10000, ///< @ref PoseMessage
39 GNSS_INFO = 10001, ///< @ref GNSSInfoMessage
40 GNSS_SATELLITE = 10002, ///< @ref GNSSSatelliteMessage
41 POSE_AUX = 10003, ///< @ref PoseAuxMessage
42 CALIBRATION_STATUS = 10004, ///< @ref CalibrationStatusMessage
43 RELATIVE_ENU_POSITION = 10005, ///< @ref RelativeENUPositionMessage
44 GNSS_SIGNALS = 10006, ///< @ref GNSSSignalsMessage
45
46 // Device status messages.
47 SYSTEM_STATUS = 10500, ///< @ref SystemStatusMessage
48
49 // Sensor measurement messages.
50 IMU_OUTPUT = 11000, ///< @ref IMUOutput
52 RAW_IMU_OUTPUT = 11002, ///< @ref RawIMUOutput
54 IMU_INPUT = 11004, ///< @ref IMUInput
55 GNSS_ATTITUDE_OUTPUT = 11005, ///< @ref GNSSAttitudeOutput
56 RAW_GNSS_ATTITUDE_OUTPUT = 11006, ///< @ref RawGNSSAttitudeOutput
57 EXTERNAL_POSE_INPUT = 11007, ///< @ref ExternalPoseInput
58
59 // Vehicle measurement messages.
61 11101, ///< @ref DeprecatedWheelSpeedMeasurement
63 11102, ///< @ref DeprecatedVehicleSpeedMeasurement
64
65 WHEEL_TICK_INPUT = 11103, ///< @ref WheelTickInput
66 VEHICLE_TICK_INPUT = 11104, ///< @ref VehicleTickInput
67 WHEEL_SPEED_INPUT = 11105, ///< @ref WheelSpeedInput
68 VEHICLE_SPEED_INPUT = 11106, ///< @ref VehicleSpeedInput
69
70 RAW_WHEEL_TICK_OUTPUT = 11123, ///< @ref RawWheelTickOutput
71 RAW_VEHICLE_TICK_OUTPUT = 11124, ///< @ref RawVehicleTickOutput
72 RAW_WHEEL_SPEED_OUTPUT = 11125, ///< @ref RawWheelSpeedOutput
73 RAW_VEHICLE_SPEED_OUTPUT = 11126, ///< @ref RawVehicleSpeedOutput
74
75 WHEEL_SPEED_OUTPUT = 11135, ///< @ref WheelSpeedOutput
76 VEHICLE_SPEED_OUTPUT = 11136, ///< @ref VehicleSpeedOutput
77
78 // ROS messages.
79 ROS_POSE = 12000, ///< @ref ros::PoseMessage
80 ROS_GPS_FIX = 12010, ///< @ref ros::GPSFixMessage
81 ROS_IMU = 12011, ///< @ref ros::IMUMessage
82
83 // Command and control messages.
84 COMMAND_RESPONSE = 13000, ///< @ref CommandResponseMessage
85 MESSAGE_REQUEST = 13001, ///< @ref MessageRequest
86 RESET_REQUEST = 13002, ///< @ref ResetRequest
87 VERSION_INFO = 13003, ///< @ref VersionInfoMessage
88 EVENT_NOTIFICATION = 13004, ///< @ref EventNotificationMessage
89 SHUTDOWN_REQUEST = 13005, ///< @ref ShutdownRequest
90 FAULT_CONTROL = 13006, ///< @ref FaultControlMessage
91 DEVICE_ID = 13007, ///< @ref DeviceIDMessage
92 STARTUP_REQUEST = 13008, ///< @ref StartupRequest
93
94 SET_CONFIG = 13100, ///< @ref SetConfigMessage
95 GET_CONFIG = 13101, ///< @ref GetConfigMessage
96 SAVE_CONFIG = 13102, ///< @ref SaveConfigMessage
97 CONFIG_RESPONSE = 13103, ///< @ref ConfigResponseMessage
98
99 IMPORT_DATA = 13110, ///< @ref ImportDataMessage
100 EXPORT_DATA = 13111, ///< @ref ExportDataMessage
101 PLATFORM_STORAGE_DATA = 13113, ///< @ref PlatformStorageDataMessage
102 INPUT_DATA_WRAPPER = 13120, ///< @ref InputDataWrapperMessage
103
104 SET_MESSAGE_RATE = 13220, ///< @ref SetMessageRate
105 GET_MESSAGE_RATE = 13221, ///< @ref GetMessageRate
106 MESSAGE_RATE_RESPONSE = 13222, ///< @ref MessageRateResponse
107 SUPPORTED_IO_INTERFACES = 13223, ///< @ref SupportedIOInterfacesMessage
108
109 LBAND_FRAME = 14000, ///< @ref LBandFrameMessage
110
111 STA5635_COMMAND = 14100, ///< @ref STA5635Command
112 STA5635_COMMAND_RESPONSE = 14101, ///< @ref STA5635CommandResponse
113 STA5635_IQ_DATA = 14102, ///< @ref STA5635IQData
114
115 /// The maximum defined @ref MessageType enum value.
117};
118
119/**
120 * @brief Get a human-friendly string name for the specified @ref MessageType.
121 * @ingroup enum_definitions
122 *
123 * @param type The desired message type.
124 *
125 * @return The corresponding string name.
126 */
128 switch (type) {
130 return "Invalid";
131
132 // Navigation solution messages.
134 return "Pose";
135
137 return "GNSS Info";
138
140 return "GNSS Satellite";
141
143 return "Pose Auxiliary";
144
146 return "Calibration Status";
147
149 return "Relative ENU Position";
150
152 return "GNSS Signals";
153
154 // Device status messages.
156 return "System Status";
157
158 // Sensor measurement messages.
160 return "IMU Output";
161
163 return "Raw GNSS Heading Output";
164
166 return "Raw IMU Output";
167
169 return "GNSS Heading Output";
170
172 return "IMU Input";
173
175 return "GNSS Attitude Output";
176
178 return "Raw GNSS Attitude Output";
179
181 return "External Pose Input";
182
184 return "Wheel Speed Measurement";
185
187 return "Vehicle Speed Measurement";
188
190 return "Wheel Tick Input";
191
193 return "Vehicle Tick Input";
194
196 return "Wheel Speed Input";
197
199 return "Vehicle Speed Input";
200
202 return "Raw Wheel Tick Output";
203
205 return "Raw Vehicle Tick Output";
206
208 return "Raw Wheel Speed Output";
209
211 return "Raw Vehicle Speed Output";
212
214 return "Wheel Speed Output";
215
217 return "Vehicle Speed Output";
218
219 // ROS messages.
221 return "ROS Pose";
222
224 return "ROS GPSFix";
225
227 return "ROS IMU";
228
229 // Command and control messages.
231 return "Command Response";
232
234 return "Message Transmission Request";
235
237 return "Reset Request";
238
240 return "Version Information";
241
243 return "Event Notification";
244
246 return "Shutdown Request";
247
249 return "Startup Request";
250
252 return "Device ID Information";
253
255 return "Fault Control";
256
258 return "Set Configuration Parameter";
259
261 return "Get Configuration Parameter";
262
264 return "Save Configuration";
265
267 return "Configuration Parameter Value";
268
270 return "Set Message Rate";
271
273 return "Get Message Rate";
274
276 return "Supported IO Interfaces";
277
279 return "Message Rate Response";
280
282 return "Import Data To Device";
283
285 return "Export Data From Device";
286
288 return "Platform Data Contents";
289
291 return "Wrapped Input Data";
292
294 return "L-band Frame Contents";
295
297 return "STA5635 Command";
298
300 return "STA5635 Command Response";
301
303 return "STA5635 IQ Data";
304 }
305 return "Unrecognized Message";
306}
307
308/**
309 * @brief @ref MessageType stream operator.
310 * @ingroup enum_definitions
311 */
313 stream << to_string(type) << " (" << (int)type << ")";
314 return stream;
315}
316
317/**
318 * @brief Check if the specified message type is a user command.
319 * @ingroup messages
320 *
321 * See also @ref IsResponse().
322 *
323 * @param message_type The message type in question.
324 *
325 * @return `true` if the message is a FusionEngine command.
326 */
328 switch (message_type) {
342 return true;
343
388 return false;
389 }
390 return false;
391}
392
393/**
394 * @brief Check if the specified message type is a response to a user command.
395 * @ingroup messages
396 *
397 * See also @ref IsCommand().
398 *
399 * @param message_type The message type in question.
400 *
401 * @return `true` if the message is a FusionEngine command response.
402 */
404 switch (message_type) {
409 return true;
410 default:
411 return false;
412 }
413}
414
415/** @brief Command response status indicators. */
416enum class Response : uint8_t {
417 OK = 0,
418 /**
419 * A version specified in the command or subcommand could not be handled.
420 * This could mean that the version was too new, or it was old and there was
421 * not a translation for it.
422 */
424 /**
425 * The command interacts with a feature that is not present on the target
426 * device (e.g., Setting the baud rate on a device without a serial port).
427 */
429 /**
430 * One or more values in the command were not in acceptable ranges (e.g., An
431 * undefined enum value, or an invalid baud rate).
432 */
433 VALUE_ERROR = 3,
434 /**
435 * The command would require adding too many elements to an internal
436 * storage.
437 */
439 /**
440 * There was a runtime failure executing the command.
441 */
443 /**
444 * The header `payload_size_bytes` is in conflict with the size of the
445 * message based on its type and type specific length fields.
446 */
448 /**
449 * Requested data was corrupted and not available.
450 */
452 /**
453 * The requested data isn't available.
454 */
456 /**
457 * The device is in a state where it can't process the command.
458 */
459 UNAVAILABLE = 9,
460 /**
461 * An interface specified in the command is invalid, or unsupported on the
462 * target device.
463 */
465};
466
467/**
468 * @brief Get a human-friendly string name for the specified @ref Response.
469 *
470 * @param val The enum to get the string name for.
471 *
472 * @return The corresponding string name.
473 */
475 switch (val) {
476 case Response::OK:
477 return "Ok";
479 return "Unsupported Command Version";
481 return "Unsupported Feature";
483 return "Value Error";
485 return "Insufficient Space";
487 return "Execution Failure";
489 return "Inconsistent Payload Length";
491 return "Data Corrupted";
493 return "No Data Stored";
495 return "Device Unavailable";
497 return "Unsupported Interface";
498 }
499 return "Unrecognized";
500}
501
502/**
503 * @brief @ref Response stream operator.
504 */
506 stream << to_string(val) << " (" << (int)val << ")";
507 return stream;
508}
509
510/**
511 * @brief Navigation solution type definitions.
512 */
513enum class SolutionType : uint8_t {
514 /** Invalid, no position available. */
515 Invalid = 0,
516 /** Standalone GNSS fix, no GNSS corrections data used. */
517 AutonomousGPS = 1,
518 /**
519 * Differential GNSS pseudorange solution using a local RTK base station or
520 * SSR or SBAS corrections.
521 */
522 DGPS = 2,
523 /**
524 * GNSS RTK solution with fixed integer carrier phase ambiguities (one or more
525 * signals fixed).
526 */
527 RTKFixed = 4,
528 /** GNSS RTK solution with floating point carrier phase ambiguities. */
529 RTKFloat = 5,
530 /** Integrated position using dead reckoning. */
531 Integrate = 6,
532 /** Using vision measurements. */
533 Visual = 9,
534 /**
535 * GNSS precise point positioning (PPP) pseudorange/carrier phase solution.
536 */
537 PPP = 10,
538 MAX_VALUE = PPP,
539};
540
541/**
542 * @brief Get a human-friendly string name for the specified @ref SolutionType.
543 * @ingroup enum_definitions
544 *
545 * @param type The desired message type.
546 *
547 * @return The corresponding string name.
548 */
550 switch (type) {
552 return "Invalid";
553
555 return "Stand Alone GNSS";
556
558 return "Differential GNSS";
559
561 return "Fixed RTK GNSS";
562
564 return "Real-valued Ambiguity RTK GNSS";
565
567 return "Dead Reckoning";
568
570 return "Visual Navigation";
571
573 return "PPP GNSS";
574 }
575 return "Unrecognized Solution Type";
576}
577
578/**
579 * @brief @ref SolutionType stream operator.
580 * @ingroup enum_definitions
581 */
583 stream << to_string(type) << " (" << (int)type << ")";
584 return stream;
585}
586
587/** @} */
588
589/**
590 * @brief Generic timestamp representation.
591 *
592 * This structure may be used to store Point One system time values (referenced
593 * to the start of the device), UNIX times (referenced to January 1, 1970), or
594 * GPS times (referenced to January 6, 1980).
595 */
597 static constexpr uint32_t INVALID = 0xFFFFFFFF;
598
599 /**
600 * The number of full seconds since the epoch. Set to @ref INVALID if
601 * the timestamp is invalid or unknown.
602 */
603 uint32_t seconds = INVALID;
604
605 /** The fractional part of the second, expressed in nanoseconds. */
606 uint32_t fraction_ns = INVALID;
607};
608
609/**
610 * @brief The header present at the beginning of every message.
611 * @ingroup messages
612 *
613 * The header is followed immediately in the binary stream by the message
614 * payload specified by @ref message_type.
615 */
617 static constexpr uint8_t SYNC0 = 0x2E; // '.'
618 static constexpr uint8_t SYNC1 = 0x31; // '1'
619
620 static constexpr uint32_t INVALID_SOURCE_ID = 0xFFFFFFFF;
621
622 /**
623 * The maximum expected message size (in bytes), used for sanity checking.
624 */
625 static const size_t MAX_MESSAGE_SIZE_BYTES = (1 << 24);
626
627 /** Message sync bytes: always set to ASCII `.1` (0x2E, 0x31). */
628 uint8_t sync[2] = {SYNC0, SYNC1};
629
630 uint8_t reserved[2] = {0};
631
632 /**
633 * The 32-bit CRC of all bytes from and including the @ref protocol_version
634 * field to the last byte in the message, including the message payload. This
635 * uses the standard CRC-32 generator polynomial in reversed order
636 * (0xEDB88320).
637 *
638 * See also @ref crc_support.
639 */
640 uint32_t crc = 0;
641
642 /** The version of the P1 binary protocol being used. */
643 uint8_t protocol_version = 2;
644
645 /**
646 * The version of the message type specified by @ref message_type to follow.
647 */
648 uint8_t message_version = 0;
649
650 /** Type identifier for the serialized message to follow. */
651 MessageType message_type = MessageType::INVALID;
652
653 /** The sequence number of this message. */
654 uint32_t sequence_number = 0;
655
656 /** The size of the serialized message (bytes). */
657 uint32_t payload_size_bytes = 0;
658
659 /** Identifies the source of the serialized data. */
660 uint32_t source_identifier = INVALID_SOURCE_ID;
661};
662
663/**
664 * @brief Check if the specified message is a user command.
665 * @ingroup messages
666 *
667 * See @ref IsCommand() for details.
668 *
669 * @param header Header of a received FusionEngine message.
670 *
671 * @return `true` if the message is a FusionEngine command.
672 */
674 return IsCommand(header.message_type);
675}
676
677/**
678 * @brief Check if the specified message type is a response to a user command.
679 * @ingroup messages
680 *
681 * See @ref IsResponse() for details.
682 *
683 * @param header Header of a received FusionEngine message.
684 *
685 * @return `true` if the message is a FusionEngine command response.
686 */
688 return IsResponse(header.message_type);
689}
690
691/**
692 * @brief The base class for all message payloads.
693 * @ingroup messages
694 */
696 // Currently empty - used simply to distinguish between payload definitions
697 // and other types.
698};
699
700#pragma pack(pop)
701
702/**
703 * @defgroup messages Message Definitions
704 * @brief Type definitions for all defined messages.
705 *
706 * See also @ref MessageType.
707 */
708
709} // namespace messages
710} // namespace fusion_engine
711} // namespace point_one

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.9.8.