You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
12 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE WHEEL_DISTANCE PACKING
  3. #define MAVLINK_MSG_ID_WHEEL_DISTANCE 9000
  4. MAVPACKED(
  5. typedef struct __mavlink_wheel_distance_t {
  6. uint64_t time_usec; /*< [us] Timestamp (synced to UNIX time or since system boot).*/
  7. 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.*/
  8. uint8_t count; /*< Number of wheels reported.*/
  9. }) mavlink_wheel_distance_t;
  10. #define MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN 137
  11. #define MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN 137
  12. #define MAVLINK_MSG_ID_9000_LEN 137
  13. #define MAVLINK_MSG_ID_9000_MIN_LEN 137
  14. #define MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC 113
  15. #define MAVLINK_MSG_ID_9000_CRC 113
  16. #define MAVLINK_MSG_WHEEL_DISTANCE_FIELD_DISTANCE_LEN 16
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_WHEEL_DISTANCE { \
  19. 9000, \
  20. "WHEEL_DISTANCE", \
  21. 3, \
  22. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_wheel_distance_t, time_usec) }, \
  23. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 136, offsetof(mavlink_wheel_distance_t, count) }, \
  24. { "distance", NULL, MAVLINK_TYPE_DOUBLE, 16, 8, offsetof(mavlink_wheel_distance_t, distance) }, \
  25. } \
  26. }
  27. #else
  28. #define MAVLINK_MESSAGE_INFO_WHEEL_DISTANCE { \
  29. "WHEEL_DISTANCE", \
  30. 3, \
  31. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_wheel_distance_t, time_usec) }, \
  32. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 136, offsetof(mavlink_wheel_distance_t, count) }, \
  33. { "distance", NULL, MAVLINK_TYPE_DOUBLE, 16, 8, offsetof(mavlink_wheel_distance_t, distance) }, \
  34. } \
  35. }
  36. #endif
  37. /**
  38. * @brief Pack a wheel_distance message
  39. * @param system_id ID of this system
  40. * @param component_id ID of this component (e.g. 200 for IMU)
  41. * @param msg The MAVLink message to compress the data into
  42. *
  43. * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
  44. * @param count Number of wheels reported.
  45. * @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.
  46. * @return length of the message in bytes (excluding serial stream start sign)
  47. */
  48. static inline uint16_t mavlink_msg_wheel_distance_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  49. uint64_t time_usec, uint8_t count, const double *distance)
  50. {
  51. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  52. char buf[MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN];
  53. _mav_put_uint64_t(buf, 0, time_usec);
  54. _mav_put_uint8_t(buf, 136, count);
  55. _mav_put_double_array(buf, 8, distance, 16);
  56. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
  57. #else
  58. mavlink_wheel_distance_t packet;
  59. packet.time_usec = time_usec;
  60. packet.count = count;
  61. mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
  62. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
  63. #endif
  64. msg->msgid = MAVLINK_MSG_ID_WHEEL_DISTANCE;
  65. 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);
  66. }
  67. /**
  68. * @brief Pack a wheel_distance message on a channel
  69. * @param system_id ID of this system
  70. * @param component_id ID of this component (e.g. 200 for IMU)
  71. * @param chan The MAVLink channel this message will be sent over
  72. * @param msg The MAVLink message to compress the data into
  73. * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
  74. * @param count Number of wheels reported.
  75. * @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.
  76. * @return length of the message in bytes (excluding serial stream start sign)
  77. */
  78. static inline uint16_t mavlink_msg_wheel_distance_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  79. mavlink_message_t* msg,
  80. uint64_t time_usec,uint8_t count,const double *distance)
  81. {
  82. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  83. char buf[MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN];
  84. _mav_put_uint64_t(buf, 0, time_usec);
  85. _mav_put_uint8_t(buf, 136, count);
  86. _mav_put_double_array(buf, 8, distance, 16);
  87. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
  88. #else
  89. mavlink_wheel_distance_t packet;
  90. packet.time_usec = time_usec;
  91. packet.count = count;
  92. mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
  93. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
  94. #endif
  95. msg->msgid = MAVLINK_MSG_ID_WHEEL_DISTANCE;
  96. 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);
  97. }
  98. /**
  99. * @brief Encode a wheel_distance struct
  100. *
  101. * @param system_id ID of this system
  102. * @param component_id ID of this component (e.g. 200 for IMU)
  103. * @param msg The MAVLink message to compress the data into
  104. * @param wheel_distance C-struct to read the message contents from
  105. */
  106. static 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)
  107. {
  108. return mavlink_msg_wheel_distance_pack(system_id, component_id, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
  109. }
  110. /**
  111. * @brief Encode a wheel_distance struct on a channel
  112. *
  113. * @param system_id ID of this system
  114. * @param component_id ID of this component (e.g. 200 for IMU)
  115. * @param chan The MAVLink channel this message will be sent over
  116. * @param msg The MAVLink message to compress the data into
  117. * @param wheel_distance C-struct to read the message contents from
  118. */
  119. static 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)
  120. {
  121. return mavlink_msg_wheel_distance_pack_chan(system_id, component_id, chan, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
  122. }
  123. /**
  124. * @brief Send a wheel_distance message
  125. * @param chan MAVLink channel to send the message
  126. *
  127. * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
  128. * @param count Number of wheels reported.
  129. * @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.
  130. */
  131. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  132. static inline void mavlink_msg_wheel_distance_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t count, const double *distance)
  133. {
  134. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  135. char buf[MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN];
  136. _mav_put_uint64_t(buf, 0, time_usec);
  137. _mav_put_uint8_t(buf, 136, count);
  138. _mav_put_double_array(buf, 8, distance, 16);
  139. _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);
  140. #else
  141. mavlink_wheel_distance_t packet;
  142. packet.time_usec = time_usec;
  143. packet.count = count;
  144. mav_array_memcpy(packet.distance, distance, sizeof(double)*16);
  145. _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);
  146. #endif
  147. }
  148. /**
  149. * @brief Send a wheel_distance message
  150. * @param chan MAVLink channel to send the message
  151. * @param struct The MAVLink struct to serialize
  152. */
  153. static inline void mavlink_msg_wheel_distance_send_struct(mavlink_channel_t chan, const mavlink_wheel_distance_t* wheel_distance)
  154. {
  155. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  156. mavlink_msg_wheel_distance_send(chan, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance);
  157. #else
  158. _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);
  159. #endif
  160. }
  161. #if MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  162. /*
  163. This varient of _send() can be used to save stack space by re-using
  164. memory from the receive buffer. The caller provides a
  165. mavlink_message_t which is the size of a full mavlink message. This
  166. is usually the receive buffer for the channel, and allows a reply to an
  167. incoming message with minimum stack space usage.
  168. */
  169. static 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)
  170. {
  171. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  172. char *buf = (char *)msgbuf;
  173. _mav_put_uint64_t(buf, 0, time_usec);
  174. _mav_put_uint8_t(buf, 136, count);
  175. _mav_put_double_array(buf, 8, distance, 16);
  176. _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);
  177. #else
  178. mavlink_wheel_distance_t *packet = (mavlink_wheel_distance_t *)msgbuf;
  179. packet->time_usec = time_usec;
  180. packet->count = count;
  181. mav_array_memcpy(packet->distance, distance, sizeof(double)*16);
  182. _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);
  183. #endif
  184. }
  185. #endif
  186. #endif
  187. // MESSAGE WHEEL_DISTANCE UNPACKING
  188. /**
  189. * @brief Get field time_usec from wheel_distance message
  190. *
  191. * @return [us] Timestamp (synced to UNIX time or since system boot).
  192. */
  193. static inline uint64_t mavlink_msg_wheel_distance_get_time_usec(const mavlink_message_t* msg)
  194. {
  195. return _MAV_RETURN_uint64_t(msg, 0);
  196. }
  197. /**
  198. * @brief Get field count from wheel_distance message
  199. *
  200. * @return Number of wheels reported.
  201. */
  202. static inline uint8_t mavlink_msg_wheel_distance_get_count(const mavlink_message_t* msg)
  203. {
  204. return _MAV_RETURN_uint8_t(msg, 136);
  205. }
  206. /**
  207. * @brief Get field distance from wheel_distance message
  208. *
  209. * @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.
  210. */
  211. static inline uint16_t mavlink_msg_wheel_distance_get_distance(const mavlink_message_t* msg, double *distance)
  212. {
  213. return _MAV_RETURN_double_array(msg, distance, 16, 8);
  214. }
  215. /**
  216. * @brief Decode a wheel_distance message into a struct
  217. *
  218. * @param msg The message to decode
  219. * @param wheel_distance C-struct to decode the message contents into
  220. */
  221. static inline void mavlink_msg_wheel_distance_decode(const mavlink_message_t* msg, mavlink_wheel_distance_t* wheel_distance)
  222. {
  223. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  224. wheel_distance->time_usec = mavlink_msg_wheel_distance_get_time_usec(msg);
  225. mavlink_msg_wheel_distance_get_distance(msg, wheel_distance->distance);
  226. wheel_distance->count = mavlink_msg_wheel_distance_get_count(msg);
  227. #else
  228. uint8_t len = msg->len < MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN? msg->len : MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN;
  229. memset(wheel_distance, 0, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN);
  230. memcpy(wheel_distance, _MAV_PAYLOAD(msg), len);
  231. #endif
  232. }