Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_odometry.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE ODOMETRY PACKING
3
4#define MAVLINK_MSG_ID_ODOMETRY 331
5
6
7typedef struct __mavlink_odometry_t {
8 uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
9 float x; /*< [m] X Position*/
10 float y; /*< [m] Y Position*/
11 float z; /*< [m] Z Position*/
12 float q[4]; /*< Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)*/
13 float vx; /*< [m/s] X linear speed*/
14 float vy; /*< [m/s] Y linear speed*/
15 float vz; /*< [m/s] Z linear speed*/
16 float rollspeed; /*< [rad/s] Roll angular speed*/
17 float pitchspeed; /*< [rad/s] Pitch angular speed*/
18 float yawspeed; /*< [rad/s] Yaw angular speed*/
19 float pose_covariance[21]; /*< Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.*/
20 float velocity_covariance[21]; /*< Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.*/
21 uint8_t frame_id; /*< Coordinate frame of reference for the pose data.*/
22 uint8_t child_frame_id; /*< Coordinate frame of reference for the velocity in free space (twist) data.*/
23 uint8_t reset_counter; /*< Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.*/
24 uint8_t estimator_type; /*< Type of estimator that is providing the odometry.*/
25 int8_t quality; /*< [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality*/
26} mavlink_odometry_t;
27
28#define MAVLINK_MSG_ID_ODOMETRY_LEN 233
29#define MAVLINK_MSG_ID_ODOMETRY_MIN_LEN 230
30#define MAVLINK_MSG_ID_331_LEN 233
31#define MAVLINK_MSG_ID_331_MIN_LEN 230
32
33#define MAVLINK_MSG_ID_ODOMETRY_CRC 91
34#define MAVLINK_MSG_ID_331_CRC 91
35
36#define MAVLINK_MSG_ODOMETRY_FIELD_Q_LEN 4
37#define MAVLINK_MSG_ODOMETRY_FIELD_POSE_COVARIANCE_LEN 21
38#define MAVLINK_MSG_ODOMETRY_FIELD_VELOCITY_COVARIANCE_LEN 21
39
40#if MAVLINK_COMMAND_24BIT
41#define MAVLINK_MESSAGE_INFO_ODOMETRY {
42 331,
43 "ODOMETRY",
44 18,
45 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_odometry_t, time_usec) },
46 { "frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 228, offsetof(mavlink_odometry_t, frame_id) },
47 { "child_frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 229, offsetof(mavlink_odometry_t, child_frame_id) },
48 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_odometry_t, x) },
49 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_odometry_t, y) },
50 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_odometry_t, z) },
51 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 20, offsetof(mavlink_odometry_t, q) },
52 { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_odometry_t, vx) },
53 { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_odometry_t, vy) },
54 { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_odometry_t, vz) },
55 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_odometry_t, rollspeed) },
56 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_odometry_t, pitchspeed) },
57 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_odometry_t, yawspeed) },
58 { "pose_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 60, offsetof(mavlink_odometry_t, pose_covariance) },
59 { "velocity_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 144, offsetof(mavlink_odometry_t, velocity_covariance) },
60 { "reset_counter", NULL, MAVLINK_TYPE_UINT8_T, 0, 230, offsetof(mavlink_odometry_t, reset_counter) },
61 { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 231, offsetof(mavlink_odometry_t, estimator_type) },
62 { "quality", NULL, MAVLINK_TYPE_INT8_T, 0, 232, offsetof(mavlink_odometry_t, quality) },
63 } \
64}
65#else
66#define MAVLINK_MESSAGE_INFO_ODOMETRY {
67 "ODOMETRY",
68 18,
69 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_odometry_t, time_usec) },
70 { "frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 228, offsetof(mavlink_odometry_t, frame_id) },
71 { "child_frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 229, offsetof(mavlink_odometry_t, child_frame_id) },
72 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_odometry_t, x) },
73 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_odometry_t, y) },
74 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_odometry_t, z) },
75 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 20, offsetof(mavlink_odometry_t, q) },
76 { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_odometry_t, vx) },
77 { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_odometry_t, vy) },
78 { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_odometry_t, vz) },
79 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_odometry_t, rollspeed) },
80 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_odometry_t, pitchspeed) },
81 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_odometry_t, yawspeed) },
82 { "pose_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 60, offsetof(mavlink_odometry_t, pose_covariance) },
83 { "velocity_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 144, offsetof(mavlink_odometry_t, velocity_covariance) },
84 { "reset_counter", NULL, MAVLINK_TYPE_UINT8_T, 0, 230, offsetof(mavlink_odometry_t, reset_counter) },
85 { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 231, offsetof(mavlink_odometry_t, estimator_type) },
86 { "quality", NULL, MAVLINK_TYPE_INT8_T, 0, 232, offsetof(mavlink_odometry_t, quality) },
87 } \
88}
89#endif
90
91/**
92 * @brief Pack a odometry message
93 * @param system_id ID of this system
94 * @param component_id ID of this component (e.g. 200 for IMU)
95 * @param msg The MAVLink message to compress the data into
96 *
97 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
98 * @param frame_id Coordinate frame of reference for the pose data.
99 * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
100 * @param x [m] X Position
101 * @param y [m] Y Position
102 * @param z [m] Z Position
103 * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
104 * @param vx [m/s] X linear speed
105 * @param vy [m/s] Y linear speed
106 * @param vz [m/s] Z linear speed
107 * @param rollspeed [rad/s] Roll angular speed
108 * @param pitchspeed [rad/s] Pitch angular speed
109 * @param yawspeed [rad/s] Yaw angular speed
110 * @param pose_covariance Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
111 * @param velocity_covariance Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
112 * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.
113 * @param estimator_type Type of estimator that is providing the odometry.
114 * @param quality [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality
115 * @return length of the message in bytes (excluding serial stream start sign)
116 */
117static inline uint16_t mavlink_msg_odometry_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
118 uint64_t time_usec, uint8_t frame_id, uint8_t child_frame_id, float x, float y, float z, const float *q, float vx, float vy, float vz, float rollspeed, float pitchspeed, float yawspeed, const float *pose_covariance, const float *velocity_covariance, uint8_t reset_counter, uint8_t estimator_type, int8_t quality)
119{
120#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 _mav_put_uint64_t(buf, 0, time_usec);
123 _mav_put_float(buf, 8, x);
124 _mav_put_float(buf, 12, y);
125 _mav_put_float(buf, 16, z);
126 _mav_put_float(buf, 36, vx);
127 _mav_put_float(buf, 40, vy);
128 _mav_put_float(buf, 44, vz);
129 _mav_put_float(buf, 48, rollspeed);
130 _mav_put_float(buf, 52, pitchspeed);
131 _mav_put_float(buf, 56, yawspeed);
132 _mav_put_uint8_t(buf, 228, frame_id);
133 _mav_put_uint8_t(buf, 229, child_frame_id);
134 _mav_put_uint8_t(buf, 230, reset_counter);
135 _mav_put_uint8_t(buf, 231, estimator_type);
136 _mav_put_int8_t(buf, 232, quality);
137 _mav_put_float_array(buf, 20, q, 4);
138 _mav_put_float_array(buf, 60, pose_covariance, 21);
139 _mav_put_float_array(buf, 144, velocity_covariance, 21);
140 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN);
141#else
142 mavlink_odometry_t packet;
143 packet.time_usec = time_usec;
144 packet.x = x;
145 packet.y = y;
146 packet.z = z;
147 packet.vx = vx;
148 packet.vy = vy;
149 packet.vz = vz;
150 packet.rollspeed = rollspeed;
151 packet.pitchspeed = pitchspeed;
152 packet.yawspeed = yawspeed;
153 packet.frame_id = frame_id;
154 packet.child_frame_id = child_frame_id;
155 packet.reset_counter = reset_counter;
156 packet.estimator_type = estimator_type;
157 packet.quality = quality;
158 mav_array_memcpy(packet.q, q, sizeof(float)*4);
159 mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
160 mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
161 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN);
162#endif
163
164 msg->msgid = MAVLINK_MSG_ID_ODOMETRY;
165 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
166}
167
168/**
169 * @brief Pack a odometry message
170 * @param system_id ID of this system
171 * @param component_id ID of this component (e.g. 200 for IMU)
172 * @param status MAVLink status structure
173 * @param msg The MAVLink message to compress the data into
174 *
175 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
176 * @param frame_id Coordinate frame of reference for the pose data.
177 * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
178 * @param x [m] X Position
179 * @param y [m] Y Position
180 * @param z [m] Z Position
181 * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
182 * @param vx [m/s] X linear speed
183 * @param vy [m/s] Y linear speed
184 * @param vz [m/s] Z linear speed
185 * @param rollspeed [rad/s] Roll angular speed
186 * @param pitchspeed [rad/s] Pitch angular speed
187 * @param yawspeed [rad/s] Yaw angular speed
188 * @param pose_covariance Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
189 * @param velocity_covariance Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
190 * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.
191 * @param estimator_type Type of estimator that is providing the odometry.
192 * @param quality [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality
193 * @return length of the message in bytes (excluding serial stream start sign)
194 */
195static inline uint16_t mavlink_msg_odometry_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
196 uint64_t time_usec, uint8_t frame_id, uint8_t child_frame_id, float x, float y, float z, const float *q, float vx, float vy, float vz, float rollspeed, float pitchspeed, float yawspeed, const float *pose_covariance, const float *velocity_covariance, uint8_t reset_counter, uint8_t estimator_type, int8_t quality)
197{
198#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 _mav_put_uint64_t(buf, 0, time_usec);
201 _mav_put_float(buf, 8, x);
202 _mav_put_float(buf, 12, y);
203 _mav_put_float(buf, 16, z);
204 _mav_put_float(buf, 36, vx);
205 _mav_put_float(buf, 40, vy);
206 _mav_put_float(buf, 44, vz);
207 _mav_put_float(buf, 48, rollspeed);
208 _mav_put_float(buf, 52, pitchspeed);
209 _mav_put_float(buf, 56, yawspeed);
210 _mav_put_uint8_t(buf, 228, frame_id);
211 _mav_put_uint8_t(buf, 229, child_frame_id);
212 _mav_put_uint8_t(buf, 230, reset_counter);
213 _mav_put_uint8_t(buf, 231, estimator_type);
214 _mav_put_int8_t(buf, 232, quality);
215 _mav_put_float_array(buf, 20, q, 4);
216 _mav_put_float_array(buf, 60, pose_covariance, 21);
217 _mav_put_float_array(buf, 144, velocity_covariance, 21);
218 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN);
219#else
220 mavlink_odometry_t packet;
221 packet.time_usec = time_usec;
222 packet.x = x;
223 packet.y = y;
224 packet.z = z;
225 packet.vx = vx;
226 packet.vy = vy;
227 packet.vz = vz;
228 packet.rollspeed = rollspeed;
229 packet.pitchspeed = pitchspeed;
230 packet.yawspeed = yawspeed;
231 packet.frame_id = frame_id;
232 packet.child_frame_id = child_frame_id;
233 packet.reset_counter = reset_counter;
234 packet.estimator_type = estimator_type;
235 packet.quality = quality;
236 mav_array_memcpy(packet.q, q, sizeof(float)*4);
237 mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
238 mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
239 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN);
240#endif
241
242 msg->msgid = MAVLINK_MSG_ID_ODOMETRY;
243#if MAVLINK_CRC_EXTRA
244 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
245#else
246 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN);
247#endif
248}
249
250/**
251 * @brief Pack a odometry message on a channel
252 * @param system_id ID of this system
253 * @param component_id ID of this component (e.g. 200 for IMU)
254 * @param chan The MAVLink channel this message will be sent over
255 * @param msg The MAVLink message to compress the data into
256 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
257 * @param frame_id Coordinate frame of reference for the pose data.
258 * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
259 * @param x [m] X Position
260 * @param y [m] Y Position
261 * @param z [m] Z Position
262 * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
263 * @param vx [m/s] X linear speed
264 * @param vy [m/s] Y linear speed
265 * @param vz [m/s] Z linear speed
266 * @param rollspeed [rad/s] Roll angular speed
267 * @param pitchspeed [rad/s] Pitch angular speed
268 * @param yawspeed [rad/s] Yaw angular speed
269 * @param pose_covariance Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
270 * @param velocity_covariance Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
271 * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.
272 * @param estimator_type Type of estimator that is providing the odometry.
273 * @param quality [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality
274 * @return length of the message in bytes (excluding serial stream start sign)
275 */
276static inline uint16_t mavlink_msg_odometry_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
277 mavlink_message_t* msg,
278 uint64_t time_usec,uint8_t frame_id,uint8_t child_frame_id,float x,float y,float z,const float *q,float vx,float vy,float vz,float rollspeed,float pitchspeed,float yawspeed,const float *pose_covariance,const float *velocity_covariance,uint8_t reset_counter,uint8_t estimator_type,int8_t quality)
279{
280#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
282 _mav_put_uint64_t(buf, 0, time_usec);
283 _mav_put_float(buf, 8, x);
284 _mav_put_float(buf, 12, y);
285 _mav_put_float(buf, 16, z);
286 _mav_put_float(buf, 36, vx);
287 _mav_put_float(buf, 40, vy);
288 _mav_put_float(buf, 44, vz);
289 _mav_put_float(buf, 48, rollspeed);
290 _mav_put_float(buf, 52, pitchspeed);
291 _mav_put_float(buf, 56, yawspeed);
292 _mav_put_uint8_t(buf, 228, frame_id);
293 _mav_put_uint8_t(buf, 229, child_frame_id);
294 _mav_put_uint8_t(buf, 230, reset_counter);
295 _mav_put_uint8_t(buf, 231, estimator_type);
296 _mav_put_int8_t(buf, 232, quality);
297 _mav_put_float_array(buf, 20, q, 4);
298 _mav_put_float_array(buf, 60, pose_covariance, 21);
299 _mav_put_float_array(buf, 144, velocity_covariance, 21);
300 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN);
301#else
302 mavlink_odometry_t packet;
303 packet.time_usec = time_usec;
304 packet.x = x;
305 packet.y = y;
306 packet.z = z;
307 packet.vx = vx;
308 packet.vy = vy;
309 packet.vz = vz;
310 packet.rollspeed = rollspeed;
311 packet.pitchspeed = pitchspeed;
312 packet.yawspeed = yawspeed;
313 packet.frame_id = frame_id;
314 packet.child_frame_id = child_frame_id;
315 packet.reset_counter = reset_counter;
316 packet.estimator_type = estimator_type;
317 packet.quality = quality;
318 mav_array_memcpy(packet.q, q, sizeof(float)*4);
319 mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
320 mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
321 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN);
322#endif
323
324 msg->msgid = MAVLINK_MSG_ID_ODOMETRY;
325 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
326}
327
328/**
329 * @brief Encode a odometry struct
330 *
331 * @param system_id ID of this system
332 * @param component_id ID of this component (e.g. 200 for IMU)
333 * @param msg The MAVLink message to compress the data into
334 * @param odometry C-struct to read the message contents from
335 */
336static inline uint16_t mavlink_msg_odometry_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_odometry_t* odometry)
337{
338 return mavlink_msg_odometry_pack(system_id, component_id, msg, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality);
339}
340
341/**
342 * @brief Encode a odometry struct on a channel
343 *
344 * @param system_id ID of this system
345 * @param component_id ID of this component (e.g. 200 for IMU)
346 * @param chan The MAVLink channel this message will be sent over
347 * @param msg The MAVLink message to compress the data into
348 * @param odometry C-struct to read the message contents from
349 */
350static inline uint16_t mavlink_msg_odometry_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_odometry_t* odometry)
351{
352 return mavlink_msg_odometry_pack_chan(system_id, component_id, chan, msg, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality);
353}
354
355/**
356 * @brief Encode a odometry struct with provided status structure
357 *
358 * @param system_id ID of this system
359 * @param component_id ID of this component (e.g. 200 for IMU)
360 * @param status MAVLink status structure
361 * @param msg The MAVLink message to compress the data into
362 * @param odometry C-struct to read the message contents from
363 */
364static inline uint16_t mavlink_msg_odometry_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_odometry_t* odometry)
365{
366 return mavlink_msg_odometry_pack_status(system_id, component_id, _status, msg, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality);
367}
368
369/**
370 * @brief Send a odometry message
371 * @param chan MAVLink channel to send the message
372 *
373 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
374 * @param frame_id Coordinate frame of reference for the pose data.
375 * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
376 * @param x [m] X Position
377 * @param y [m] Y Position
378 * @param z [m] Z Position
379 * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
380 * @param vx [m/s] X linear speed
381 * @param vy [m/s] Y linear speed
382 * @param vz [m/s] Z linear speed
383 * @param rollspeed [rad/s] Roll angular speed
384 * @param pitchspeed [rad/s] Pitch angular speed
385 * @param yawspeed [rad/s] Yaw angular speed
386 * @param pose_covariance Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
387 * @param velocity_covariance Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
388 * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.
389 * @param estimator_type Type of estimator that is providing the odometry.
390 * @param quality [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality
391 */
392#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
393
394static inline void mavlink_msg_odometry_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t frame_id, uint8_t child_frame_id, float x, float y, float z, const float *q, float vx, float vy, float vz, float rollspeed, float pitchspeed, float yawspeed, const float *pose_covariance, const float *velocity_covariance, uint8_t reset_counter, uint8_t estimator_type, int8_t quality)
395{
396#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
397 char buf[MAVLINK_MSG_ID_ODOMETRY_LEN];
398 _mav_put_uint64_t(buf, 0, time_usec);
399 _mav_put_float(buf, 8, x);
400 _mav_put_float(buf, 12, y);
401 _mav_put_float(buf, 16, z);
402 _mav_put_float(buf, 36, vx);
403 _mav_put_float(buf, 40, vy);
404 _mav_put_float(buf, 44, vz);
405 _mav_put_float(buf, 48, rollspeed);
406 _mav_put_float(buf, 52, pitchspeed);
407 _mav_put_float(buf, 56, yawspeed);
408 _mav_put_uint8_t(buf, 228, frame_id);
409 _mav_put_uint8_t(buf, 229, child_frame_id);
410 _mav_put_uint8_t(buf, 230, reset_counter);
411 _mav_put_uint8_t(buf, 231, estimator_type);
412 _mav_put_int8_t(buf, 232, quality);
413 _mav_put_float_array(buf, 20, q, 4);
414 _mav_put_float_array(buf, 60, pose_covariance, 21);
415 _mav_put_float_array(buf, 144, velocity_covariance, 21);
416 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ODOMETRY, buf, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
417#else
418 mavlink_odometry_t packet;
419 packet.time_usec = time_usec;
420 packet.x = x;
421 packet.y = y;
422 packet.z = z;
423 packet.vx = vx;
424 packet.vy = vy;
425 packet.vz = vz;
426 packet.rollspeed = rollspeed;
427 packet.pitchspeed = pitchspeed;
428 packet.yawspeed = yawspeed;
429 packet.frame_id = frame_id;
430 packet.child_frame_id = child_frame_id;
431 packet.reset_counter = reset_counter;
432 packet.estimator_type = estimator_type;
433 packet.quality = quality;
434 mav_array_memcpy(packet.q, q, sizeof(float)*4);
435 mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
436 mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
437 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ODOMETRY, (const char *)&packet, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
438#endif
439}
440
441/**
442 * @brief Send a odometry message
443 * @param chan MAVLink channel to send the message
444 * @param struct The MAVLink struct to serialize
445 */
446static inline void mavlink_msg_odometry_send_struct(mavlink_channel_t chan, const mavlink_odometry_t* odometry)
447{
448#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
449 mavlink_msg_odometry_send(chan, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality);
450#else
451 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ODOMETRY, (const char *)odometry, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
452#endif
453}
454
455#if MAVLINK_MSG_ID_ODOMETRY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
456/*
457 This variant of _send() can be used to save stack space by reusing
458 memory from the receive buffer. The caller provides a
459 mavlink_message_t which is the size of a full mavlink message. This
460 is usually the receive buffer for the channel, and allows a reply to an
461 incoming message with minimum stack space usage.
462 */
463static inline void mavlink_msg_odometry_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t frame_id, uint8_t child_frame_id, float x, float y, float z, const float *q, float vx, float vy, float vz, float rollspeed, float pitchspeed, float yawspeed, const float *pose_covariance, const float *velocity_covariance, uint8_t reset_counter, uint8_t estimator_type, int8_t quality)
464{
465#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
466 char *buf = (char *)msgbuf;
467 _mav_put_uint64_t(buf, 0, time_usec);
468 _mav_put_float(buf, 8, x);
469 _mav_put_float(buf, 12, y);
470 _mav_put_float(buf, 16, z);
471 _mav_put_float(buf, 36, vx);
472 _mav_put_float(buf, 40, vy);
473 _mav_put_float(buf, 44, vz);
474 _mav_put_float(buf, 48, rollspeed);
475 _mav_put_float(buf, 52, pitchspeed);
476 _mav_put_float(buf, 56, yawspeed);
477 _mav_put_uint8_t(buf, 228, frame_id);
478 _mav_put_uint8_t(buf, 229, child_frame_id);
479 _mav_put_uint8_t(buf, 230, reset_counter);
480 _mav_put_uint8_t(buf, 231, estimator_type);
481 _mav_put_int8_t(buf, 232, quality);
482 _mav_put_float_array(buf, 20, q, 4);
483 _mav_put_float_array(buf, 60, pose_covariance, 21);
484 _mav_put_float_array(buf, 144, velocity_covariance, 21);
485 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ODOMETRY, buf, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
486#else
487 mavlink_odometry_t *packet = (mavlink_odometry_t *)msgbuf;
488 packet->time_usec = time_usec;
489 packet->x = x;
490 packet->y = y;
491 packet->z = z;
492 packet->vx = vx;
493 packet->vy = vy;
494 packet->vz = vz;
495 packet->rollspeed = rollspeed;
496 packet->pitchspeed = pitchspeed;
497 packet->yawspeed = yawspeed;
498 packet->frame_id = frame_id;
499 packet->child_frame_id = child_frame_id;
500 packet->reset_counter = reset_counter;
501 packet->estimator_type = estimator_type;
502 packet->quality = quality;
503 mav_array_memcpy(packet->q, q, sizeof(float)*4);
504 mav_array_memcpy(packet->pose_covariance, pose_covariance, sizeof(float)*21);
505 mav_array_memcpy(packet->velocity_covariance, velocity_covariance, sizeof(float)*21);
506 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ODOMETRY, (const char *)packet, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC);
507#endif
508}
509#endif
510
511#endif
512
513// MESSAGE ODOMETRY UNPACKING
514
515
516/**
517 * @brief Get field time_usec from odometry message
518 *
519 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
520 */
521static inline uint64_t mavlink_msg_odometry_get_time_usec(const mavlink_message_t* msg)
522{
523 return _MAV_RETURN_uint64_t(msg, 0);
524}
525
526/**
527 * @brief Get field frame_id from odometry message
528 *
529 * @return Coordinate frame of reference for the pose data.
530 */
531static inline uint8_t mavlink_msg_odometry_get_frame_id(const mavlink_message_t* msg)
532{
533 return _MAV_RETURN_uint8_t(msg, 228);
534}
535
536/**
537 * @brief Get field child_frame_id from odometry message
538 *
539 * @return Coordinate frame of reference for the velocity in free space (twist) data.
540 */
541static inline uint8_t mavlink_msg_odometry_get_child_frame_id(const mavlink_message_t* msg)
542{
543 return _MAV_RETURN_uint8_t(msg, 229);
544}
545
546/**
547 * @brief Get field x from odometry message
548 *
549 * @return [m] X Position
550 */
551static inline float mavlink_msg_odometry_get_x(const mavlink_message_t* msg)
552{
553 return _MAV_RETURN_float(msg, 8);
554}
555
556/**
557 * @brief Get field y from odometry message
558 *
559 * @return [m] Y Position
560 */
561static inline float mavlink_msg_odometry_get_y(const mavlink_message_t* msg)
562{
563 return _MAV_RETURN_float(msg, 12);
564}
565
566/**
567 * @brief Get field z from odometry message
568 *
569 * @return [m] Z Position
570 */
571static inline float mavlink_msg_odometry_get_z(const mavlink_message_t* msg)
572{
573 return _MAV_RETURN_float(msg, 16);
574}
575
576/**
577 * @brief Get field q from odometry message
578 *
579 * @return Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
580 */
581static inline uint16_t mavlink_msg_odometry_get_q(const mavlink_message_t* msg, float *q)
582{
583 return _MAV_RETURN_float_array(msg, q, 4, 20);
584}
585
586/**
587 * @brief Get field vx from odometry message
588 *
589 * @return [m/s] X linear speed
590 */
591static inline float mavlink_msg_odometry_get_vx(const mavlink_message_t* msg)
592{
593 return _MAV_RETURN_float(msg, 36);
594}
595
596/**
597 * @brief Get field vy from odometry message
598 *
599 * @return [m/s] Y linear speed
600 */
601static inline float mavlink_msg_odometry_get_vy(const mavlink_message_t* msg)
602{
603 return _MAV_RETURN_float(msg, 40);
604}
605
606/**
607 * @brief Get field vz from odometry message
608 *
609 * @return [m/s] Z linear speed
610 */
611static inline float mavlink_msg_odometry_get_vz(const mavlink_message_t* msg)
612{
613 return _MAV_RETURN_float(msg, 44);
614}
615
616/**
617 * @brief Get field rollspeed from odometry message
618 *
619 * @return [rad/s] Roll angular speed
620 */
621static inline float mavlink_msg_odometry_get_rollspeed(const mavlink_message_t* msg)
622{
623 return _MAV_RETURN_float(msg, 48);
624}
625
626/**
627 * @brief Get field pitchspeed from odometry message
628 *
629 * @return [rad/s] Pitch angular speed
630 */
631static inline float mavlink_msg_odometry_get_pitchspeed(const mavlink_message_t* msg)
632{
633 return _MAV_RETURN_float(msg, 52);
634}
635
636/**
637 * @brief Get field yawspeed from odometry message
638 *
639 * @return [rad/s] Yaw angular speed
640 */
641static inline float mavlink_msg_odometry_get_yawspeed(const mavlink_message_t* msg)
642{
643 return _MAV_RETURN_float(msg, 56);
644}
645
646/**
647 * @brief Get field pose_covariance from odometry message
648 *
649 * @return Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
650 */
651static inline uint16_t mavlink_msg_odometry_get_pose_covariance(const mavlink_message_t* msg, float *pose_covariance)
652{
653 return _MAV_RETURN_float_array(msg, pose_covariance, 21, 60);
654}
655
656/**
657 * @brief Get field velocity_covariance from odometry message
658 *
659 * @return Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
660 */
661static inline uint16_t mavlink_msg_odometry_get_velocity_covariance(const mavlink_message_t* msg, float *velocity_covariance)
662{
663 return _MAV_RETURN_float_array(msg, velocity_covariance, 21, 144);
664}
665
666/**
667 * @brief Get field reset_counter from odometry message
668 *
669 * @return Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps.
670 */
671static inline uint8_t mavlink_msg_odometry_get_reset_counter(const mavlink_message_t* msg)
672{
673 return _MAV_RETURN_uint8_t(msg, 230);
674}
675
676/**
677 * @brief Get field estimator_type from odometry message
678 *
679 * @return Type of estimator that is providing the odometry.
680 */
681static inline uint8_t mavlink_msg_odometry_get_estimator_type(const mavlink_message_t* msg)
682{
683 return _MAV_RETURN_uint8_t(msg, 231);
684}
685
686/**
687 * @brief Get field quality from odometry message
688 *
689 * @return [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality
690 */
691static inline int8_t mavlink_msg_odometry_get_quality(const mavlink_message_t* msg)
692{
693 return _MAV_RETURN_int8_t(msg, 232);
694}
695
696/**
697 * @brief Decode a odometry message into a struct
698 *
699 * @param msg The message to decode
700 * @param odometry C-struct to decode the message contents into
701 */
702static inline void mavlink_msg_odometry_decode(const mavlink_message_t* msg, mavlink_odometry_t* odometry)
703{
704#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
705 odometry->time_usec = mavlink_msg_odometry_get_time_usec(msg);
706 odometry->x = mavlink_msg_odometry_get_x(msg);
707 odometry->y = mavlink_msg_odometry_get_y(msg);
708 odometry->z = mavlink_msg_odometry_get_z(msg);
709 mavlink_msg_odometry_get_q(msg, odometry->q);
710 odometry->vx = mavlink_msg_odometry_get_vx(msg);
711 odometry->vy = mavlink_msg_odometry_get_vy(msg);
712 odometry->vz = mavlink_msg_odometry_get_vz(msg);
713 odometry->rollspeed = mavlink_msg_odometry_get_rollspeed(msg);
714 odometry->pitchspeed = mavlink_msg_odometry_get_pitchspeed(msg);
715 odometry->yawspeed = mavlink_msg_odometry_get_yawspeed(msg);
716 mavlink_msg_odometry_get_pose_covariance(msg, odometry->pose_covariance);
717 mavlink_msg_odometry_get_velocity_covariance(msg, odometry->velocity_covariance);
718 odometry->frame_id = mavlink_msg_odometry_get_frame_id(msg);
719 odometry->child_frame_id = mavlink_msg_odometry_get_child_frame_id(msg);
720 odometry->reset_counter = mavlink_msg_odometry_get_reset_counter(msg);
721 odometry->estimator_type = mavlink_msg_odometry_get_estimator_type(msg);
722 odometry->quality = mavlink_msg_odometry_get_quality(msg);
723#else
724 uint8_t len = msg->len < MAVLINK_MSG_ID_ODOMETRY_LEN? msg->len : MAVLINK_MSG_ID_ODOMETRY_LEN;
725 memset(odometry, 0, MAVLINK_MSG_ID_ODOMETRY_LEN);
726 memcpy(odometry, _MAV_PAYLOAD(msg), len);
727#endif
728}