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.

363 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE PID_TUNING PACKING
  3. #define MAVLINK_MSG_ID_PID_TUNING 194
  4. MAVPACKED(
  5. typedef struct __mavlink_pid_tuning_t {
  6. float desired; /*< [deg/s] Desired rate.*/
  7. float achieved; /*< [deg/s] Achieved rate.*/
  8. float FF; /*< FF component.*/
  9. float P; /*< P component.*/
  10. float I; /*< I component.*/
  11. float D; /*< D component.*/
  12. uint8_t axis; /*< Axis.*/
  13. }) mavlink_pid_tuning_t;
  14. #define MAVLINK_MSG_ID_PID_TUNING_LEN 25
  15. #define MAVLINK_MSG_ID_PID_TUNING_MIN_LEN 25
  16. #define MAVLINK_MSG_ID_194_LEN 25
  17. #define MAVLINK_MSG_ID_194_MIN_LEN 25
  18. #define MAVLINK_MSG_ID_PID_TUNING_CRC 98
  19. #define MAVLINK_MSG_ID_194_CRC 98
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_PID_TUNING { \
  22. 194, \
  23. "PID_TUNING", \
  24. 7, \
  25. { { "axis", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_pid_tuning_t, axis) }, \
  26. { "desired", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_pid_tuning_t, desired) }, \
  27. { "achieved", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_pid_tuning_t, achieved) }, \
  28. { "FF", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_pid_tuning_t, FF) }, \
  29. { "P", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_pid_tuning_t, P) }, \
  30. { "I", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_pid_tuning_t, I) }, \
  31. { "D", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_pid_tuning_t, D) }, \
  32. } \
  33. }
  34. #else
  35. #define MAVLINK_MESSAGE_INFO_PID_TUNING { \
  36. "PID_TUNING", \
  37. 7, \
  38. { { "axis", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_pid_tuning_t, axis) }, \
  39. { "desired", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_pid_tuning_t, desired) }, \
  40. { "achieved", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_pid_tuning_t, achieved) }, \
  41. { "FF", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_pid_tuning_t, FF) }, \
  42. { "P", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_pid_tuning_t, P) }, \
  43. { "I", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_pid_tuning_t, I) }, \
  44. { "D", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_pid_tuning_t, D) }, \
  45. } \
  46. }
  47. #endif
  48. /**
  49. * @brief Pack a pid_tuning message
  50. * @param system_id ID of this system
  51. * @param component_id ID of this component (e.g. 200 for IMU)
  52. * @param msg The MAVLink message to compress the data into
  53. *
  54. * @param axis Axis.
  55. * @param desired [deg/s] Desired rate.
  56. * @param achieved [deg/s] Achieved rate.
  57. * @param FF FF component.
  58. * @param P P component.
  59. * @param I I component.
  60. * @param D D component.
  61. * @return length of the message in bytes (excluding serial stream start sign)
  62. */
  63. static inline uint16_t mavlink_msg_pid_tuning_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  64. uint8_t axis, float desired, float achieved, float FF, float P, float I, float D)
  65. {
  66. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  67. char buf[MAVLINK_MSG_ID_PID_TUNING_LEN];
  68. _mav_put_float(buf, 0, desired);
  69. _mav_put_float(buf, 4, achieved);
  70. _mav_put_float(buf, 8, FF);
  71. _mav_put_float(buf, 12, P);
  72. _mav_put_float(buf, 16, I);
  73. _mav_put_float(buf, 20, D);
  74. _mav_put_uint8_t(buf, 24, axis);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PID_TUNING_LEN);
  76. #else
  77. mavlink_pid_tuning_t packet;
  78. packet.desired = desired;
  79. packet.achieved = achieved;
  80. packet.FF = FF;
  81. packet.P = P;
  82. packet.I = I;
  83. packet.D = D;
  84. packet.axis = axis;
  85. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PID_TUNING_LEN);
  86. #endif
  87. msg->msgid = MAVLINK_MSG_ID_PID_TUNING;
  88. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  89. }
  90. /**
  91. * @brief Pack a pid_tuning message on a channel
  92. * @param system_id ID of this system
  93. * @param component_id ID of this component (e.g. 200 for IMU)
  94. * @param chan The MAVLink channel this message will be sent over
  95. * @param msg The MAVLink message to compress the data into
  96. * @param axis Axis.
  97. * @param desired [deg/s] Desired rate.
  98. * @param achieved [deg/s] Achieved rate.
  99. * @param FF FF component.
  100. * @param P P component.
  101. * @param I I component.
  102. * @param D D component.
  103. * @return length of the message in bytes (excluding serial stream start sign)
  104. */
  105. static inline uint16_t mavlink_msg_pid_tuning_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  106. mavlink_message_t* msg,
  107. uint8_t axis,float desired,float achieved,float FF,float P,float I,float D)
  108. {
  109. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  110. char buf[MAVLINK_MSG_ID_PID_TUNING_LEN];
  111. _mav_put_float(buf, 0, desired);
  112. _mav_put_float(buf, 4, achieved);
  113. _mav_put_float(buf, 8, FF);
  114. _mav_put_float(buf, 12, P);
  115. _mav_put_float(buf, 16, I);
  116. _mav_put_float(buf, 20, D);
  117. _mav_put_uint8_t(buf, 24, axis);
  118. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PID_TUNING_LEN);
  119. #else
  120. mavlink_pid_tuning_t packet;
  121. packet.desired = desired;
  122. packet.achieved = achieved;
  123. packet.FF = FF;
  124. packet.P = P;
  125. packet.I = I;
  126. packet.D = D;
  127. packet.axis = axis;
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PID_TUNING_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_PID_TUNING;
  131. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  132. }
  133. /**
  134. * @brief Encode a pid_tuning struct
  135. *
  136. * @param system_id ID of this system
  137. * @param component_id ID of this component (e.g. 200 for IMU)
  138. * @param msg The MAVLink message to compress the data into
  139. * @param pid_tuning C-struct to read the message contents from
  140. */
  141. static inline uint16_t mavlink_msg_pid_tuning_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_pid_tuning_t* pid_tuning)
  142. {
  143. return mavlink_msg_pid_tuning_pack(system_id, component_id, msg, pid_tuning->axis, pid_tuning->desired, pid_tuning->achieved, pid_tuning->FF, pid_tuning->P, pid_tuning->I, pid_tuning->D);
  144. }
  145. /**
  146. * @brief Encode a pid_tuning struct on a channel
  147. *
  148. * @param system_id ID of this system
  149. * @param component_id ID of this component (e.g. 200 for IMU)
  150. * @param chan The MAVLink channel this message will be sent over
  151. * @param msg The MAVLink message to compress the data into
  152. * @param pid_tuning C-struct to read the message contents from
  153. */
  154. static inline uint16_t mavlink_msg_pid_tuning_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_pid_tuning_t* pid_tuning)
  155. {
  156. return mavlink_msg_pid_tuning_pack_chan(system_id, component_id, chan, msg, pid_tuning->axis, pid_tuning->desired, pid_tuning->achieved, pid_tuning->FF, pid_tuning->P, pid_tuning->I, pid_tuning->D);
  157. }
  158. /**
  159. * @brief Send a pid_tuning message
  160. * @param chan MAVLink channel to send the message
  161. *
  162. * @param axis Axis.
  163. * @param desired [deg/s] Desired rate.
  164. * @param achieved [deg/s] Achieved rate.
  165. * @param FF FF component.
  166. * @param P P component.
  167. * @param I I component.
  168. * @param D D component.
  169. */
  170. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  171. static inline void mavlink_msg_pid_tuning_send(mavlink_channel_t chan, uint8_t axis, float desired, float achieved, float FF, float P, float I, float D)
  172. {
  173. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  174. char buf[MAVLINK_MSG_ID_PID_TUNING_LEN];
  175. _mav_put_float(buf, 0, desired);
  176. _mav_put_float(buf, 4, achieved);
  177. _mav_put_float(buf, 8, FF);
  178. _mav_put_float(buf, 12, P);
  179. _mav_put_float(buf, 16, I);
  180. _mav_put_float(buf, 20, D);
  181. _mav_put_uint8_t(buf, 24, axis);
  182. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PID_TUNING, buf, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  183. #else
  184. mavlink_pid_tuning_t packet;
  185. packet.desired = desired;
  186. packet.achieved = achieved;
  187. packet.FF = FF;
  188. packet.P = P;
  189. packet.I = I;
  190. packet.D = D;
  191. packet.axis = axis;
  192. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PID_TUNING, (const char *)&packet, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  193. #endif
  194. }
  195. /**
  196. * @brief Send a pid_tuning message
  197. * @param chan MAVLink channel to send the message
  198. * @param struct The MAVLink struct to serialize
  199. */
  200. static inline void mavlink_msg_pid_tuning_send_struct(mavlink_channel_t chan, const mavlink_pid_tuning_t* pid_tuning)
  201. {
  202. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  203. mavlink_msg_pid_tuning_send(chan, pid_tuning->axis, pid_tuning->desired, pid_tuning->achieved, pid_tuning->FF, pid_tuning->P, pid_tuning->I, pid_tuning->D);
  204. #else
  205. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PID_TUNING, (const char *)pid_tuning, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  206. #endif
  207. }
  208. #if MAVLINK_MSG_ID_PID_TUNING_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  209. /*
  210. This varient of _send() can be used to save stack space by re-using
  211. memory from the receive buffer. The caller provides a
  212. mavlink_message_t which is the size of a full mavlink message. This
  213. is usually the receive buffer for the channel, and allows a reply to an
  214. incoming message with minimum stack space usage.
  215. */
  216. static inline void mavlink_msg_pid_tuning_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t axis, float desired, float achieved, float FF, float P, float I, float D)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  219. char *buf = (char *)msgbuf;
  220. _mav_put_float(buf, 0, desired);
  221. _mav_put_float(buf, 4, achieved);
  222. _mav_put_float(buf, 8, FF);
  223. _mav_put_float(buf, 12, P);
  224. _mav_put_float(buf, 16, I);
  225. _mav_put_float(buf, 20, D);
  226. _mav_put_uint8_t(buf, 24, axis);
  227. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PID_TUNING, buf, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  228. #else
  229. mavlink_pid_tuning_t *packet = (mavlink_pid_tuning_t *)msgbuf;
  230. packet->desired = desired;
  231. packet->achieved = achieved;
  232. packet->FF = FF;
  233. packet->P = P;
  234. packet->I = I;
  235. packet->D = D;
  236. packet->axis = axis;
  237. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PID_TUNING, (const char *)packet, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC);
  238. #endif
  239. }
  240. #endif
  241. #endif
  242. // MESSAGE PID_TUNING UNPACKING
  243. /**
  244. * @brief Get field axis from pid_tuning message
  245. *
  246. * @return Axis.
  247. */
  248. static inline uint8_t mavlink_msg_pid_tuning_get_axis(const mavlink_message_t* msg)
  249. {
  250. return _MAV_RETURN_uint8_t(msg, 24);
  251. }
  252. /**
  253. * @brief Get field desired from pid_tuning message
  254. *
  255. * @return [deg/s] Desired rate.
  256. */
  257. static inline float mavlink_msg_pid_tuning_get_desired(const mavlink_message_t* msg)
  258. {
  259. return _MAV_RETURN_float(msg, 0);
  260. }
  261. /**
  262. * @brief Get field achieved from pid_tuning message
  263. *
  264. * @return [deg/s] Achieved rate.
  265. */
  266. static inline float mavlink_msg_pid_tuning_get_achieved(const mavlink_message_t* msg)
  267. {
  268. return _MAV_RETURN_float(msg, 4);
  269. }
  270. /**
  271. * @brief Get field FF from pid_tuning message
  272. *
  273. * @return FF component.
  274. */
  275. static inline float mavlink_msg_pid_tuning_get_FF(const mavlink_message_t* msg)
  276. {
  277. return _MAV_RETURN_float(msg, 8);
  278. }
  279. /**
  280. * @brief Get field P from pid_tuning message
  281. *
  282. * @return P component.
  283. */
  284. static inline float mavlink_msg_pid_tuning_get_P(const mavlink_message_t* msg)
  285. {
  286. return _MAV_RETURN_float(msg, 12);
  287. }
  288. /**
  289. * @brief Get field I from pid_tuning message
  290. *
  291. * @return I component.
  292. */
  293. static inline float mavlink_msg_pid_tuning_get_I(const mavlink_message_t* msg)
  294. {
  295. return _MAV_RETURN_float(msg, 16);
  296. }
  297. /**
  298. * @brief Get field D from pid_tuning message
  299. *
  300. * @return D component.
  301. */
  302. static inline float mavlink_msg_pid_tuning_get_D(const mavlink_message_t* msg)
  303. {
  304. return _MAV_RETURN_float(msg, 20);
  305. }
  306. /**
  307. * @brief Decode a pid_tuning message into a struct
  308. *
  309. * @param msg The message to decode
  310. * @param pid_tuning C-struct to decode the message contents into
  311. */
  312. static inline void mavlink_msg_pid_tuning_decode(const mavlink_message_t* msg, mavlink_pid_tuning_t* pid_tuning)
  313. {
  314. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  315. pid_tuning->desired = mavlink_msg_pid_tuning_get_desired(msg);
  316. pid_tuning->achieved = mavlink_msg_pid_tuning_get_achieved(msg);
  317. pid_tuning->FF = mavlink_msg_pid_tuning_get_FF(msg);
  318. pid_tuning->P = mavlink_msg_pid_tuning_get_P(msg);
  319. pid_tuning->I = mavlink_msg_pid_tuning_get_I(msg);
  320. pid_tuning->D = mavlink_msg_pid_tuning_get_D(msg);
  321. pid_tuning->axis = mavlink_msg_pid_tuning_get_axis(msg);
  322. #else
  323. uint8_t len = msg->len < MAVLINK_MSG_ID_PID_TUNING_LEN? msg->len : MAVLINK_MSG_ID_PID_TUNING_LEN;
  324. memset(pid_tuning, 0, MAVLINK_MSG_ID_PID_TUNING_LEN);
  325. memcpy(pid_tuning, _MAV_PAYLOAD(msg), len);
  326. #endif
  327. }