1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <cinttypes>
25#include <cmath>
26#include <cstdint>
27#include <cstdio>
28#include <cstdlib>
29#include <cstring>
30
31
32#include <unistd.h>
33
34
39
40
41
42
43
49
50
51
52int main(int , char** )
53{
54#ifndef NDEBUG
56#endif
58
59
60 const double speed_FL[3] = { 5.422, -0.02, 0.4 };
61 const double speed_FR[3] = { 6.543, +0.03, 0.5 };
62
63
64
67
69
70 meas[0].
meas_x = std::floor(speed_FL[0] * 1e3);
71 meas[0].
meas_y = std::floor(speed_FL[1] * 1e3);
72 meas[0].
meas_z = std::floor(speed_FL[2] * 1e3);
79
80 meas[1].
meas_x = std::floor(speed_FR[0] * 1e3);
81 meas[1].
meas_y = std::floor(speed_FR[1] * 1e3);
82 meas[1].
meas_z = std::floor(speed_FR[2] * 1e3);
89
90
92 std::size_t payload_size = 0;
93
94 std::memcpy(&payload[payload_size], &head, sizeof(head));
95 payload_size += sizeof(head);
96
98 std::memcpy(&payload[payload_size], &meas[ix], sizeof(meas[ix]));
99 payload_size += sizeof(meas[ix]);
100 }
101
102 INFO(
"num_meas=%" PRIu8
" payload_size=%" PRIuMAX, head.
num_meas, payload_size);
104
105
106 std::vector<uint8_t> message;
108 INFO(
"Message successfully made");
110
111
112 if (isatty(fileno(stdout)) == 0) {
113 write(fileno(stdout), message.data(), message.size());
114 }
115 } else {
116 WARNING(
"Failed making FP_B-MEASUREMENTS message");
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 return EXIT_SUCCESS;
162}
163
164
Fixposition SDK: Utilities for apps.
Helper to print a strack trace on SIGSEGV and SIGABRT.
Fixposition SDK: Parser FP_B routines and types.
Fixposition SDK: Logging.
#define WARNING(...)
Print a warning message.
#define DEBUG_HEXDUMP(data, size, prefix,...)
Print a debug hexdump.
#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_B routines and types.
static constexpr std::size_t FP_B_MEASUREMENTS_MAX_NUM_MEAS
Maximum number of measurements.
bool FpbMakeMessage(std::vector< uint8_t > &msg, const uint16_t msg_id, const uint16_t msg_time, const std::vector< uint8_t > &payload)
Make a FP_B message.
static constexpr std::size_t FP_B_MEASUREMENTS_HEAD_SIZE
FP_B-MEASUREMENTS payload head size.
@ TIMEOFARRIVAL
Use time of arrival of the measurement (ignore gps_wno and gps_tow)
@ VELOCITY
Velocity measuement (wheel speed)
@ FR
Measurement of a sensor at the front-right (FR)
@ FL
Measurement of a sensor at the front-left (FL)
static constexpr uint16_t FP_B_MEASUREMENTS_MSGID
FP_B-MEASUREMENTS message ID.
static constexpr std::size_t FP_B_MEASUREMENTS_MEAS_SIZE
Size of FpbMeasurementsMeas.
constexpr std::underlying_type< T >::type EnumToVal(T enum_val)
Convert enum class constant to the underlying integral type value.
FP_B-MEASUREMENTS payload: head.
uint8_t num_meas
Number of measurements in the body (1..FP_B_MEASUREMENTS_MAX_NUM_MEAS)
FP_B-MEASUREMENTS payload: measurement.
uint8_t timestamp_type
See FpbMeasurementsTimestampType.
int32_t meas_y
Measurement y.
uint8_t meas_y_valid
Validity of measurement y (1 = meas_x contains valid data, 0 = data invalid or n/a)
uint8_t meas_z_valid
Validity of measurement z (1 = meas_x contains valid data, 0 = data invalid or n/a)
uint8_t meas_type
See FpbMeasurementsMeasType.
uint8_t meas_x_valid
Validity of measurement x (1 = meas_x contains valid data, 0 = data invalid or n/a)
int32_t meas_z
Measurement z.
int32_t meas_x
Measurement x.
uint8_t meas_loc
See FpbMeasurementsMeasLoc.
Fixposition SDK: Common types and type helpers.