mavlink_msg_home_position.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. #pragma once
  2. // MESSAGE HOME_POSITION PACKING
  3. #define MAVLINK_MSG_ID_HOME_POSITION 242
  4. MAVPACKED(
  5. typedef struct __mavlink_home_position_t {
  6. int32_t latitude; /*< [degE7] Latitude (WGS84)*/
  7. int32_t longitude; /*< [degE7] Longitude (WGS84)*/
  8. int32_t altitude; /*< [mm] Altitude (MSL). Positive for up.*/
  9. float x; /*< [m] Local X position of this position in the local coordinate frame (NED)*/
  10. float y; /*< [m] Local Y position of this position in the local coordinate frame (NED)*/
  11. float z; /*< [m] Local Z position of this position in the local coordinate frame (NED: positive "down")*/
  12. float q[4]; /*<
  13. Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position.
  14. Used to indicate the heading and slope of the ground.
  15. All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied.
  16. */
  17. float approach_x; /*< [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.*/
  18. float approach_y; /*< [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.*/
  19. float approach_z; /*< [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.*/
  20. 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 of the number.*/
  21. }) mavlink_home_position_t;
  22. #define MAVLINK_MSG_ID_HOME_POSITION_LEN 60
  23. #define MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN 52
  24. #define MAVLINK_MSG_ID_242_LEN 60
  25. #define MAVLINK_MSG_ID_242_MIN_LEN 52
  26. #define MAVLINK_MSG_ID_HOME_POSITION_CRC 104
  27. #define MAVLINK_MSG_ID_242_CRC 104
  28. #define MAVLINK_MSG_HOME_POSITION_FIELD_Q_LEN 4
  29. #if MAVLINK_COMMAND_24BIT
  30. #define MAVLINK_MESSAGE_INFO_HOME_POSITION { \
  31. 242, \
  32. "HOME_POSITION", \
  33. 11, \
  34. { { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_home_position_t, latitude) }, \
  35. { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_home_position_t, longitude) }, \
  36. { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_home_position_t, altitude) }, \
  37. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_home_position_t, x) }, \
  38. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_home_position_t, y) }, \
  39. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_home_position_t, z) }, \
  40. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_home_position_t, q) }, \
  41. { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_home_position_t, approach_x) }, \
  42. { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_home_position_t, approach_y) }, \
  43. { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_home_position_t, approach_z) }, \
  44. { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 52, offsetof(mavlink_home_position_t, time_usec) }, \
  45. } \
  46. }
  47. #else
  48. #define MAVLINK_MESSAGE_INFO_HOME_POSITION { \
  49. "HOME_POSITION", \
  50. 11, \
  51. { { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_home_position_t, latitude) }, \
  52. { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_home_position_t, longitude) }, \
  53. { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_home_position_t, altitude) }, \
  54. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_home_position_t, x) }, \
  55. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_home_position_t, y) }, \
  56. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_home_position_t, z) }, \
  57. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_home_position_t, q) }, \
  58. { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_home_position_t, approach_x) }, \
  59. { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_home_position_t, approach_y) }, \
  60. { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_home_position_t, approach_z) }, \
  61. { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 52, offsetof(mavlink_home_position_t, time_usec) }, \
  62. } \
  63. }
  64. #endif
  65. /**
  66. * @brief Pack a home_position message
  67. * @param system_id ID of this system
  68. * @param component_id ID of this component (e.g. 200 for IMU)
  69. * @param msg The MAVLink message to compress the data into
  70. *
  71. * @param latitude [degE7] Latitude (WGS84)
  72. * @param longitude [degE7] Longitude (WGS84)
  73. * @param altitude [mm] Altitude (MSL). Positive for up.
  74. * @param x [m] Local X position of this position in the local coordinate frame (NED)
  75. * @param y [m] Local Y position of this position in the local coordinate frame (NED)
  76. * @param z [m] Local Z position of this position in the local coordinate frame (NED: positive "down")
  77. * @param q
  78. Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position.
  79. Used to indicate the heading and slope of the ground.
  80. All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied.
  81. * @param approach_x [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  82. * @param approach_y [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  83. * @param approach_z [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  84. * @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 of the number.
  85. * @return length of the message in bytes (excluding serial stream start sign)
  86. */
  87. static inline uint16_t mavlink_msg_home_position_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  88. int32_t latitude, int32_t longitude, int32_t altitude, float x, float y, float z, const float *q, float approach_x, float approach_y, float approach_z, uint64_t time_usec)
  89. {
  90. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  91. char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN];
  92. _mav_put_int32_t(buf, 0, latitude);
  93. _mav_put_int32_t(buf, 4, longitude);
  94. _mav_put_int32_t(buf, 8, altitude);
  95. _mav_put_float(buf, 12, x);
  96. _mav_put_float(buf, 16, y);
  97. _mav_put_float(buf, 20, z);
  98. _mav_put_float(buf, 40, approach_x);
  99. _mav_put_float(buf, 44, approach_y);
  100. _mav_put_float(buf, 48, approach_z);
  101. _mav_put_uint64_t(buf, 52, time_usec);
  102. _mav_put_float_array(buf, 24, q, 4);
  103. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HOME_POSITION_LEN);
  104. #else
  105. mavlink_home_position_t packet;
  106. packet.latitude = latitude;
  107. packet.longitude = longitude;
  108. packet.altitude = altitude;
  109. packet.x = x;
  110. packet.y = y;
  111. packet.z = z;
  112. packet.approach_x = approach_x;
  113. packet.approach_y = approach_y;
  114. packet.approach_z = approach_z;
  115. packet.time_usec = time_usec;
  116. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  117. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HOME_POSITION_LEN);
  118. #endif
  119. msg->msgid = MAVLINK_MSG_ID_HOME_POSITION;
  120. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  121. }
  122. /**
  123. * @brief Pack a home_position message on a channel
  124. * @param system_id ID of this system
  125. * @param component_id ID of this component (e.g. 200 for IMU)
  126. * @param chan The MAVLink channel this message will be sent over
  127. * @param msg The MAVLink message to compress the data into
  128. * @param latitude [degE7] Latitude (WGS84)
  129. * @param longitude [degE7] Longitude (WGS84)
  130. * @param altitude [mm] Altitude (MSL). Positive for up.
  131. * @param x [m] Local X position of this position in the local coordinate frame (NED)
  132. * @param y [m] Local Y position of this position in the local coordinate frame (NED)
  133. * @param z [m] Local Z position of this position in the local coordinate frame (NED: positive "down")
  134. * @param q
  135. Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position.
  136. Used to indicate the heading and slope of the ground.
  137. All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied.
  138. * @param approach_x [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  139. * @param approach_y [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  140. * @param approach_z [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  141. * @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 of the number.
  142. * @return length of the message in bytes (excluding serial stream start sign)
  143. */
  144. static inline uint16_t mavlink_msg_home_position_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  145. mavlink_message_t* msg,
  146. int32_t latitude,int32_t longitude,int32_t altitude,float x,float y,float z,const float *q,float approach_x,float approach_y,float approach_z,uint64_t time_usec)
  147. {
  148. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  149. char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN];
  150. _mav_put_int32_t(buf, 0, latitude);
  151. _mav_put_int32_t(buf, 4, longitude);
  152. _mav_put_int32_t(buf, 8, altitude);
  153. _mav_put_float(buf, 12, x);
  154. _mav_put_float(buf, 16, y);
  155. _mav_put_float(buf, 20, z);
  156. _mav_put_float(buf, 40, approach_x);
  157. _mav_put_float(buf, 44, approach_y);
  158. _mav_put_float(buf, 48, approach_z);
  159. _mav_put_uint64_t(buf, 52, time_usec);
  160. _mav_put_float_array(buf, 24, q, 4);
  161. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HOME_POSITION_LEN);
  162. #else
  163. mavlink_home_position_t packet;
  164. packet.latitude = latitude;
  165. packet.longitude = longitude;
  166. packet.altitude = altitude;
  167. packet.x = x;
  168. packet.y = y;
  169. packet.z = z;
  170. packet.approach_x = approach_x;
  171. packet.approach_y = approach_y;
  172. packet.approach_z = approach_z;
  173. packet.time_usec = time_usec;
  174. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  175. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HOME_POSITION_LEN);
  176. #endif
  177. msg->msgid = MAVLINK_MSG_ID_HOME_POSITION;
  178. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  179. }
  180. /**
  181. * @brief Encode a home_position struct
  182. *
  183. * @param system_id ID of this system
  184. * @param component_id ID of this component (e.g. 200 for IMU)
  185. * @param msg The MAVLink message to compress the data into
  186. * @param home_position C-struct to read the message contents from
  187. */
  188. static inline uint16_t mavlink_msg_home_position_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_home_position_t* home_position)
  189. {
  190. return mavlink_msg_home_position_pack(system_id, component_id, msg, home_position->latitude, home_position->longitude, home_position->altitude, home_position->x, home_position->y, home_position->z, home_position->q, home_position->approach_x, home_position->approach_y, home_position->approach_z, home_position->time_usec);
  191. }
  192. /**
  193. * @brief Encode a home_position struct on a channel
  194. *
  195. * @param system_id ID of this system
  196. * @param component_id ID of this component (e.g. 200 for IMU)
  197. * @param chan The MAVLink channel this message will be sent over
  198. * @param msg The MAVLink message to compress the data into
  199. * @param home_position C-struct to read the message contents from
  200. */
  201. static inline uint16_t mavlink_msg_home_position_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_home_position_t* home_position)
  202. {
  203. return mavlink_msg_home_position_pack_chan(system_id, component_id, chan, msg, home_position->latitude, home_position->longitude, home_position->altitude, home_position->x, home_position->y, home_position->z, home_position->q, home_position->approach_x, home_position->approach_y, home_position->approach_z, home_position->time_usec);
  204. }
  205. /**
  206. * @brief Send a home_position message
  207. * @param chan MAVLink channel to send the message
  208. *
  209. * @param latitude [degE7] Latitude (WGS84)
  210. * @param longitude [degE7] Longitude (WGS84)
  211. * @param altitude [mm] Altitude (MSL). Positive for up.
  212. * @param x [m] Local X position of this position in the local coordinate frame (NED)
  213. * @param y [m] Local Y position of this position in the local coordinate frame (NED)
  214. * @param z [m] Local Z position of this position in the local coordinate frame (NED: positive "down")
  215. * @param q
  216. Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position.
  217. Used to indicate the heading and slope of the ground.
  218. All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied.
  219. * @param approach_x [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  220. * @param approach_y [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  221. * @param approach_z [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  222. * @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 of the number.
  223. */
  224. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  225. static inline void mavlink_msg_home_position_send(mavlink_channel_t chan, int32_t latitude, int32_t longitude, int32_t altitude, float x, float y, float z, const float *q, float approach_x, float approach_y, float approach_z, uint64_t time_usec)
  226. {
  227. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  228. char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN];
  229. _mav_put_int32_t(buf, 0, latitude);
  230. _mav_put_int32_t(buf, 4, longitude);
  231. _mav_put_int32_t(buf, 8, altitude);
  232. _mav_put_float(buf, 12, x);
  233. _mav_put_float(buf, 16, y);
  234. _mav_put_float(buf, 20, z);
  235. _mav_put_float(buf, 40, approach_x);
  236. _mav_put_float(buf, 44, approach_y);
  237. _mav_put_float(buf, 48, approach_z);
  238. _mav_put_uint64_t(buf, 52, time_usec);
  239. _mav_put_float_array(buf, 24, q, 4);
  240. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HOME_POSITION, buf, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  241. #else
  242. mavlink_home_position_t packet;
  243. packet.latitude = latitude;
  244. packet.longitude = longitude;
  245. packet.altitude = altitude;
  246. packet.x = x;
  247. packet.y = y;
  248. packet.z = z;
  249. packet.approach_x = approach_x;
  250. packet.approach_y = approach_y;
  251. packet.approach_z = approach_z;
  252. packet.time_usec = time_usec;
  253. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  254. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HOME_POSITION, (const char *)&packet, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  255. #endif
  256. }
  257. /**
  258. * @brief Send a home_position message
  259. * @param chan MAVLink channel to send the message
  260. * @param struct The MAVLink struct to serialize
  261. */
  262. static inline void mavlink_msg_home_position_send_struct(mavlink_channel_t chan, const mavlink_home_position_t* home_position)
  263. {
  264. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  265. mavlink_msg_home_position_send(chan, home_position->latitude, home_position->longitude, home_position->altitude, home_position->x, home_position->y, home_position->z, home_position->q, home_position->approach_x, home_position->approach_y, home_position->approach_z, home_position->time_usec);
  266. #else
  267. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HOME_POSITION, (const char *)home_position, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  268. #endif
  269. }
  270. #if MAVLINK_MSG_ID_HOME_POSITION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  271. /*
  272. This variant of _send() can be used to save stack space by re-using
  273. memory from the receive buffer. The caller provides a
  274. mavlink_message_t which is the size of a full mavlink message. This
  275. is usually the receive buffer for the channel, and allows a reply to an
  276. incoming message with minimum stack space usage.
  277. */
  278. static inline void mavlink_msg_home_position_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t latitude, int32_t longitude, int32_t altitude, float x, float y, float z, const float *q, float approach_x, float approach_y, float approach_z, uint64_t time_usec)
  279. {
  280. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  281. char *buf = (char *)msgbuf;
  282. _mav_put_int32_t(buf, 0, latitude);
  283. _mav_put_int32_t(buf, 4, longitude);
  284. _mav_put_int32_t(buf, 8, altitude);
  285. _mav_put_float(buf, 12, x);
  286. _mav_put_float(buf, 16, y);
  287. _mav_put_float(buf, 20, z);
  288. _mav_put_float(buf, 40, approach_x);
  289. _mav_put_float(buf, 44, approach_y);
  290. _mav_put_float(buf, 48, approach_z);
  291. _mav_put_uint64_t(buf, 52, time_usec);
  292. _mav_put_float_array(buf, 24, q, 4);
  293. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HOME_POSITION, buf, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  294. #else
  295. mavlink_home_position_t *packet = (mavlink_home_position_t *)msgbuf;
  296. packet->latitude = latitude;
  297. packet->longitude = longitude;
  298. packet->altitude = altitude;
  299. packet->x = x;
  300. packet->y = y;
  301. packet->z = z;
  302. packet->approach_x = approach_x;
  303. packet->approach_y = approach_y;
  304. packet->approach_z = approach_z;
  305. packet->time_usec = time_usec;
  306. mav_array_memcpy(packet->q, q, sizeof(float)*4);
  307. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HOME_POSITION, (const char *)packet, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC);
  308. #endif
  309. }
  310. #endif
  311. #endif
  312. // MESSAGE HOME_POSITION UNPACKING
  313. /**
  314. * @brief Get field latitude from home_position message
  315. *
  316. * @return [degE7] Latitude (WGS84)
  317. */
  318. static inline int32_t mavlink_msg_home_position_get_latitude(const mavlink_message_t* msg)
  319. {
  320. return _MAV_RETURN_int32_t(msg, 0);
  321. }
  322. /**
  323. * @brief Get field longitude from home_position message
  324. *
  325. * @return [degE7] Longitude (WGS84)
  326. */
  327. static inline int32_t mavlink_msg_home_position_get_longitude(const mavlink_message_t* msg)
  328. {
  329. return _MAV_RETURN_int32_t(msg, 4);
  330. }
  331. /**
  332. * @brief Get field altitude from home_position message
  333. *
  334. * @return [mm] Altitude (MSL). Positive for up.
  335. */
  336. static inline int32_t mavlink_msg_home_position_get_altitude(const mavlink_message_t* msg)
  337. {
  338. return _MAV_RETURN_int32_t(msg, 8);
  339. }
  340. /**
  341. * @brief Get field x from home_position message
  342. *
  343. * @return [m] Local X position of this position in the local coordinate frame (NED)
  344. */
  345. static inline float mavlink_msg_home_position_get_x(const mavlink_message_t* msg)
  346. {
  347. return _MAV_RETURN_float(msg, 12);
  348. }
  349. /**
  350. * @brief Get field y from home_position message
  351. *
  352. * @return [m] Local Y position of this position in the local coordinate frame (NED)
  353. */
  354. static inline float mavlink_msg_home_position_get_y(const mavlink_message_t* msg)
  355. {
  356. return _MAV_RETURN_float(msg, 16);
  357. }
  358. /**
  359. * @brief Get field z from home_position message
  360. *
  361. * @return [m] Local Z position of this position in the local coordinate frame (NED: positive "down")
  362. */
  363. static inline float mavlink_msg_home_position_get_z(const mavlink_message_t* msg)
  364. {
  365. return _MAV_RETURN_float(msg, 20);
  366. }
  367. /**
  368. * @brief Get field q from home_position message
  369. *
  370. * @return
  371. Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position.
  372. Used to indicate the heading and slope of the ground.
  373. All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied.
  374. */
  375. static inline uint16_t mavlink_msg_home_position_get_q(const mavlink_message_t* msg, float *q)
  376. {
  377. return _MAV_RETURN_float_array(msg, q, 4, 24);
  378. }
  379. /**
  380. * @brief Get field approach_x from home_position message
  381. *
  382. * @return [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  383. */
  384. static inline float mavlink_msg_home_position_get_approach_x(const mavlink_message_t* msg)
  385. {
  386. return _MAV_RETURN_float(msg, 40);
  387. }
  388. /**
  389. * @brief Get field approach_y from home_position message
  390. *
  391. * @return [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  392. */
  393. static inline float mavlink_msg_home_position_get_approach_y(const mavlink_message_t* msg)
  394. {
  395. return _MAV_RETURN_float(msg, 44);
  396. }
  397. /**
  398. * @brief Get field approach_z from home_position message
  399. *
  400. * @return [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone.
  401. */
  402. static inline float mavlink_msg_home_position_get_approach_z(const mavlink_message_t* msg)
  403. {
  404. return _MAV_RETURN_float(msg, 48);
  405. }
  406. /**
  407. * @brief Get field time_usec from home_position message
  408. *
  409. * @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 of the number.
  410. */
  411. static inline uint64_t mavlink_msg_home_position_get_time_usec(const mavlink_message_t* msg)
  412. {
  413. return _MAV_RETURN_uint64_t(msg, 52);
  414. }
  415. /**
  416. * @brief Decode a home_position message into a struct
  417. *
  418. * @param msg The message to decode
  419. * @param home_position C-struct to decode the message contents into
  420. */
  421. static inline void mavlink_msg_home_position_decode(const mavlink_message_t* msg, mavlink_home_position_t* home_position)
  422. {
  423. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  424. home_position->latitude = mavlink_msg_home_position_get_latitude(msg);
  425. home_position->longitude = mavlink_msg_home_position_get_longitude(msg);
  426. home_position->altitude = mavlink_msg_home_position_get_altitude(msg);
  427. home_position->x = mavlink_msg_home_position_get_x(msg);
  428. home_position->y = mavlink_msg_home_position_get_y(msg);
  429. home_position->z = mavlink_msg_home_position_get_z(msg);
  430. mavlink_msg_home_position_get_q(msg, home_position->q);
  431. home_position->approach_x = mavlink_msg_home_position_get_approach_x(msg);
  432. home_position->approach_y = mavlink_msg_home_position_get_approach_y(msg);
  433. home_position->approach_z = mavlink_msg_home_position_get_approach_z(msg);
  434. home_position->time_usec = mavlink_msg_home_position_get_time_usec(msg);
  435. #else
  436. uint8_t len = msg->len < MAVLINK_MSG_ID_HOME_POSITION_LEN? msg->len : MAVLINK_MSG_ID_HOME_POSITION_LEN;
  437. memset(home_position, 0, MAVLINK_MSG_ID_HOME_POSITION_LEN);
  438. memcpy(home_position, _MAV_PAYLOAD(msg), len);
  439. #endif
  440. }