30#include "fpsdk_common/ext/eigen_core.hpp"
54const uint8_t SAMPLE_DATA[] = {
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"
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"
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"
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"
80const std::size_t SAMPLE_SIZE =
sizeof(SAMPLE_DATA) - 1;
97static constexpr const char* source_crs =
"EPSG:4936";
98static constexpr const char* target_crs =
"EPSG:2056";
101static void ProcessCollectedMsgs(
const CollectedMsgs& collected_msgs,
Transformer& trafo);
103int main(
int ,
char** )
108 LoggingSetParams({ LoggingLevel::TRACE });
112 if (!trafo.Init(source_crs, target_crs)) {
113 ERROR(
"Failed creating coordinate transformer!");
121 if (!parser.
Add(SAMPLE_DATA, SAMPLE_SIZE)) {
122 WARNING(
"Parser overflow, SAMPLE_DATA is too large!");
126 CollectedMsgs collected_msgs;
128 DEBUG(
"Message %-s (size %" PRIuMAX
" bytes)", msg.
name_.c_str(), msg.
data_.size());
132 if (msg.
name_ == FpaOdometryPayload::MSG_NAME) {
133 msg_ok = collected_msgs.fpa_odometry_.SetFromMsg(msg.
data_.data(), msg.
data_.size());
136 else if (msg.
name_ == FpaOdomstatusPayload::MSG_NAME) {
137 msg_ok = collected_msgs.fpa_odomstatus_.SetFromMsg(msg.
data_.data(), msg.
data_.size());
140 else if (msg.
name_ == FpaEoePayload::MSG_NAME) {
143 if (fpa_eoe.
epoch == FpaEpoch::FUSION) {
145 collected_msgs.fpa_eoe_ = fpa_eoe;
146 ProcessCollectedMsgs(collected_msgs, trafo);
149 collected_msgs = CollectedMsgs();
191static void ProcessCollectedMsgs(
const CollectedMsgs& collected_msgs,
Transformer& trafo)
193 auto& fpa_odometry = collected_msgs.fpa_odometry_;
194 auto& fpa_odomstatus = collected_msgs.fpa_odomstatus_;
195 auto& fpa_eoe = collected_msgs.fpa_eoe_;
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))) {
207 if (!fpa_odometry.pos.valid || (fpa_odomstatus.init_status == FpaInitStatus::UNSPECIFIED)) {
214 if (fpa_odomstatus.init_status != FpaInitStatus::GLOBAL_INIT) {
222 fpa_eoe.
gps_time.
tow.
value, fpa_odometry.pos.values[0], fpa_odometry.pos.values[1], fpa_odometry.pos.values[2]);
225 Eigen::Vector3d pos = { fpa_odometry.pos.values[0], fpa_odometry.pos.values[1], fpa_odometry.pos.values[2] };
227 INFO(
"Local coordinates: %.1f %.1f %.1f", pos(0), pos(1), pos(2));
Fixposition SDK: Utilities for apps.
Helper to print a strack trace on SIGSEGV and SIGABRT.
bool Process(ParserMsg &msg)
Process data in parser, return message.
bool Add(const uint8_t *data, const std::size_t size)
Add data to parser.
Fixposition SDK: Parser FP_A routines and types.
Fixposition SDK: Logging.
#define ERROR(fmt,...)
Print a error message.
#define INFO(fmt,...)
Print a info message.
#define DEBUG(fmt,...)
Print a debug message.
#define WARNING(fmt,...)
Print a warning message.
Parser FP_A routines and types.
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.
std::vector< uint8_t > data_
Message data.
FP_A-EOE (version 1) message payload.
bool SetFromMsg(const uint8_t *msg, const std::size_t msg_size)
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)
FP_A-ODOMSTATUS (version 1) messages payload.
bool valid_
Payload successfully decoded (true), or not (yet) decoded (false)
Fixposition SDK: Transformation utilities.