mavlink_msg_sim_state.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. #pragma once
  2. // MESSAGE SIM_STATE PACKING
  3. #define MAVLINK_MSG_ID_SIM_STATE 108
  4. typedef struct __mavlink_sim_state_t {
  5. float q1; /*< True attitude quaternion component 1, w (1 in null-rotation)*/
  6. float q2; /*< True attitude quaternion component 2, x (0 in null-rotation)*/
  7. float q3; /*< True attitude quaternion component 3, y (0 in null-rotation)*/
  8. float q4; /*< True attitude quaternion component 4, z (0 in null-rotation)*/
  9. float roll; /*< Attitude roll expressed as Euler angles, not recommended except for human-readable outputs*/
  10. float pitch; /*< Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs*/
  11. float yaw; /*< Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs*/
  12. float xacc; /*< [m/s/s] X acceleration*/
  13. float yacc; /*< [m/s/s] Y acceleration*/
  14. float zacc; /*< [m/s/s] Z acceleration*/
  15. float xgyro; /*< [rad/s] Angular speed around X axis*/
  16. float ygyro; /*< [rad/s] Angular speed around Y axis*/
  17. float zgyro; /*< [rad/s] Angular speed around Z axis*/
  18. float lat; /*< [deg] Latitude (lower precision). Both this and the lat_int field should be set.*/
  19. float lon; /*< [deg] Longitude (lower precision). Both this and the lon_int field should be set.*/
  20. float alt; /*< [m] Altitude*/
  21. float std_dev_horz; /*< Horizontal position standard deviation*/
  22. float std_dev_vert; /*< Vertical position standard deviation*/
  23. float vn; /*< [m/s] True velocity in north direction in earth-fixed NED frame*/
  24. float ve; /*< [m/s] True velocity in east direction in earth-fixed NED frame*/
  25. float vd; /*< [m/s] True velocity in down direction in earth-fixed NED frame*/
  26. int32_t lat_int; /*< [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).*/
  27. int32_t lon_int; /*< [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).*/
  28. } mavlink_sim_state_t;
  29. #define MAVLINK_MSG_ID_SIM_STATE_LEN 92
  30. #define MAVLINK_MSG_ID_SIM_STATE_MIN_LEN 84
  31. #define MAVLINK_MSG_ID_108_LEN 92
  32. #define MAVLINK_MSG_ID_108_MIN_LEN 84
  33. #define MAVLINK_MSG_ID_SIM_STATE_CRC 32
  34. #define MAVLINK_MSG_ID_108_CRC 32
  35. #if MAVLINK_COMMAND_24BIT
  36. #define MAVLINK_MESSAGE_INFO_SIM_STATE { \
  37. 108, \
  38. "SIM_STATE", \
  39. 23, \
  40. { { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sim_state_t, q1) }, \
  41. { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_sim_state_t, q2) }, \
  42. { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_sim_state_t, q3) }, \
  43. { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sim_state_t, q4) }, \
  44. { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_sim_state_t, roll) }, \
  45. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_sim_state_t, pitch) }, \
  46. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_sim_state_t, yaw) }, \
  47. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_sim_state_t, xacc) }, \
  48. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_sim_state_t, yacc) }, \
  49. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_sim_state_t, zacc) }, \
  50. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_sim_state_t, xgyro) }, \
  51. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_sim_state_t, ygyro) }, \
  52. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_sim_state_t, zgyro) }, \
  53. { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_sim_state_t, lat) }, \
  54. { "lon", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_sim_state_t, lon) }, \
  55. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 60, offsetof(mavlink_sim_state_t, alt) }, \
  56. { "std_dev_horz", NULL, MAVLINK_TYPE_FLOAT, 0, 64, offsetof(mavlink_sim_state_t, std_dev_horz) }, \
  57. { "std_dev_vert", NULL, MAVLINK_TYPE_FLOAT, 0, 68, offsetof(mavlink_sim_state_t, std_dev_vert) }, \
  58. { "vn", NULL, MAVLINK_TYPE_FLOAT, 0, 72, offsetof(mavlink_sim_state_t, vn) }, \
  59. { "ve", NULL, MAVLINK_TYPE_FLOAT, 0, 76, offsetof(mavlink_sim_state_t, ve) }, \
  60. { "vd", NULL, MAVLINK_TYPE_FLOAT, 0, 80, offsetof(mavlink_sim_state_t, vd) }, \
  61. { "lat_int", NULL, MAVLINK_TYPE_INT32_T, 0, 84, offsetof(mavlink_sim_state_t, lat_int) }, \
  62. { "lon_int", NULL, MAVLINK_TYPE_INT32_T, 0, 88, offsetof(mavlink_sim_state_t, lon_int) }, \
  63. } \
  64. }
  65. #else
  66. #define MAVLINK_MESSAGE_INFO_SIM_STATE { \
  67. "SIM_STATE", \
  68. 23, \
  69. { { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sim_state_t, q1) }, \
  70. { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_sim_state_t, q2) }, \
  71. { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_sim_state_t, q3) }, \
  72. { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sim_state_t, q4) }, \
  73. { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_sim_state_t, roll) }, \
  74. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_sim_state_t, pitch) }, \
  75. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_sim_state_t, yaw) }, \
  76. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_sim_state_t, xacc) }, \
  77. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_sim_state_t, yacc) }, \
  78. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_sim_state_t, zacc) }, \
  79. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_sim_state_t, xgyro) }, \
  80. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_sim_state_t, ygyro) }, \
  81. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_sim_state_t, zgyro) }, \
  82. { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_sim_state_t, lat) }, \
  83. { "lon", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_sim_state_t, lon) }, \
  84. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 60, offsetof(mavlink_sim_state_t, alt) }, \
  85. { "std_dev_horz", NULL, MAVLINK_TYPE_FLOAT, 0, 64, offsetof(mavlink_sim_state_t, std_dev_horz) }, \
  86. { "std_dev_vert", NULL, MAVLINK_TYPE_FLOAT, 0, 68, offsetof(mavlink_sim_state_t, std_dev_vert) }, \
  87. { "vn", NULL, MAVLINK_TYPE_FLOAT, 0, 72, offsetof(mavlink_sim_state_t, vn) }, \
  88. { "ve", NULL, MAVLINK_TYPE_FLOAT, 0, 76, offsetof(mavlink_sim_state_t, ve) }, \
  89. { "vd", NULL, MAVLINK_TYPE_FLOAT, 0, 80, offsetof(mavlink_sim_state_t, vd) }, \
  90. { "lat_int", NULL, MAVLINK_TYPE_INT32_T, 0, 84, offsetof(mavlink_sim_state_t, lat_int) }, \
  91. { "lon_int", NULL, MAVLINK_TYPE_INT32_T, 0, 88, offsetof(mavlink_sim_state_t, lon_int) }, \
  92. } \
  93. }
  94. #endif
  95. /**
  96. * @brief Pack a sim_state message
  97. * @param system_id ID of this system
  98. * @param component_id ID of this component (e.g. 200 for IMU)
  99. * @param msg The MAVLink message to compress the data into
  100. *
  101. * @param q1 True attitude quaternion component 1, w (1 in null-rotation)
  102. * @param q2 True attitude quaternion component 2, x (0 in null-rotation)
  103. * @param q3 True attitude quaternion component 3, y (0 in null-rotation)
  104. * @param q4 True attitude quaternion component 4, z (0 in null-rotation)
  105. * @param roll Attitude roll expressed as Euler angles, not recommended except for human-readable outputs
  106. * @param pitch Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs
  107. * @param yaw Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs
  108. * @param xacc [m/s/s] X acceleration
  109. * @param yacc [m/s/s] Y acceleration
  110. * @param zacc [m/s/s] Z acceleration
  111. * @param xgyro [rad/s] Angular speed around X axis
  112. * @param ygyro [rad/s] Angular speed around Y axis
  113. * @param zgyro [rad/s] Angular speed around Z axis
  114. * @param lat [deg] Latitude (lower precision). Both this and the lat_int field should be set.
  115. * @param lon [deg] Longitude (lower precision). Both this and the lon_int field should be set.
  116. * @param alt [m] Altitude
  117. * @param std_dev_horz Horizontal position standard deviation
  118. * @param std_dev_vert Vertical position standard deviation
  119. * @param vn [m/s] True velocity in north direction in earth-fixed NED frame
  120. * @param ve [m/s] True velocity in east direction in earth-fixed NED frame
  121. * @param vd [m/s] True velocity in down direction in earth-fixed NED frame
  122. * @param lat_int [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).
  123. * @param lon_int [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).
  124. * @return length of the message in bytes (excluding serial stream start sign)
  125. */
  126. static inline uint16_t mavlink_msg_sim_state_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  127. float q1, float q2, float q3, float q4, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lon, float alt, float std_dev_horz, float std_dev_vert, float vn, float ve, float vd, int32_t lat_int, int32_t lon_int)
  128. {
  129. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  130. char buf[MAVLINK_MSG_ID_SIM_STATE_LEN];
  131. _mav_put_float(buf, 0, q1);
  132. _mav_put_float(buf, 4, q2);
  133. _mav_put_float(buf, 8, q3);
  134. _mav_put_float(buf, 12, q4);
  135. _mav_put_float(buf, 16, roll);
  136. _mav_put_float(buf, 20, pitch);
  137. _mav_put_float(buf, 24, yaw);
  138. _mav_put_float(buf, 28, xacc);
  139. _mav_put_float(buf, 32, yacc);
  140. _mav_put_float(buf, 36, zacc);
  141. _mav_put_float(buf, 40, xgyro);
  142. _mav_put_float(buf, 44, ygyro);
  143. _mav_put_float(buf, 48, zgyro);
  144. _mav_put_float(buf, 52, lat);
  145. _mav_put_float(buf, 56, lon);
  146. _mav_put_float(buf, 60, alt);
  147. _mav_put_float(buf, 64, std_dev_horz);
  148. _mav_put_float(buf, 68, std_dev_vert);
  149. _mav_put_float(buf, 72, vn);
  150. _mav_put_float(buf, 76, ve);
  151. _mav_put_float(buf, 80, vd);
  152. _mav_put_int32_t(buf, 84, lat_int);
  153. _mav_put_int32_t(buf, 88, lon_int);
  154. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIM_STATE_LEN);
  155. #else
  156. mavlink_sim_state_t packet;
  157. packet.q1 = q1;
  158. packet.q2 = q2;
  159. packet.q3 = q3;
  160. packet.q4 = q4;
  161. packet.roll = roll;
  162. packet.pitch = pitch;
  163. packet.yaw = yaw;
  164. packet.xacc = xacc;
  165. packet.yacc = yacc;
  166. packet.zacc = zacc;
  167. packet.xgyro = xgyro;
  168. packet.ygyro = ygyro;
  169. packet.zgyro = zgyro;
  170. packet.lat = lat;
  171. packet.lon = lon;
  172. packet.alt = alt;
  173. packet.std_dev_horz = std_dev_horz;
  174. packet.std_dev_vert = std_dev_vert;
  175. packet.vn = vn;
  176. packet.ve = ve;
  177. packet.vd = vd;
  178. packet.lat_int = lat_int;
  179. packet.lon_int = lon_int;
  180. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIM_STATE_LEN);
  181. #endif
  182. msg->msgid = MAVLINK_MSG_ID_SIM_STATE;
  183. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  184. }
  185. /**
  186. * @brief Pack a sim_state message
  187. * @param system_id ID of this system
  188. * @param component_id ID of this component (e.g. 200 for IMU)
  189. * @param status MAVLink status structure
  190. * @param msg The MAVLink message to compress the data into
  191. *
  192. * @param q1 True attitude quaternion component 1, w (1 in null-rotation)
  193. * @param q2 True attitude quaternion component 2, x (0 in null-rotation)
  194. * @param q3 True attitude quaternion component 3, y (0 in null-rotation)
  195. * @param q4 True attitude quaternion component 4, z (0 in null-rotation)
  196. * @param roll Attitude roll expressed as Euler angles, not recommended except for human-readable outputs
  197. * @param pitch Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs
  198. * @param yaw Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs
  199. * @param xacc [m/s/s] X acceleration
  200. * @param yacc [m/s/s] Y acceleration
  201. * @param zacc [m/s/s] Z acceleration
  202. * @param xgyro [rad/s] Angular speed around X axis
  203. * @param ygyro [rad/s] Angular speed around Y axis
  204. * @param zgyro [rad/s] Angular speed around Z axis
  205. * @param lat [deg] Latitude (lower precision). Both this and the lat_int field should be set.
  206. * @param lon [deg] Longitude (lower precision). Both this and the lon_int field should be set.
  207. * @param alt [m] Altitude
  208. * @param std_dev_horz Horizontal position standard deviation
  209. * @param std_dev_vert Vertical position standard deviation
  210. * @param vn [m/s] True velocity in north direction in earth-fixed NED frame
  211. * @param ve [m/s] True velocity in east direction in earth-fixed NED frame
  212. * @param vd [m/s] True velocity in down direction in earth-fixed NED frame
  213. * @param lat_int [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).
  214. * @param lon_int [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).
  215. * @return length of the message in bytes (excluding serial stream start sign)
  216. */
  217. static inline uint16_t mavlink_msg_sim_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  218. float q1, float q2, float q3, float q4, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lon, float alt, float std_dev_horz, float std_dev_vert, float vn, float ve, float vd, int32_t lat_int, int32_t lon_int)
  219. {
  220. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  221. char buf[MAVLINK_MSG_ID_SIM_STATE_LEN];
  222. _mav_put_float(buf, 0, q1);
  223. _mav_put_float(buf, 4, q2);
  224. _mav_put_float(buf, 8, q3);
  225. _mav_put_float(buf, 12, q4);
  226. _mav_put_float(buf, 16, roll);
  227. _mav_put_float(buf, 20, pitch);
  228. _mav_put_float(buf, 24, yaw);
  229. _mav_put_float(buf, 28, xacc);
  230. _mav_put_float(buf, 32, yacc);
  231. _mav_put_float(buf, 36, zacc);
  232. _mav_put_float(buf, 40, xgyro);
  233. _mav_put_float(buf, 44, ygyro);
  234. _mav_put_float(buf, 48, zgyro);
  235. _mav_put_float(buf, 52, lat);
  236. _mav_put_float(buf, 56, lon);
  237. _mav_put_float(buf, 60, alt);
  238. _mav_put_float(buf, 64, std_dev_horz);
  239. _mav_put_float(buf, 68, std_dev_vert);
  240. _mav_put_float(buf, 72, vn);
  241. _mav_put_float(buf, 76, ve);
  242. _mav_put_float(buf, 80, vd);
  243. _mav_put_int32_t(buf, 84, lat_int);
  244. _mav_put_int32_t(buf, 88, lon_int);
  245. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIM_STATE_LEN);
  246. #else
  247. mavlink_sim_state_t packet;
  248. packet.q1 = q1;
  249. packet.q2 = q2;
  250. packet.q3 = q3;
  251. packet.q4 = q4;
  252. packet.roll = roll;
  253. packet.pitch = pitch;
  254. packet.yaw = yaw;
  255. packet.xacc = xacc;
  256. packet.yacc = yacc;
  257. packet.zacc = zacc;
  258. packet.xgyro = xgyro;
  259. packet.ygyro = ygyro;
  260. packet.zgyro = zgyro;
  261. packet.lat = lat;
  262. packet.lon = lon;
  263. packet.alt = alt;
  264. packet.std_dev_horz = std_dev_horz;
  265. packet.std_dev_vert = std_dev_vert;
  266. packet.vn = vn;
  267. packet.ve = ve;
  268. packet.vd = vd;
  269. packet.lat_int = lat_int;
  270. packet.lon_int = lon_int;
  271. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIM_STATE_LEN);
  272. #endif
  273. msg->msgid = MAVLINK_MSG_ID_SIM_STATE;
  274. #if MAVLINK_CRC_EXTRA
  275. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  276. #else
  277. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN);
  278. #endif
  279. }
  280. /**
  281. * @brief Pack a sim_state message on a channel
  282. * @param system_id ID of this system
  283. * @param component_id ID of this component (e.g. 200 for IMU)
  284. * @param chan The MAVLink channel this message will be sent over
  285. * @param msg The MAVLink message to compress the data into
  286. * @param q1 True attitude quaternion component 1, w (1 in null-rotation)
  287. * @param q2 True attitude quaternion component 2, x (0 in null-rotation)
  288. * @param q3 True attitude quaternion component 3, y (0 in null-rotation)
  289. * @param q4 True attitude quaternion component 4, z (0 in null-rotation)
  290. * @param roll Attitude roll expressed as Euler angles, not recommended except for human-readable outputs
  291. * @param pitch Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs
  292. * @param yaw Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs
  293. * @param xacc [m/s/s] X acceleration
  294. * @param yacc [m/s/s] Y acceleration
  295. * @param zacc [m/s/s] Z acceleration
  296. * @param xgyro [rad/s] Angular speed around X axis
  297. * @param ygyro [rad/s] Angular speed around Y axis
  298. * @param zgyro [rad/s] Angular speed around Z axis
  299. * @param lat [deg] Latitude (lower precision). Both this and the lat_int field should be set.
  300. * @param lon [deg] Longitude (lower precision). Both this and the lon_int field should be set.
  301. * @param alt [m] Altitude
  302. * @param std_dev_horz Horizontal position standard deviation
  303. * @param std_dev_vert Vertical position standard deviation
  304. * @param vn [m/s] True velocity in north direction in earth-fixed NED frame
  305. * @param ve [m/s] True velocity in east direction in earth-fixed NED frame
  306. * @param vd [m/s] True velocity in down direction in earth-fixed NED frame
  307. * @param lat_int [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).
  308. * @param lon_int [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).
  309. * @return length of the message in bytes (excluding serial stream start sign)
  310. */
  311. static inline uint16_t mavlink_msg_sim_state_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  312. mavlink_message_t* msg,
  313. float q1,float q2,float q3,float q4,float roll,float pitch,float yaw,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,float lat,float lon,float alt,float std_dev_horz,float std_dev_vert,float vn,float ve,float vd,int32_t lat_int,int32_t lon_int)
  314. {
  315. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  316. char buf[MAVLINK_MSG_ID_SIM_STATE_LEN];
  317. _mav_put_float(buf, 0, q1);
  318. _mav_put_float(buf, 4, q2);
  319. _mav_put_float(buf, 8, q3);
  320. _mav_put_float(buf, 12, q4);
  321. _mav_put_float(buf, 16, roll);
  322. _mav_put_float(buf, 20, pitch);
  323. _mav_put_float(buf, 24, yaw);
  324. _mav_put_float(buf, 28, xacc);
  325. _mav_put_float(buf, 32, yacc);
  326. _mav_put_float(buf, 36, zacc);
  327. _mav_put_float(buf, 40, xgyro);
  328. _mav_put_float(buf, 44, ygyro);
  329. _mav_put_float(buf, 48, zgyro);
  330. _mav_put_float(buf, 52, lat);
  331. _mav_put_float(buf, 56, lon);
  332. _mav_put_float(buf, 60, alt);
  333. _mav_put_float(buf, 64, std_dev_horz);
  334. _mav_put_float(buf, 68, std_dev_vert);
  335. _mav_put_float(buf, 72, vn);
  336. _mav_put_float(buf, 76, ve);
  337. _mav_put_float(buf, 80, vd);
  338. _mav_put_int32_t(buf, 84, lat_int);
  339. _mav_put_int32_t(buf, 88, lon_int);
  340. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIM_STATE_LEN);
  341. #else
  342. mavlink_sim_state_t packet;
  343. packet.q1 = q1;
  344. packet.q2 = q2;
  345. packet.q3 = q3;
  346. packet.q4 = q4;
  347. packet.roll = roll;
  348. packet.pitch = pitch;
  349. packet.yaw = yaw;
  350. packet.xacc = xacc;
  351. packet.yacc = yacc;
  352. packet.zacc = zacc;
  353. packet.xgyro = xgyro;
  354. packet.ygyro = ygyro;
  355. packet.zgyro = zgyro;
  356. packet.lat = lat;
  357. packet.lon = lon;
  358. packet.alt = alt;
  359. packet.std_dev_horz = std_dev_horz;
  360. packet.std_dev_vert = std_dev_vert;
  361. packet.vn = vn;
  362. packet.ve = ve;
  363. packet.vd = vd;
  364. packet.lat_int = lat_int;
  365. packet.lon_int = lon_int;
  366. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIM_STATE_LEN);
  367. #endif
  368. msg->msgid = MAVLINK_MSG_ID_SIM_STATE;
  369. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  370. }
  371. /**
  372. * @brief Encode a sim_state struct
  373. *
  374. * @param system_id ID of this system
  375. * @param component_id ID of this component (e.g. 200 for IMU)
  376. * @param msg The MAVLink message to compress the data into
  377. * @param sim_state C-struct to read the message contents from
  378. */
  379. static inline uint16_t mavlink_msg_sim_state_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sim_state_t* sim_state)
  380. {
  381. return mavlink_msg_sim_state_pack(system_id, component_id, msg, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int);
  382. }
  383. /**
  384. * @brief Encode a sim_state struct on a channel
  385. *
  386. * @param system_id ID of this system
  387. * @param component_id ID of this component (e.g. 200 for IMU)
  388. * @param chan The MAVLink channel this message will be sent over
  389. * @param msg The MAVLink message to compress the data into
  390. * @param sim_state C-struct to read the message contents from
  391. */
  392. static inline uint16_t mavlink_msg_sim_state_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sim_state_t* sim_state)
  393. {
  394. return mavlink_msg_sim_state_pack_chan(system_id, component_id, chan, msg, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int);
  395. }
  396. /**
  397. * @brief Encode a sim_state struct with provided status structure
  398. *
  399. * @param system_id ID of this system
  400. * @param component_id ID of this component (e.g. 200 for IMU)
  401. * @param status MAVLink status structure
  402. * @param msg The MAVLink message to compress the data into
  403. * @param sim_state C-struct to read the message contents from
  404. */
  405. static inline uint16_t mavlink_msg_sim_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sim_state_t* sim_state)
  406. {
  407. return mavlink_msg_sim_state_pack_status(system_id, component_id, _status, msg, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int);
  408. }
  409. /**
  410. * @brief Send a sim_state message
  411. * @param chan MAVLink channel to send the message
  412. *
  413. * @param q1 True attitude quaternion component 1, w (1 in null-rotation)
  414. * @param q2 True attitude quaternion component 2, x (0 in null-rotation)
  415. * @param q3 True attitude quaternion component 3, y (0 in null-rotation)
  416. * @param q4 True attitude quaternion component 4, z (0 in null-rotation)
  417. * @param roll Attitude roll expressed as Euler angles, not recommended except for human-readable outputs
  418. * @param pitch Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs
  419. * @param yaw Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs
  420. * @param xacc [m/s/s] X acceleration
  421. * @param yacc [m/s/s] Y acceleration
  422. * @param zacc [m/s/s] Z acceleration
  423. * @param xgyro [rad/s] Angular speed around X axis
  424. * @param ygyro [rad/s] Angular speed around Y axis
  425. * @param zgyro [rad/s] Angular speed around Z axis
  426. * @param lat [deg] Latitude (lower precision). Both this and the lat_int field should be set.
  427. * @param lon [deg] Longitude (lower precision). Both this and the lon_int field should be set.
  428. * @param alt [m] Altitude
  429. * @param std_dev_horz Horizontal position standard deviation
  430. * @param std_dev_vert Vertical position standard deviation
  431. * @param vn [m/s] True velocity in north direction in earth-fixed NED frame
  432. * @param ve [m/s] True velocity in east direction in earth-fixed NED frame
  433. * @param vd [m/s] True velocity in down direction in earth-fixed NED frame
  434. * @param lat_int [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).
  435. * @param lon_int [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).
  436. */
  437. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  438. static inline void mavlink_msg_sim_state_send(mavlink_channel_t chan, float q1, float q2, float q3, float q4, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lon, float alt, float std_dev_horz, float std_dev_vert, float vn, float ve, float vd, int32_t lat_int, int32_t lon_int)
  439. {
  440. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  441. char buf[MAVLINK_MSG_ID_SIM_STATE_LEN];
  442. _mav_put_float(buf, 0, q1);
  443. _mav_put_float(buf, 4, q2);
  444. _mav_put_float(buf, 8, q3);
  445. _mav_put_float(buf, 12, q4);
  446. _mav_put_float(buf, 16, roll);
  447. _mav_put_float(buf, 20, pitch);
  448. _mav_put_float(buf, 24, yaw);
  449. _mav_put_float(buf, 28, xacc);
  450. _mav_put_float(buf, 32, yacc);
  451. _mav_put_float(buf, 36, zacc);
  452. _mav_put_float(buf, 40, xgyro);
  453. _mav_put_float(buf, 44, ygyro);
  454. _mav_put_float(buf, 48, zgyro);
  455. _mav_put_float(buf, 52, lat);
  456. _mav_put_float(buf, 56, lon);
  457. _mav_put_float(buf, 60, alt);
  458. _mav_put_float(buf, 64, std_dev_horz);
  459. _mav_put_float(buf, 68, std_dev_vert);
  460. _mav_put_float(buf, 72, vn);
  461. _mav_put_float(buf, 76, ve);
  462. _mav_put_float(buf, 80, vd);
  463. _mav_put_int32_t(buf, 84, lat_int);
  464. _mav_put_int32_t(buf, 88, lon_int);
  465. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIM_STATE, buf, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  466. #else
  467. mavlink_sim_state_t packet;
  468. packet.q1 = q1;
  469. packet.q2 = q2;
  470. packet.q3 = q3;
  471. packet.q4 = q4;
  472. packet.roll = roll;
  473. packet.pitch = pitch;
  474. packet.yaw = yaw;
  475. packet.xacc = xacc;
  476. packet.yacc = yacc;
  477. packet.zacc = zacc;
  478. packet.xgyro = xgyro;
  479. packet.ygyro = ygyro;
  480. packet.zgyro = zgyro;
  481. packet.lat = lat;
  482. packet.lon = lon;
  483. packet.alt = alt;
  484. packet.std_dev_horz = std_dev_horz;
  485. packet.std_dev_vert = std_dev_vert;
  486. packet.vn = vn;
  487. packet.ve = ve;
  488. packet.vd = vd;
  489. packet.lat_int = lat_int;
  490. packet.lon_int = lon_int;
  491. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIM_STATE, (const char *)&packet, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  492. #endif
  493. }
  494. /**
  495. * @brief Send a sim_state message
  496. * @param chan MAVLink channel to send the message
  497. * @param struct The MAVLink struct to serialize
  498. */
  499. static inline void mavlink_msg_sim_state_send_struct(mavlink_channel_t chan, const mavlink_sim_state_t* sim_state)
  500. {
  501. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  502. mavlink_msg_sim_state_send(chan, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int);
  503. #else
  504. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIM_STATE, (const char *)sim_state, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  505. #endif
  506. }
  507. #if MAVLINK_MSG_ID_SIM_STATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  508. /*
  509. This variant of _send() can be used to save stack space by re-using
  510. memory from the receive buffer. The caller provides a
  511. mavlink_message_t which is the size of a full mavlink message. This
  512. is usually the receive buffer for the channel, and allows a reply to an
  513. incoming message with minimum stack space usage.
  514. */
  515. static inline void mavlink_msg_sim_state_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float q1, float q2, float q3, float q4, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lon, float alt, float std_dev_horz, float std_dev_vert, float vn, float ve, float vd, int32_t lat_int, int32_t lon_int)
  516. {
  517. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  518. char *buf = (char *)msgbuf;
  519. _mav_put_float(buf, 0, q1);
  520. _mav_put_float(buf, 4, q2);
  521. _mav_put_float(buf, 8, q3);
  522. _mav_put_float(buf, 12, q4);
  523. _mav_put_float(buf, 16, roll);
  524. _mav_put_float(buf, 20, pitch);
  525. _mav_put_float(buf, 24, yaw);
  526. _mav_put_float(buf, 28, xacc);
  527. _mav_put_float(buf, 32, yacc);
  528. _mav_put_float(buf, 36, zacc);
  529. _mav_put_float(buf, 40, xgyro);
  530. _mav_put_float(buf, 44, ygyro);
  531. _mav_put_float(buf, 48, zgyro);
  532. _mav_put_float(buf, 52, lat);
  533. _mav_put_float(buf, 56, lon);
  534. _mav_put_float(buf, 60, alt);
  535. _mav_put_float(buf, 64, std_dev_horz);
  536. _mav_put_float(buf, 68, std_dev_vert);
  537. _mav_put_float(buf, 72, vn);
  538. _mav_put_float(buf, 76, ve);
  539. _mav_put_float(buf, 80, vd);
  540. _mav_put_int32_t(buf, 84, lat_int);
  541. _mav_put_int32_t(buf, 88, lon_int);
  542. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIM_STATE, buf, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  543. #else
  544. mavlink_sim_state_t *packet = (mavlink_sim_state_t *)msgbuf;
  545. packet->q1 = q1;
  546. packet->q2 = q2;
  547. packet->q3 = q3;
  548. packet->q4 = q4;
  549. packet->roll = roll;
  550. packet->pitch = pitch;
  551. packet->yaw = yaw;
  552. packet->xacc = xacc;
  553. packet->yacc = yacc;
  554. packet->zacc = zacc;
  555. packet->xgyro = xgyro;
  556. packet->ygyro = ygyro;
  557. packet->zgyro = zgyro;
  558. packet->lat = lat;
  559. packet->lon = lon;
  560. packet->alt = alt;
  561. packet->std_dev_horz = std_dev_horz;
  562. packet->std_dev_vert = std_dev_vert;
  563. packet->vn = vn;
  564. packet->ve = ve;
  565. packet->vd = vd;
  566. packet->lat_int = lat_int;
  567. packet->lon_int = lon_int;
  568. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIM_STATE, (const char *)packet, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC);
  569. #endif
  570. }
  571. #endif
  572. #endif
  573. // MESSAGE SIM_STATE UNPACKING
  574. /**
  575. * @brief Get field q1 from sim_state message
  576. *
  577. * @return True attitude quaternion component 1, w (1 in null-rotation)
  578. */
  579. static inline float mavlink_msg_sim_state_get_q1(const mavlink_message_t* msg)
  580. {
  581. return _MAV_RETURN_float(msg, 0);
  582. }
  583. /**
  584. * @brief Get field q2 from sim_state message
  585. *
  586. * @return True attitude quaternion component 2, x (0 in null-rotation)
  587. */
  588. static inline float mavlink_msg_sim_state_get_q2(const mavlink_message_t* msg)
  589. {
  590. return _MAV_RETURN_float(msg, 4);
  591. }
  592. /**
  593. * @brief Get field q3 from sim_state message
  594. *
  595. * @return True attitude quaternion component 3, y (0 in null-rotation)
  596. */
  597. static inline float mavlink_msg_sim_state_get_q3(const mavlink_message_t* msg)
  598. {
  599. return _MAV_RETURN_float(msg, 8);
  600. }
  601. /**
  602. * @brief Get field q4 from sim_state message
  603. *
  604. * @return True attitude quaternion component 4, z (0 in null-rotation)
  605. */
  606. static inline float mavlink_msg_sim_state_get_q4(const mavlink_message_t* msg)
  607. {
  608. return _MAV_RETURN_float(msg, 12);
  609. }
  610. /**
  611. * @brief Get field roll from sim_state message
  612. *
  613. * @return Attitude roll expressed as Euler angles, not recommended except for human-readable outputs
  614. */
  615. static inline float mavlink_msg_sim_state_get_roll(const mavlink_message_t* msg)
  616. {
  617. return _MAV_RETURN_float(msg, 16);
  618. }
  619. /**
  620. * @brief Get field pitch from sim_state message
  621. *
  622. * @return Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs
  623. */
  624. static inline float mavlink_msg_sim_state_get_pitch(const mavlink_message_t* msg)
  625. {
  626. return _MAV_RETURN_float(msg, 20);
  627. }
  628. /**
  629. * @brief Get field yaw from sim_state message
  630. *
  631. * @return Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs
  632. */
  633. static inline float mavlink_msg_sim_state_get_yaw(const mavlink_message_t* msg)
  634. {
  635. return _MAV_RETURN_float(msg, 24);
  636. }
  637. /**
  638. * @brief Get field xacc from sim_state message
  639. *
  640. * @return [m/s/s] X acceleration
  641. */
  642. static inline float mavlink_msg_sim_state_get_xacc(const mavlink_message_t* msg)
  643. {
  644. return _MAV_RETURN_float(msg, 28);
  645. }
  646. /**
  647. * @brief Get field yacc from sim_state message
  648. *
  649. * @return [m/s/s] Y acceleration
  650. */
  651. static inline float mavlink_msg_sim_state_get_yacc(const mavlink_message_t* msg)
  652. {
  653. return _MAV_RETURN_float(msg, 32);
  654. }
  655. /**
  656. * @brief Get field zacc from sim_state message
  657. *
  658. * @return [m/s/s] Z acceleration
  659. */
  660. static inline float mavlink_msg_sim_state_get_zacc(const mavlink_message_t* msg)
  661. {
  662. return _MAV_RETURN_float(msg, 36);
  663. }
  664. /**
  665. * @brief Get field xgyro from sim_state message
  666. *
  667. * @return [rad/s] Angular speed around X axis
  668. */
  669. static inline float mavlink_msg_sim_state_get_xgyro(const mavlink_message_t* msg)
  670. {
  671. return _MAV_RETURN_float(msg, 40);
  672. }
  673. /**
  674. * @brief Get field ygyro from sim_state message
  675. *
  676. * @return [rad/s] Angular speed around Y axis
  677. */
  678. static inline float mavlink_msg_sim_state_get_ygyro(const mavlink_message_t* msg)
  679. {
  680. return _MAV_RETURN_float(msg, 44);
  681. }
  682. /**
  683. * @brief Get field zgyro from sim_state message
  684. *
  685. * @return [rad/s] Angular speed around Z axis
  686. */
  687. static inline float mavlink_msg_sim_state_get_zgyro(const mavlink_message_t* msg)
  688. {
  689. return _MAV_RETURN_float(msg, 48);
  690. }
  691. /**
  692. * @brief Get field lat from sim_state message
  693. *
  694. * @return [deg] Latitude (lower precision). Both this and the lat_int field should be set.
  695. */
  696. static inline float mavlink_msg_sim_state_get_lat(const mavlink_message_t* msg)
  697. {
  698. return _MAV_RETURN_float(msg, 52);
  699. }
  700. /**
  701. * @brief Get field lon from sim_state message
  702. *
  703. * @return [deg] Longitude (lower precision). Both this and the lon_int field should be set.
  704. */
  705. static inline float mavlink_msg_sim_state_get_lon(const mavlink_message_t* msg)
  706. {
  707. return _MAV_RETURN_float(msg, 56);
  708. }
  709. /**
  710. * @brief Get field alt from sim_state message
  711. *
  712. * @return [m] Altitude
  713. */
  714. static inline float mavlink_msg_sim_state_get_alt(const mavlink_message_t* msg)
  715. {
  716. return _MAV_RETURN_float(msg, 60);
  717. }
  718. /**
  719. * @brief Get field std_dev_horz from sim_state message
  720. *
  721. * @return Horizontal position standard deviation
  722. */
  723. static inline float mavlink_msg_sim_state_get_std_dev_horz(const mavlink_message_t* msg)
  724. {
  725. return _MAV_RETURN_float(msg, 64);
  726. }
  727. /**
  728. * @brief Get field std_dev_vert from sim_state message
  729. *
  730. * @return Vertical position standard deviation
  731. */
  732. static inline float mavlink_msg_sim_state_get_std_dev_vert(const mavlink_message_t* msg)
  733. {
  734. return _MAV_RETURN_float(msg, 68);
  735. }
  736. /**
  737. * @brief Get field vn from sim_state message
  738. *
  739. * @return [m/s] True velocity in north direction in earth-fixed NED frame
  740. */
  741. static inline float mavlink_msg_sim_state_get_vn(const mavlink_message_t* msg)
  742. {
  743. return _MAV_RETURN_float(msg, 72);
  744. }
  745. /**
  746. * @brief Get field ve from sim_state message
  747. *
  748. * @return [m/s] True velocity in east direction in earth-fixed NED frame
  749. */
  750. static inline float mavlink_msg_sim_state_get_ve(const mavlink_message_t* msg)
  751. {
  752. return _MAV_RETURN_float(msg, 76);
  753. }
  754. /**
  755. * @brief Get field vd from sim_state message
  756. *
  757. * @return [m/s] True velocity in down direction in earth-fixed NED frame
  758. */
  759. static inline float mavlink_msg_sim_state_get_vd(const mavlink_message_t* msg)
  760. {
  761. return _MAV_RETURN_float(msg, 80);
  762. }
  763. /**
  764. * @brief Get field lat_int from sim_state message
  765. *
  766. * @return [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred).
  767. */
  768. static inline int32_t mavlink_msg_sim_state_get_lat_int(const mavlink_message_t* msg)
  769. {
  770. return _MAV_RETURN_int32_t(msg, 84);
  771. }
  772. /**
  773. * @brief Get field lon_int from sim_state message
  774. *
  775. * @return [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred).
  776. */
  777. static inline int32_t mavlink_msg_sim_state_get_lon_int(const mavlink_message_t* msg)
  778. {
  779. return _MAV_RETURN_int32_t(msg, 88);
  780. }
  781. /**
  782. * @brief Decode a sim_state message into a struct
  783. *
  784. * @param msg The message to decode
  785. * @param sim_state C-struct to decode the message contents into
  786. */
  787. static inline void mavlink_msg_sim_state_decode(const mavlink_message_t* msg, mavlink_sim_state_t* sim_state)
  788. {
  789. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  790. sim_state->q1 = mavlink_msg_sim_state_get_q1(msg);
  791. sim_state->q2 = mavlink_msg_sim_state_get_q2(msg);
  792. sim_state->q3 = mavlink_msg_sim_state_get_q3(msg);
  793. sim_state->q4 = mavlink_msg_sim_state_get_q4(msg);
  794. sim_state->roll = mavlink_msg_sim_state_get_roll(msg);
  795. sim_state->pitch = mavlink_msg_sim_state_get_pitch(msg);
  796. sim_state->yaw = mavlink_msg_sim_state_get_yaw(msg);
  797. sim_state->xacc = mavlink_msg_sim_state_get_xacc(msg);
  798. sim_state->yacc = mavlink_msg_sim_state_get_yacc(msg);
  799. sim_state->zacc = mavlink_msg_sim_state_get_zacc(msg);
  800. sim_state->xgyro = mavlink_msg_sim_state_get_xgyro(msg);
  801. sim_state->ygyro = mavlink_msg_sim_state_get_ygyro(msg);
  802. sim_state->zgyro = mavlink_msg_sim_state_get_zgyro(msg);
  803. sim_state->lat = mavlink_msg_sim_state_get_lat(msg);
  804. sim_state->lon = mavlink_msg_sim_state_get_lon(msg);
  805. sim_state->alt = mavlink_msg_sim_state_get_alt(msg);
  806. sim_state->std_dev_horz = mavlink_msg_sim_state_get_std_dev_horz(msg);
  807. sim_state->std_dev_vert = mavlink_msg_sim_state_get_std_dev_vert(msg);
  808. sim_state->vn = mavlink_msg_sim_state_get_vn(msg);
  809. sim_state->ve = mavlink_msg_sim_state_get_ve(msg);
  810. sim_state->vd = mavlink_msg_sim_state_get_vd(msg);
  811. sim_state->lat_int = mavlink_msg_sim_state_get_lat_int(msg);
  812. sim_state->lon_int = mavlink_msg_sim_state_get_lon_int(msg);
  813. #else
  814. uint8_t len = msg->len < MAVLINK_MSG_ID_SIM_STATE_LEN? msg->len : MAVLINK_MSG_ID_SIM_STATE_LEN;
  815. memset(sim_state, 0, MAVLINK_MSG_ID_SIM_STATE_LEN);
  816. memcpy(sim_state, _MAV_PAYLOAD(msg), len);
  817. #endif
  818. }