forked from PX4/PX4-Autopilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.h
More file actions
369 lines (340 loc) · 9.58 KB
/
messages.h
File metadata and controls
369 lines (340 loc) · 9.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/****************************************************************************
*
* Copyright (c) 2024 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file messages.h
*
* @brief Septentrio binary format (SBF) protocol message definitions.
*
* @author Thomas Frans
*/
#pragma once
#include <cstddef>
#include <cstdint>
namespace septentrio
{
namespace sbf
{
constexpr char k_sync1 {'$'};
constexpr char k_sync2 {'@'};
// Do-Not-Use values for fields in SBF blocks. The receiver can set certain fields to these values to signal that they are invalid.
// Most fields of a certain type will use these values (u2 representing a value often has DNU value of 65535).
// For the ones that do not use these, custom ones can be specified together with the blocks.
constexpr uint32_t k_dnu_u4_value {4294967295};
constexpr uint32_t k_dnu_u4_bitfield {0};
constexpr uint16_t k_dnu_u2_value {65535};
constexpr uint16_t k_dnu_u2_bitfield {0};
constexpr float k_dnu_f4_value {-2.0f * 10000000000.0f};
constexpr double k_dnu_f8_value {-2.0 * 10000000000.0};
/// Maximum size of all expected messages.
/// This needs to be bigger than the maximum size of all declared SBF blocks so that `memcpy()` can safely copy from the decoding buffer using this value into messages.
constexpr size_t k_max_message_size {300};
/// Maximum expected number of sub-blocks.
constexpr uint8_t k_max_quality_indicators {9};
constexpr uint8_t k_max_rfband_blocks {4};
/**
* IDs of all the available SBF messages that we care about.
*/
enum class BlockID : uint16_t {
Invalid = 0,
DOP = 4001,
PVTGeodetic = 4007,
ReceiverStatus = 4014,
QualityInd = 4082,
RFStatus = 4092,
GALAuthStatus = 4245,
VelCovGeodetic = 5908,
EndOfPVT = 5921,
GEOIonoDelay = 5933,
AttEuler = 5938,
AttCovEuler = 5939,
};
#pragma pack(push, 1)
/**
* Common SBF message header.
*/
struct Header {
uint8_t sync1;
uint8_t sync2;
uint16_t crc;
uint16_t id_number: 13;
uint16_t id_revision: 3;
uint16_t length;
uint32_t tow;
uint16_t wnc;
};
struct DOP {
uint8_t nr_sv;
uint8_t reserved;
uint16_t p_dop;
uint16_t t_dop;
uint16_t h_dop;
uint16_t v_dop;
float hpl;
float vpl;
};
struct PVTGeodetic {
static constexpr uint8_t k_dnu_nr_sv {255};
enum class ModeType : uint8_t {
NoPVT = 0,
StandAlonePVT = 1,
DifferentialPVT = 2,
FixedLocation = 3,
RTKFixed = 4,
RTKFloat = 5,
PVTWithSBAS = 6,
MovingBaseRTKFixed = 7,
MovingBaseRTKFloat = 8,
PrecisePointPositioning = 10,
};
enum class Error : uint8_t {
None = 0,
InsufficientMeasurements = 1,
InsufficientEphemerides = 2,
DOPTooLarge = 3,
SquaredResidualSumTooLarge = 4,
NoConvergence = 5,
InsufficientMeasurementsAfterOutlierRejection = 6,
ExportLawsForbidPositionOutput = 7,
InsufficientDifferentialCorrections = 8,
MissingBaseStationCoordinates = 9,
MissingRequiredRTKFixedPosition = 10,
};
uint8_t mode_type: 4;
uint8_t mode_reserved: 2;
uint8_t mode_base_fixed: 1;
uint8_t mode_2d: 1;
Error error;
double latitude;
double longitude;
double height;
float undulation;
float vn;
float ve;
float vu;
float cog;
double rx_clk_bias;
float rx_clk_drift;
uint8_t time_system;
uint8_t datum;
uint8_t nr_sv;
uint8_t wa_corr_info;
uint16_t reference_id;
uint16_t mean_corr_age;
uint32_t signal_info;
uint8_t alert_flag;
uint8_t nr_bases;
uint16_t ppp_info;
uint16_t latency;
uint16_t h_accuracy;
uint16_t v_accuracy;
};
struct ReceiverStatus {
uint8_t cpu_load;
uint8_t ext_error_siserror: 1;
uint8_t ext_error_diff_corr_error: 1;
uint8_t ext_error_ext_sensor_error: 1;
uint8_t ext_error_setup_error: 1;
uint8_t ext_error_reserved: 4;
uint32_t uptime;
uint32_t rx_state_reserved1: 1;
uint32_t rx_state_active_antenna: 1;
uint32_t rx_state_ext_freq: 1;
uint32_t rx_state_ext_time: 1;
uint32_t rx_state_wn_set: 1;
uint32_t rx_state_tow_set: 1;
uint32_t rx_state_fine_time: 1;
uint32_t rx_state_internal_disk_activity: 1;
uint32_t rx_state_internal_disk_full: 1;
uint32_t rx_state_internal_disk_mounted: 1;
uint32_t rx_state_int_ant: 1;
uint32_t rx_state_refout_locked: 1;
uint32_t rx_state_reserved2: 1;
uint32_t rx_state_external_disk_activity: 1;
uint32_t rx_state_external_disk_full: 1;
uint32_t rx_state_external_disk_mounted: 1;
uint32_t rx_state_pps_in_cal: 1;
uint32_t rx_state_diff_corr_in: 1;
uint32_t rx_state_internet: 1;
uint32_t rx_state_reserved3: 13;
uint32_t rx_error_reserved1: 3;
uint32_t rx_error_software: 1;
uint32_t rx_error_watchdog: 1;
uint32_t rx_error_antenna: 1;
uint32_t rx_error_congestion: 1;
uint32_t rx_error_reserved2: 1;
uint32_t rx_error_missed_event: 1;
uint32_t rx_error_cpu_overload: 1;
uint32_t rx_error_invalid_config: 1;
uint32_t rx_error_out_of_geofence: 1;
uint32_t rx_error_reserved3: 22;
uint8_t n;
uint8_t sb_length;
uint8_t cmd_count;
uint8_t temperature;
};
struct QualityIndicator {
enum class Type : uint8_t {
Overall = 0,
GNSSSignalsMainAntenna = 1,
GNSSSignalsAuxAntenna = 2,
RFPowerMainAntenna = 11,
RFPowerAuxAntenna = 12,
CPUHeadroom = 21,
OCXOStability = 25,
BaseStationMeasurements = 30,
RTKPostProcessing = 31,
};
Type type: 8;
uint16_t value: 4;
uint16_t reserved: 4;
};
struct QualityInd {
uint8_t n;
uint8_t reserved1;
// Only support the currently available indicators for now so we don't have to allocate.
QualityIndicator indicators[k_max_quality_indicators];
};
struct RFBand {
enum class InfoMode : uint8_t {
Suppressed = 1,
Mitigated = 2,
Interference = 8
};
uint32_t frequency;
uint16_t bandwidth;
uint8_t info_mode: 4;
uint8_t info_reserved: 2;
uint8_t info_antenna_id: 2;
};
struct RFStatus {
uint8_t n;
uint8_t sb_length;
uint8_t flags_inauthentic_gnss_signals: 1;
uint8_t flags_inauthentic_navigation_message: 1;
uint8_t flags_reserved: 6;
uint8_t reserved[3];
RFBand rf_band[k_max_rfband_blocks];
};
struct GALAuthStatus {
enum class OSNMAStatus : uint16_t {
Disabled = 0,
Initializing = 1,
AwaitingTrustedTimeInfo = 2,
InitFailedInconsistentTime = 3,
InitFailedKROOTInvalid = 4,
InitFailedInvalidParam = 5,
Authenticating = 6,
};
uint16_t osnma_status_status: 3;
uint16_t osnma_status_initialization_progress: 8;
uint16_t osnma_status_trusted_time_source: 3;
uint16_t osnma_status_merkle_tree_busy: 1;
uint16_t osnma_status_reserved: 1;
float trusted_time_delta;
uint64_t gal_active_mask;
uint64_t gal_authentic_mask;
uint64_t gps_active_mask;
uint64_t gps_authentic_mask;
OSNMAStatus osnmaStatus() const { return static_cast<OSNMAStatus>(osnma_status_status); }
};
struct VelCovGeodetic {
uint8_t mode_type: 4;
uint8_t mode_reserved: 2;
uint8_t mode_base_fixed: 1;
uint8_t mode_2d: 1;
uint8_t error;
float cov_vn_vn;
float cov_ve_ve;
float cov_vu_vu;
float cov_dt_dt;
float cov_vn_ve;
float cov_vn_vu;
float cov_vn_dt;
float cov_ve_vu;
float cov_ve_dt;
float cov_vu_dt;
};
struct IDC {
uint8_t igp_mask_no;
uint8_t givei;
uint8_t reserved[2];
float vertical_delay;
};
struct GEOIonoDelay {
uint8_t prn;
uint8_t bandnbr;
uint8_t iodi;
uint8_t n;
uint8_t sb_length;
uint8_t reserved;
IDC idc[4];
};
struct AttEuler {
enum class Error : uint8_t {
None = 0,
InsufficientMeasurements = 1,
};
uint8_t nr_sv;
uint8_t error_aux1: 2;
uint8_t error_aux2: 2;
uint8_t error_reserved: 3;
uint8_t error_not_requested: 1;
uint16_t mode;
uint16_t reserved;
float heading;
float pitch;
float roll;
float pitch_dot;
float roll_dot;
float heading_dot;
};
struct AttCovEuler {
enum class Error : uint8_t {
None = 0,
InsufficientMeasurements = 1,
};
uint8_t reserved;
uint8_t error_aux1: 2;
uint8_t error_aux2: 2;
uint8_t error_reserved: 3;
uint8_t error_not_requested: 1;
float cov_headhead;
float cov_pitchpitch;
float cov_rollroll;
float cov_headpitch;
float cov_headroll;
float cov_pitchroll;
};
#pragma pack(pop)
} // namespace sbf
} // namespace septentrio