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#include <cinttypes>
26#include <cstdint>
27#include <cstdlib>
28
29
30#include "fpsdk_common/ext/eigen_core.hpp"
31
32
38
39
40
41
42
49
50
51
52
53
54const uint8_t SAMPLE_DATA[] = {
55
56 "$FP,ODOMSTATUS,1,2349,59920.000000,2,2,1,1,1,1,,0,,,,,,0,1,3,8,8,3,5,5,,0,6,,,,,,,,,,,,*18\r\n"
57 "$FP,EOE,1,2349,59920.000000,FUSION*59\r\n"
58
59 "$FP,ODOMETRY,2,2349,59921.000000,4278387.6882,635620.5002,4672339.9313,-0.580560,0.326972,-0.184160,0.722582,"
60 "-0.0008,0.0001,-0.0003,0.00190,-0.00021,-0.00018,0.1875,-0.1978,9.8054,4,0,8,8,-1,0.00139,0.00459,0.00201,0.0024"
61 "4,-0.00294,-0.00160,0.03639,0.00068,0.04631,0.00467,-0.00524,-0.04100,0.00175,0.00055,0.00065,-0.00005,0.0000"
62 "0,0.00045,fp_vrtk2-integ_6912e460-1703*20\r\n"
63 "$FP,ODOMSTATUS,1,2349,59921.000000,1,2,1,1,1,1,,0,,,,,,0,1,3,8,8,3,5,5,,0,6,,,,,,,,,,,,*1A\r\n"
64 "$FP,EOE,1,2349,59921.000000,FUSION*58\r\n"
65
66 "$FP,ODOMETRY,2,2349,59922.000000,,,,-0.580477,0.327111,-0.184310,0.722547,"
67 "-0.0012,0.0001,-0.0010,-0.00048,-0.00065,-0.00063,0.1939,-0.2015,9.8043,4,0,8,8,-1,0.00139,0.00458,0.00200,0.002"
68 "44,-0.00293,-0.00160,0.03636,0.00067,0.04631,0.00466,-0.00524,-0.04098,0.00171,0.00055,0.00064,-0.00005,0.000"
69 "00,0.00043,fp_vrtk2-integ_6912e460-1703*29\r\n"
70 "$FP,ODOMSTATUS,1,2349,59922.000000,2,2,1,1,1,1,,0,,,,,,0,1,3,8,8,3,5,5,,0,6,,,,,,,,,,,,*1A\r\n"
71 "$FP,EOE,1,2349,59922.000000,FUSION*5B\r\n"
72
73 "$FP,ODOMETRY,2,2349,59923.000000,4278387.6888,635620.5014,4672339.9313,-0.580321,0.327140,-0.184394,0.722638,"
74 "-0.0023,0.0005,-0.0003,0.00038,0.00123,0.00023,0.1910,-0.2060,9.7975,4,0,8,8,-1,0.00139,0.00458,0.00200,0.00244,"
75 "-0.00293,-0.00160,0.03633,0.00068,0.04629,0.00467,-0.00524,-0.04096,0.00171,0.00055,0.00064,-0.00005,0.00000,"
76 "0.00043,fp_vrtk2-integ_6912e460-1703*27\r\n"
77 "$FP,ODOMSTATUS,1,2349,59923.000000,2,2,1,1,1,1,,0,,,,,,0,1,3,8,8,3,5,5,,0,6,,,,,,,,,,,,*1B\r\n"
78 "$FP,EOE,1,2349,59923.000000,FUSION*5A\r\n"
79};
80const std::size_t SAMPLE_SIZE = sizeof(SAMPLE_DATA) - 1;
81
82
83
84
85
86struct CollectedMsgs
87{
91};
92
93
94
95
96
97static constexpr const char* source_crs = "EPSG:4936";
98static constexpr const char* target_crs = "EPSG:2056";
99
100
101static void ProcessCollectedMsgs(
const CollectedMsgs& collected_msgs,
Transformer&
trafo);
102
103int main(int , char** )
104{
105#ifndef NDEBUG
107#endif
109
110
112 if (!
trafo.Init(source_crs, target_crs)) {
113 ERROR(
"Failed creating coordinate transformer!");
114 return EXIT_FAILURE;
115 }
116
117
118
121 if (!
parser.Add(SAMPLE_DATA, SAMPLE_SIZE)) {
122 WARNING(
"Parser overflow, SAMPLE_DATA is too large!");
123 }
124
125
126 CollectedMsgs collected_msgs;
127 while (
parser.Process(msg)) {
128 DEBUG(
"Message %-s (size %" PRIuMAX
" bytes)", msg.
name_.c_str(), msg.
Size());
129 bool msg_ok = true;
130
131
133 msg_ok = collected_msgs.fpa_odometry_.SetFromMsg(msg.
Data(), msg.
Size());
134 }
135
137 msg_ok = collected_msgs.fpa_odomstatus_.SetFromMsg(msg.
Data(), msg.
Size());
138 }
139
144
145 collected_msgs.fpa_eoe_ = fpa_eoe;
146 ProcessCollectedMsgs(collected_msgs,
trafo);
147
148
149 collected_msgs = CollectedMsgs();
150 }
151 }
152
153
154
155 if (!msg_ok) {
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 return EXIT_SUCCESS;
189}
190
191static void ProcessCollectedMsgs(
const CollectedMsgs& collected_msgs,
Transformer&
trafo)
192{
193 auto& fpa_odometry = collected_msgs.fpa_odometry_;
194 auto& fpa_odomstatus = collected_msgs.fpa_odomstatus_;
195 auto& fpa_eoe = collected_msgs.fpa_eoe_;
196
197
198 if (!(fpa_odometry.valid_ && fpa_odomstatus.valid_ && fpa_eoe.
valid_ && fpa_odometry.gps_time.week.valid &&
199 fpa_odometry.gps_time.tow.valid && (fpa_odometry.gps_time == fpa_odomstatus.gps_time) &&
200 (fpa_odometry.gps_time == fpa_eoe.
gps_time))) {
202 return;
203 }
204
205
206
209 return;
210 }
211
212
213
217 return;
218 }
219
220
222 fpa_eoe.
gps_time.
tow.
value, fpa_odometry.pos.values[0], fpa_odometry.pos.values[1], fpa_odometry.pos.values[2]);
223
224
225 Eigen::Vector3d pos = { fpa_odometry.pos.values[0], fpa_odometry.pos.values[1], fpa_odometry.pos.values[2] };
226 if (
trafo.Transform(pos)) {
227 INFO(
"Local coordinates: %.1f %.1f %.1f", pos(0), pos(1), pos(2));
228 }
229
230
231
232
233
234}
235
236
Fixposition SDK: Utilities for apps.
Helper to print a strack trace on SIGSEGV and SIGABRT.
Fixposition SDK: Parser FP_A routines and types.
Fixposition SDK: Logging.
#define ERROR(...)
Print a error message.
#define WARNING(...)
Print a warning message.
#define DEBUG(...)
Print a debug message.
#define INFO(...)
Print a info message.
LoggingParams LoggingSetParams(const LoggingParams ¶ms)
Configure logging.
@ TRACE
[7/debug] Extra debugging, only compiled-in in non-Release builds
Parser FP_A routines and types.
@ UNSPECIFIED
Unspecified.
@ GLOBAL_INIT
Globally initialised.
Transformation utilities.
Message frame output by the Parser.
std::string info_
Message (debug) info, default empty, call MakeInfo() to fill.
std::string name_
Name of the message.
void MakeInfo() const
Make info_ field.
const uint8_t * Data() const
Get message raw data.
std::size_t Size() const
Get message raw size.
FP_A-EOE (version 1) message payload.
static constexpr const char * MSG_NAME
Message name.
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size) final
Set data from message.
FpaEpoch epoch
Indicates which epoch ended ("FUSION", "GNSS", "GNSS1", "GNSS2")
FpaInt week
GPS week number, range 0-9999, or null if time not (yet) available.
FpaFloat tow
GPS time of week, range 0.000-604799.999999, or null if time not (yet) available.
FP_A-ODOMETRY (version 2) messages payload (ECEF)
static constexpr const char * MSG_NAME
Message name.
FP_A-ODOMSTATUS (version 1) messages payload.
static constexpr const char * MSG_NAME
Message name.
bool valid_
Payload successfully decoded (true), or not (yet) decoded (false)
Fixposition SDK: Transformation utilities.