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.

607 lines
30 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE ODOMETRY PACKING
  3. #define MAVLINK_MSG_ID_ODOMETRY 331
  4. MAVPACKED(
  5. typedef struct __mavlink_odometry_t {
  6. 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 the number.*/
  7. float x; /*< [m] X Position*/
  8. float y; /*< [m] Y Position*/
  9. float z; /*< [m] Z Position*/
  10. float q[4]; /*< Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)*/
  11. float vx; /*< [m/s] X linear speed*/
  12. float vy; /*< [m/s] Y linear speed*/
  13. float vz; /*< [m/s] Z linear speed*/
  14. float rollspeed; /*< [rad/s] Roll angular speed*/
  15. float pitchspeed; /*< [rad/s] Pitch angular speed*/
  16. float yawspeed; /*< [rad/s] Yaw angular speed*/
  17. 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.*/
  18. 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.*/
  19. uint8_t frame_id; /*< Coordinate frame of reference for the pose data.*/
  20. uint8_t child_frame_id; /*< Coordinate frame of reference for the velocity in free space (twist) data.*/
  21. 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.*/
  22. uint8_t estimator_type; /*< Type of estimator that is providing the odometry.*/
  23. }) mavlink_odometry_t;
  24. #define MAVLINK_MSG_ID_ODOMETRY_LEN 232
  25. #define MAVLINK_MSG_ID_ODOMETRY_MIN_LEN 230
  26. #define MAVLINK_MSG_ID_331_LEN 232
  27. #define MAVLINK_MSG_ID_331_MIN_LEN 230
  28. #define MAVLINK_MSG_ID_ODOMETRY_CRC 91
  29. #define MAVLINK_MSG_ID_331_CRC 91
  30. #define MAVLINK_MSG_ODOMETRY_FIELD_Q_LEN 4
  31. #define MAVLINK_MSG_ODOMETRY_FIELD_POSE_COVARIANCE_LEN 21
  32. #define MAVLINK_MSG_ODOMETRY_FIELD_VELOCITY_COVARIANCE_LEN 21
  33. #if MAVLINK_COMMAND_24BIT
  34. #define MAVLINK_MESSAGE_INFO_ODOMETRY { \
  35. 331, \
  36. "ODOMETRY", \
  37. 17, \
  38. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_odometry_t, time_usec) }, \
  39. { "frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 228, offsetof(mavlink_odometry_t, frame_id) }, \
  40. { "child_frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 229, offsetof(mavlink_odometry_t, child_frame_id) }, \
  41. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_odometry_t, x) }, \
  42. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_odometry_t, y) }, \
  43. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_odometry_t, z) }, \
  44. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 20, offsetof(mavlink_odometry_t, q) }, \
  45. { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_odometry_t, vx) }, \
  46. { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_odometry_t, vy) }, \
  47. { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_odometry_t, vz) }, \
  48. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_odometry_t, rollspeed) }, \
  49. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_odometry_t, pitchspeed) }, \
  50. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_odometry_t, yawspeed) }, \
  51. { "pose_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 60, offsetof(mavlink_odometry_t, pose_covariance) }, \
  52. { "velocity_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 144, offsetof(mavlink_odometry_t, velocity_covariance) }, \
  53. { "reset_counter", NULL, MAVLINK_TYPE_UINT8_T, 0, 230, offsetof(mavlink_odometry_t, reset_counter) }, \
  54. { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 231, offsetof(mavlink_odometry_t, estimator_type) }, \
  55. } \
  56. }
  57. #else
  58. #define MAVLINK_MESSAGE_INFO_ODOMETRY { \
  59. "ODOMETRY", \
  60. 17, \
  61. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_odometry_t, time_usec) }, \
  62. { "frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 228, offsetof(mavlink_odometry_t, frame_id) }, \
  63. { "child_frame_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 229, offsetof(mavlink_odometry_t, child_frame_id) }, \
  64. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_odometry_t, x) }, \
  65. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_odometry_t, y) }, \
  66. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_odometry_t, z) }, \
  67. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 20, offsetof(mavlink_odometry_t, q) }, \
  68. { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_odometry_t, vx) }, \
  69. { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_odometry_t, vy) }, \
  70. { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_odometry_t, vz) }, \
  71. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_odometry_t, rollspeed) }, \
  72. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_odometry_t, pitchspeed) }, \
  73. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_odometry_t, yawspeed) }, \
  74. { "pose_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 60, offsetof(mavlink_odometry_t, pose_covariance) }, \
  75. { "velocity_covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 144, offsetof(mavlink_odometry_t, velocity_covariance) }, \
  76. { "reset_counter", NULL, MAVLINK_TYPE_UINT8_T, 0, 230, offsetof(mavlink_odometry_t, reset_counter) }, \
  77. { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 231, offsetof(mavlink_odometry_t, estimator_type) }, \
  78. } \
  79. }
  80. #endif
  81. /**
  82. * @brief Pack a odometry message
  83. * @param system_id ID of this system
  84. * @param component_id ID of this component (e.g. 200 for IMU)
  85. * @param msg The MAVLink message to compress the data into
  86. *
  87. * @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 the number.
  88. * @param frame_id Coordinate frame of reference for the pose data.
  89. * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
  90. * @param x [m] X Position
  91. * @param y [m] Y Position
  92. * @param z [m] Z Position
  93. * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
  94. * @param vx [m/s] X linear speed
  95. * @param vy [m/s] Y linear speed
  96. * @param vz [m/s] Z linear speed
  97. * @param rollspeed [rad/s] Roll angular speed
  98. * @param pitchspeed [rad/s] Pitch angular speed
  99. * @param yawspeed [rad/s] Yaw angular speed
  100. * @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.
  101. * @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.
  102. * @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.
  103. * @param estimator_type Type of estimator that is providing the odometry.
  104. * @return length of the message in bytes (excluding serial stream start sign)
  105. */
  106. static inline uint16_t mavlink_msg_odometry_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  107. 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)
  108. {
  109. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  110. char buf[MAVLINK_MSG_ID_ODOMETRY_LEN];
  111. _mav_put_uint64_t(buf, 0, time_usec);
  112. _mav_put_float(buf, 8, x);
  113. _mav_put_float(buf, 12, y);
  114. _mav_put_float(buf, 16, z);
  115. _mav_put_float(buf, 36, vx);
  116. _mav_put_float(buf, 40, vy);
  117. _mav_put_float(buf, 44, vz);
  118. _mav_put_float(buf, 48, rollspeed);
  119. _mav_put_float(buf, 52, pitchspeed);
  120. _mav_put_float(buf, 56, yawspeed);
  121. _mav_put_uint8_t(buf, 228, frame_id);
  122. _mav_put_uint8_t(buf, 229, child_frame_id);
  123. _mav_put_uint8_t(buf, 230, reset_counter);
  124. _mav_put_uint8_t(buf, 231, estimator_type);
  125. _mav_put_float_array(buf, 20, q, 4);
  126. _mav_put_float_array(buf, 60, pose_covariance, 21);
  127. _mav_put_float_array(buf, 144, velocity_covariance, 21);
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN);
  129. #else
  130. mavlink_odometry_t packet;
  131. packet.time_usec = time_usec;
  132. packet.x = x;
  133. packet.y = y;
  134. packet.z = z;
  135. packet.vx = vx;
  136. packet.vy = vy;
  137. packet.vz = vz;
  138. packet.rollspeed = rollspeed;
  139. packet.pitchspeed = pitchspeed;
  140. packet.yawspeed = yawspeed;
  141. packet.frame_id = frame_id;
  142. packet.child_frame_id = child_frame_id;
  143. packet.reset_counter = reset_counter;
  144. packet.estimator_type = estimator_type;
  145. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  146. mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
  147. mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
  148. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN);
  149. #endif
  150. msg->msgid = MAVLINK_MSG_ID_ODOMETRY;
  151. 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);
  152. }
  153. /**
  154. * @brief Pack a odometry message on a channel
  155. * @param system_id ID of this system
  156. * @param component_id ID of this component (e.g. 200 for IMU)
  157. * @param chan The MAVLink channel this message will be sent over
  158. * @param msg The MAVLink message to compress the data into
  159. * @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 the number.
  160. * @param frame_id Coordinate frame of reference for the pose data.
  161. * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
  162. * @param x [m] X Position
  163. * @param y [m] Y Position
  164. * @param z [m] Z Position
  165. * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
  166. * @param vx [m/s] X linear speed
  167. * @param vy [m/s] Y linear speed
  168. * @param vz [m/s] Z linear speed
  169. * @param rollspeed [rad/s] Roll angular speed
  170. * @param pitchspeed [rad/s] Pitch angular speed
  171. * @param yawspeed [rad/s] Yaw angular speed
  172. * @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.
  173. * @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.
  174. * @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.
  175. * @param estimator_type Type of estimator that is providing the odometry.
  176. * @return length of the message in bytes (excluding serial stream start sign)
  177. */
  178. static inline uint16_t mavlink_msg_odometry_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  179. mavlink_message_t* msg,
  180. 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)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char buf[MAVLINK_MSG_ID_ODOMETRY_LEN];
  184. _mav_put_uint64_t(buf, 0, time_usec);
  185. _mav_put_float(buf, 8, x);
  186. _mav_put_float(buf, 12, y);
  187. _mav_put_float(buf, 16, z);
  188. _mav_put_float(buf, 36, vx);
  189. _mav_put_float(buf, 40, vy);
  190. _mav_put_float(buf, 44, vz);
  191. _mav_put_float(buf, 48, rollspeed);
  192. _mav_put_float(buf, 52, pitchspeed);
  193. _mav_put_float(buf, 56, yawspeed);
  194. _mav_put_uint8_t(buf, 228, frame_id);
  195. _mav_put_uint8_t(buf, 229, child_frame_id);
  196. _mav_put_uint8_t(buf, 230, reset_counter);
  197. _mav_put_uint8_t(buf, 231, estimator_type);
  198. _mav_put_float_array(buf, 20, q, 4);
  199. _mav_put_float_array(buf, 60, pose_covariance, 21);
  200. _mav_put_float_array(buf, 144, velocity_covariance, 21);
  201. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN);
  202. #else
  203. mavlink_odometry_t packet;
  204. packet.time_usec = time_usec;
  205. packet.x = x;
  206. packet.y = y;
  207. packet.z = z;
  208. packet.vx = vx;
  209. packet.vy = vy;
  210. packet.vz = vz;
  211. packet.rollspeed = rollspeed;
  212. packet.pitchspeed = pitchspeed;
  213. packet.yawspeed = yawspeed;
  214. packet.frame_id = frame_id;
  215. packet.child_frame_id = child_frame_id;
  216. packet.reset_counter = reset_counter;
  217. packet.estimator_type = estimator_type;
  218. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  219. mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
  220. mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
  221. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN);
  222. #endif
  223. msg->msgid = MAVLINK_MSG_ID_ODOMETRY;
  224. 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);
  225. }
  226. /**
  227. * @brief Encode a odometry struct
  228. *
  229. * @param system_id ID of this system
  230. * @param component_id ID of this component (e.g. 200 for IMU)
  231. * @param msg The MAVLink message to compress the data into
  232. * @param odometry C-struct to read the message contents from
  233. */
  234. static inline uint16_t mavlink_msg_odometry_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_odometry_t* odometry)
  235. {
  236. 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);
  237. }
  238. /**
  239. * @brief Encode a odometry struct on a channel
  240. *
  241. * @param system_id ID of this system
  242. * @param component_id ID of this component (e.g. 200 for IMU)
  243. * @param chan The MAVLink channel this message will be sent over
  244. * @param msg The MAVLink message to compress the data into
  245. * @param odometry C-struct to read the message contents from
  246. */
  247. static 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)
  248. {
  249. 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);
  250. }
  251. /**
  252. * @brief Send a odometry message
  253. * @param chan MAVLink channel to send the message
  254. *
  255. * @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 the number.
  256. * @param frame_id Coordinate frame of reference for the pose data.
  257. * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data.
  258. * @param x [m] X Position
  259. * @param y [m] Y Position
  260. * @param z [m] Z Position
  261. * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
  262. * @param vx [m/s] X linear speed
  263. * @param vy [m/s] Y linear speed
  264. * @param vz [m/s] Z linear speed
  265. * @param rollspeed [rad/s] Roll angular speed
  266. * @param pitchspeed [rad/s] Pitch angular speed
  267. * @param yawspeed [rad/s] Yaw angular speed
  268. * @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.
  269. * @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.
  270. * @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.
  271. * @param estimator_type Type of estimator that is providing the odometry.
  272. */
  273. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  274. static 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)
  275. {
  276. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  277. char buf[MAVLINK_MSG_ID_ODOMETRY_LEN];
  278. _mav_put_uint64_t(buf, 0, time_usec);
  279. _mav_put_float(buf, 8, x);
  280. _mav_put_float(buf, 12, y);
  281. _mav_put_float(buf, 16, z);
  282. _mav_put_float(buf, 36, vx);
  283. _mav_put_float(buf, 40, vy);
  284. _mav_put_float(buf, 44, vz);
  285. _mav_put_float(buf, 48, rollspeed);
  286. _mav_put_float(buf, 52, pitchspeed);
  287. _mav_put_float(buf, 56, yawspeed);
  288. _mav_put_uint8_t(buf, 228, frame_id);
  289. _mav_put_uint8_t(buf, 229, child_frame_id);
  290. _mav_put_uint8_t(buf, 230, reset_counter);
  291. _mav_put_uint8_t(buf, 231, estimator_type);
  292. _mav_put_float_array(buf, 20, q, 4);
  293. _mav_put_float_array(buf, 60, pose_covariance, 21);
  294. _mav_put_float_array(buf, 144, velocity_covariance, 21);
  295. _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);
  296. #else
  297. mavlink_odometry_t packet;
  298. packet.time_usec = time_usec;
  299. packet.x = x;
  300. packet.y = y;
  301. packet.z = z;
  302. packet.vx = vx;
  303. packet.vy = vy;
  304. packet.vz = vz;
  305. packet.rollspeed = rollspeed;
  306. packet.pitchspeed = pitchspeed;
  307. packet.yawspeed = yawspeed;
  308. packet.frame_id = frame_id;
  309. packet.child_frame_id = child_frame_id;
  310. packet.reset_counter = reset_counter;
  311. packet.estimator_type = estimator_type;
  312. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  313. mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21);
  314. mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21);
  315. _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);
  316. #endif
  317. }
  318. /**
  319. * @brief Send a odometry message
  320. * @param chan MAVLink channel to send the message
  321. * @param struct The MAVLink struct to serialize
  322. */
  323. static inline void mavlink_msg_odometry_send_struct(mavlink_channel_t chan, const mavlink_odometry_t* odometry)
  324. {
  325. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  326. 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);
  327. #else
  328. _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);
  329. #endif
  330. }
  331. #if MAVLINK_MSG_ID_ODOMETRY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  332. /*
  333. This varient of _send() can be used to save stack space by re-using
  334. memory from the receive buffer. The caller provides a
  335. mavlink_message_t which is the size of a full mavlink message. This
  336. is usually the receive buffer for the channel, and allows a reply to an
  337. incoming message with minimum stack space usage.
  338. */
  339. static 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)
  340. {
  341. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  342. char *buf = (char *)msgbuf;
  343. _mav_put_uint64_t(buf, 0, time_usec);
  344. _mav_put_float(buf, 8, x);
  345. _mav_put_float(buf, 12, y);
  346. _mav_put_float(buf, 16, z);
  347. _mav_put_float(buf, 36, vx);
  348. _mav_put_float(buf, 40, vy);
  349. _mav_put_float(buf, 44, vz);
  350. _mav_put_float(buf, 48, rollspeed);
  351. _mav_put_float(buf, 52, pitchspeed);
  352. _mav_put_float(buf, 56, yawspeed);
  353. _mav_put_uint8_t(buf, 228, frame_id);
  354. _mav_put_uint8_t(buf, 229, child_frame_id);
  355. _mav_put_uint8_t(buf, 230, reset_counter);
  356. _mav_put_uint8_t(buf, 231, estimator_type);
  357. _mav_put_float_array(buf, 20, q, 4);
  358. _mav_put_float_array(buf, 60, pose_covariance, 21);
  359. _mav_put_float_array(buf, 144, velocity_covariance, 21);
  360. _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);
  361. #else
  362. mavlink_odometry_t *packet = (mavlink_odometry_t *)msgbuf;
  363. packet->time_usec = time_usec;
  364. packet->x = x;
  365. packet->y = y;
  366. packet->z = z;
  367. packet->vx = vx;
  368. packet->vy = vy;
  369. packet->vz = vz;
  370. packet->rollspeed = rollspeed;
  371. packet->pitchspeed = pitchspeed;
  372. packet->yawspeed = yawspeed;
  373. packet->frame_id = frame_id;
  374. packet->child_frame_id = child_frame_id;
  375. packet->reset_counter = reset_counter;
  376. packet->estimator_type = estimator_type;
  377. mav_array_memcpy(packet->q, q, sizeof(float)*4);
  378. mav_array_memcpy(packet->pose_covariance, pose_covariance, sizeof(float)*21);
  379. mav_array_memcpy(packet->velocity_covariance, velocity_covariance, sizeof(float)*21);
  380. _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);
  381. #endif
  382. }
  383. #endif
  384. #endif
  385. // MESSAGE ODOMETRY UNPACKING
  386. /**
  387. * @brief Get field time_usec from odometry message
  388. *
  389. * @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 the number.
  390. */
  391. static inline uint64_t mavlink_msg_odometry_get_time_usec(const mavlink_message_t* msg)
  392. {
  393. return _MAV_RETURN_uint64_t(msg, 0);
  394. }
  395. /**
  396. * @brief Get field frame_id from odometry message
  397. *
  398. * @return Coordinate frame of reference for the pose data.
  399. */
  400. static inline uint8_t mavlink_msg_odometry_get_frame_id(const mavlink_message_t* msg)
  401. {
  402. return _MAV_RETURN_uint8_t(msg, 228);
  403. }
  404. /**
  405. * @brief Get field child_frame_id from odometry message
  406. *
  407. * @return Coordinate frame of reference for the velocity in free space (twist) data.
  408. */
  409. static inline uint8_t mavlink_msg_odometry_get_child_frame_id(const mavlink_message_t* msg)
  410. {
  411. return _MAV_RETURN_uint8_t(msg, 229);
  412. }
  413. /**
  414. * @brief Get field x from odometry message
  415. *
  416. * @return [m] X Position
  417. */
  418. static inline float mavlink_msg_odometry_get_x(const mavlink_message_t* msg)
  419. {
  420. return _MAV_RETURN_float(msg, 8);
  421. }
  422. /**
  423. * @brief Get field y from odometry message
  424. *
  425. * @return [m] Y Position
  426. */
  427. static inline float mavlink_msg_odometry_get_y(const mavlink_message_t* msg)
  428. {
  429. return _MAV_RETURN_float(msg, 12);
  430. }
  431. /**
  432. * @brief Get field z from odometry message
  433. *
  434. * @return [m] Z Position
  435. */
  436. static inline float mavlink_msg_odometry_get_z(const mavlink_message_t* msg)
  437. {
  438. return _MAV_RETURN_float(msg, 16);
  439. }
  440. /**
  441. * @brief Get field q from odometry message
  442. *
  443. * @return Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation)
  444. */
  445. static inline uint16_t mavlink_msg_odometry_get_q(const mavlink_message_t* msg, float *q)
  446. {
  447. return _MAV_RETURN_float_array(msg, q, 4, 20);
  448. }
  449. /**
  450. * @brief Get field vx from odometry message
  451. *
  452. * @return [m/s] X linear speed
  453. */
  454. static inline float mavlink_msg_odometry_get_vx(const mavlink_message_t* msg)
  455. {
  456. return _MAV_RETURN_float(msg, 36);
  457. }
  458. /**
  459. * @brief Get field vy from odometry message
  460. *
  461. * @return [m/s] Y linear speed
  462. */
  463. static inline float mavlink_msg_odometry_get_vy(const mavlink_message_t* msg)
  464. {
  465. return _MAV_RETURN_float(msg, 40);
  466. }
  467. /**
  468. * @brief Get field vz from odometry message
  469. *
  470. * @return [m/s] Z linear speed
  471. */
  472. static inline float mavlink_msg_odometry_get_vz(const mavlink_message_t* msg)
  473. {
  474. return _MAV_RETURN_float(msg, 44);
  475. }
  476. /**
  477. * @brief Get field rollspeed from odometry message
  478. *
  479. * @return [rad/s] Roll angular speed
  480. */
  481. static inline float mavlink_msg_odometry_get_rollspeed(const mavlink_message_t* msg)
  482. {
  483. return _MAV_RETURN_float(msg, 48);
  484. }
  485. /**
  486. * @brief Get field pitchspeed from odometry message
  487. *
  488. * @return [rad/s] Pitch angular speed
  489. */
  490. static inline float mavlink_msg_odometry_get_pitchspeed(const mavlink_message_t* msg)
  491. {
  492. return _MAV_RETURN_float(msg, 52);
  493. }
  494. /**
  495. * @brief Get field yawspeed from odometry message
  496. *
  497. * @return [rad/s] Yaw angular speed
  498. */
  499. static inline float mavlink_msg_odometry_get_yawspeed(const mavlink_message_t* msg)
  500. {
  501. return _MAV_RETURN_float(msg, 56);
  502. }
  503. /**
  504. * @brief Get field pose_covariance from odometry message
  505. *
  506. * @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.
  507. */
  508. static inline uint16_t mavlink_msg_odometry_get_pose_covariance(const mavlink_message_t* msg, float *pose_covariance)
  509. {
  510. return _MAV_RETURN_float_array(msg, pose_covariance, 21, 60);
  511. }
  512. /**
  513. * @brief Get field velocity_covariance from odometry message
  514. *
  515. * @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.
  516. */
  517. static inline uint16_t mavlink_msg_odometry_get_velocity_covariance(const mavlink_message_t* msg, float *velocity_covariance)
  518. {
  519. return _MAV_RETURN_float_array(msg, velocity_covariance, 21, 144);
  520. }
  521. /**
  522. * @brief Get field reset_counter from odometry message
  523. *
  524. * @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.
  525. */
  526. static inline uint8_t mavlink_msg_odometry_get_reset_counter(const mavlink_message_t* msg)
  527. {
  528. return _MAV_RETURN_uint8_t(msg, 230);
  529. }
  530. /**
  531. * @brief Get field estimator_type from odometry message
  532. *
  533. * @return Type of estimator that is providing the odometry.
  534. */
  535. static inline uint8_t mavlink_msg_odometry_get_estimator_type(const mavlink_message_t* msg)
  536. {
  537. return _MAV_RETURN_uint8_t(msg, 231);
  538. }
  539. /**
  540. * @brief Decode a odometry message into a struct
  541. *
  542. * @param msg The message to decode
  543. * @param odometry C-struct to decode the message contents into
  544. */
  545. static inline void mavlink_msg_odometry_decode(const mavlink_message_t* msg, mavlink_odometry_t* odometry)
  546. {
  547. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  548. odometry->time_usec = mavlink_msg_odometry_get_time_usec(msg);
  549. odometry->x = mavlink_msg_odometry_get_x(msg);
  550. odometry->y = mavlink_msg_odometry_get_y(msg);
  551. odometry->z = mavlink_msg_odometry_get_z(msg);
  552. mavlink_msg_odometry_get_q(msg, odometry->q);
  553. odometry->vx = mavlink_msg_odometry_get_vx(msg);
  554. odometry->vy = mavlink_msg_odometry_get_vy(msg);
  555. odometry->vz = mavlink_msg_odometry_get_vz(msg);
  556. odometry->rollspeed = mavlink_msg_odometry_get_rollspeed(msg);
  557. odometry->pitchspeed = mavlink_msg_odometry_get_pitchspeed(msg);
  558. odometry->yawspeed = mavlink_msg_odometry_get_yawspeed(msg);
  559. mavlink_msg_odometry_get_pose_covariance(msg, odometry->pose_covariance);
  560. mavlink_msg_odometry_get_velocity_covariance(msg, odometry->velocity_covariance);
  561. odometry->frame_id = mavlink_msg_odometry_get_frame_id(msg);
  562. odometry->child_frame_id = mavlink_msg_odometry_get_child_frame_id(msg);
  563. odometry->reset_counter = mavlink_msg_odometry_get_reset_counter(msg);
  564. odometry->estimator_type = mavlink_msg_odometry_get_estimator_type(msg);
  565. #else
  566. uint8_t len = msg->len < MAVLINK_MSG_ID_ODOMETRY_LEN? msg->len : MAVLINK_MSG_ID_ODOMETRY_LEN;
  567. memset(odometry, 0, MAVLINK_MSG_ID_ODOMETRY_LEN);
  568. memcpy(odometry, _MAV_PAYLOAD(msg), len);
  569. #endif
  570. }