Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_wheel_distance.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE WHEEL_DISTANCE PACKING
3
4#define MAVLINK_MSG_ID_WHEEL_DISTANCE 9000
5
6
8 uint64_t time_usec; /*< [us] Timestamp (synced to UNIX time or since system boot).*/
9 double distance[16]; /*< [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.*/
10 uint8_t count; /*< Number of wheels reported.*/
11} mavlink_wheel_distance_t;
12
13#define MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN 137
14#define MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN 137
15#define MAVLINK_MSG_ID_9000_LEN 137
16#define MAVLINK_MSG_ID_9000_MIN_LEN 137
17
18#define MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC 113
19#define MAVLINK_MSG_ID_9000_CRC 113
20
21#define MAVLINK_MSG_WHEEL_DISTANCE_FIELD_DISTANCE_LEN 16
22
23#if MAVLINK_COMMAND_24BIT
24#define MAVLINK_MESSAGE_INFO_WHEEL_DISTANCE {
25 9000,
26 "WHEEL_DISTANCE",
27 3,
28 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_wheel_distance_t, time_usec) },
29 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 136, offsetof(mavlink_wheel_distance_t, count) },
30 { "distance", NULL, MAVLINK_TYPE_DOUBLE, 16, 8, offsetof(mavlink_wheel_distance_t, distance) },
31 } \
32}
33#else
34#define MAVLINK_MESSAGE_INFO_WHEEL_DISTANCE {
35 "WHEEL_DISTANCE",
36 3,
37 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_wheel_distance_t, time_usec) },
38 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 136, offsetof(mavlink_wheel_distance_t, count) },
39 { "distance", NULL, MAVLINK_TYPE_DOUBLE, 16, 8, offsetof(mavlink_wheel_distance_t, distance) },
40 } \
41}
42#endif
43
44/**
45 * @brief Pack a wheel_distance message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
49 *
50 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
51 * @param count Number of wheels reported.
52 * @param distance [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.
53 * @return length of the message in bytes (excluding serial stream start sign)
54 */
55static inline uint16_t mavlink_msg_wheel_distance_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
56 uint64_t time_usec, uint8_t count, const double *distance)
57{
58#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 _mav_put_uint64_t(buf, 0, time_usec);
61 _mav_put_uint8_t(buf, 136, count);
62 _mav_put_double_array(buf, 8, distance, 16);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
64#else
65 mavlink_wheel_distance_t packet;
66 packet.time_usec = time_usec;
67 packet.count = count;
68 mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
69 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
70#endif
71
73 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
74}
75
76/**
77 * @brief Pack a wheel_distance message
78 * @param system_id ID of this system
79 * @param component_id ID of this component (e.g. 200 for IMU)
80 * @param status MAVLink status structure
81 * @param msg The MAVLink message to compress the data into
82 *
83 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
84 * @param count Number of wheels reported.
85 * @param distance [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.
86 * @return length of the message in bytes (excluding serial stream start sign)
87 */
88static inline uint16_t mavlink_msg_wheel_distance_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
89 uint64_t time_usec, uint8_t count, const double *distance)
90{
91#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
93 _mav_put_uint64_t(buf, 0, time_usec);
94 _mav_put_uint8_t(buf, 136, count);
95 _mav_put_double_array(buf, 8, distance, 16);
96 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
97#else
98 mavlink_wheel_distance_t packet;
99 packet.time_usec = time_usec;
100 packet.count = count;
101 mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
102 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
103#endif
104
106#if MAVLINK_CRC_EXTRA
107 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
108#else
109 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
110#endif
111}
112
113/**
114 * @brief Pack a wheel_distance message on a channel
115 * @param system_id ID of this system
116 * @param component_id ID of this component (e.g. 200 for IMU)
117 * @param chan The MAVLink channel this message will be sent over
118 * @param msg The MAVLink message to compress the data into
119 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
120 * @param count Number of wheels reported.
121 * @param distance [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.
122 * @return length of the message in bytes (excluding serial stream start sign)
123 */
124static inline uint16_t mavlink_msg_wheel_distance_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
125 mavlink_message_t* msg,
126 uint64_t time_usec,uint8_t count,const double *distance)
127{
128#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
130 _mav_put_uint64_t(buf, 0, time_usec);
131 _mav_put_uint8_t(buf, 136, count);
132 _mav_put_double_array(buf, 8, distance, 16);
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
134#else
135 mavlink_wheel_distance_t packet;
136 packet.time_usec = time_usec;
137 packet.count = count;
138 mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
139 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
140#endif
141
143 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
144}
145
146/**
147 * @brief Encode a wheel_distance struct
148 *
149 * @param system_id ID of this system
150 * @param component_id ID of this component (e.g. 200 for IMU)
151 * @param msg The MAVLink message to compress the data into
152 * @param wheel_distance C-struct to read the message contents from
153 */
154static inline uint16_t mavlink_msg_wheel_distance_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_wheel_distance_t* wheel_distance)
155{
156 return mavlink_msg_wheel_distance_pack(system_id, component_id, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
157}
158
159/**
160 * @brief Encode a wheel_distance struct on a channel
161 *
162 * @param system_id ID of this system
163 * @param component_id ID of this component (e.g. 200 for IMU)
164 * @param chan The MAVLink channel this message will be sent over
165 * @param msg The MAVLink message to compress the data into
166 * @param wheel_distance C-struct to read the message contents from
167 */
168static inline uint16_t mavlink_msg_wheel_distance_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_wheel_distance_t* wheel_distance)
169{
170 return mavlink_msg_wheel_distance_pack_chan(system_id, component_id, chan, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
171}
172
173/**
174 * @brief Encode a wheel_distance struct with provided status structure
175 *
176 * @param system_id ID of this system
177 * @param component_id ID of this component (e.g. 200 for IMU)
178 * @param status MAVLink status structure
179 * @param msg The MAVLink message to compress the data into
180 * @param wheel_distance C-struct to read the message contents from
181 */
182static inline uint16_t mavlink_msg_wheel_distance_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wheel_distance_t* wheel_distance)
183{
184 return mavlink_msg_wheel_distance_pack_status(system_id, component_id, _status, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
185}
186
187/**
188 * @brief Send a wheel_distance message
189 * @param chan MAVLink channel to send the message
190 *
191 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
192 * @param count Number of wheels reported.
193 * @param distance [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.
194 */
195#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
196
197static inline void mavlink_msg_wheel_distance_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t count, const double *distance)
198{
199#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char buf[MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN];
201 _mav_put_uint64_t(buf, 0, time_usec);
202 _mav_put_uint8_t(buf, 136, count);
203 _mav_put_double_array(buf, 8, distance, 16);
204 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WHEEL_DISTANCE, buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
205#else
206 mavlink_wheel_distance_t packet;
207 packet.time_usec = time_usec;
208 packet.count = count;
209 mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
210 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WHEEL_DISTANCE, (const char *)&packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
211#endif
212}
213
214/**
215 * @brief Send a wheel_distance message
216 * @param chan MAVLink channel to send the message
217 * @param struct The MAVLink struct to serialize
218 */
219static inline void mavlink_msg_wheel_distance_send_struct(mavlink_channel_t chan, const mavlink_wheel_distance_t* wheel_distance)
220{
221#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
222 mavlink_msg_wheel_distance_send(chan, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
223#else
224 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WHEEL_DISTANCE, (const char *)wheel_distance, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
225#endif
226}
227
228#if MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
229/*
230 This variant of _send() can be used to save stack space by reusing
231 memory from the receive buffer. The caller provides a
232 mavlink_message_t which is the size of a full mavlink message. This
233 is usually the receive buffer for the channel, and allows a reply to an
234 incoming message with minimum stack space usage.
235 */
236static inline void mavlink_msg_wheel_distance_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t count, const double *distance)
237{
238#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
239 char *buf = (char *)msgbuf;
240 _mav_put_uint64_t(buf, 0, time_usec);
241 _mav_put_uint8_t(buf, 136, count);
242 _mav_put_double_array(buf, 8, distance, 16);
243 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WHEEL_DISTANCE, buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
244#else
245 mavlink_wheel_distance_t *packet = (mavlink_wheel_distance_t *)msgbuf;
246 packet->time_usec = time_usec;
247 packet->count = count;
248 mav_array_memcpy(packet->distance, distance, sizeof(double)*16);
249 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WHEEL_DISTANCE, (const char *)packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC);
250#endif
251}
252#endif
253
254#endif
255
256// MESSAGE WHEEL_DISTANCE UNPACKING
257
258
259/**
260 * @brief Get field time_usec from wheel_distance message
261 *
262 * @return [us] Timestamp (synced to UNIX time or since system boot).
263 */
264static inline uint64_t mavlink_msg_wheel_distance_get_time_usec(const mavlink_message_t* msg)
265{
266 return _MAV_RETURN_uint64_t(msg, 0);
267}
268
269/**
270 * @brief Get field count from wheel_distance message
271 *
272 * @return Number of wheels reported.
273 */
274static inline uint8_t mavlink_msg_wheel_distance_get_count(const mavlink_message_t* msg)
275{
276 return _MAV_RETURN_uint8_t(msg, 136);
277}
278
279/**
280 * @brief Get field distance from wheel_distance message
281 *
282 * @return [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints.
283 */
284static inline uint16_t mavlink_msg_wheel_distance_get_distance(const mavlink_message_t* msg, double *distance)
285{
286 return _MAV_RETURN_double_array(msg, distance, 16, 8);
287}
288
289/**
290 * @brief Decode a wheel_distance message into a struct
291 *
292 * @param msg The message to decode
293 * @param wheel_distance C-struct to decode the message contents into
294 */
295static inline void mavlink_msg_wheel_distance_decode(const mavlink_message_t* msg, mavlink_wheel_distance_t* wheel_distance)
296{
297#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
298 wheel_distance->time_usec = mavlink_msg_wheel_distance_get_time_usec(msg);
299 mavlink_msg_wheel_distance_get_distance(msg, wheel_distance->distance);
300 wheel_distance->count = mavlink_msg_wheel_distance_get_count(msg);
301#else
302 uint8_t len = msg->len < MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN? msg->len : MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN;
303 memset(wheel_distance, 0, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
304 memcpy(wheel_distance, _MAV_PAYLOAD(msg), len);
305#endif
306}