RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_home_position.h
1#pragma once
2// MESSAGE HOME_POSITION PACKING
3
4#define MAVLINK_MSG_ID_HOME_POSITION 242
5
6MAVPACKED(
7typedef struct __mavlink_home_position_t {
8 int32_t latitude; /*< Latitude (WGS84), in degrees * 1E7*/
9 int32_t longitude; /*< Longitude (WGS84, in degrees * 1E7*/
10 int32_t altitude; /*< Altitude (AMSL), in meters * 1000 (positive for up)*/
11 float x; /*< Local X position of this position in the local coordinate frame*/
12 float y; /*< Local Y position of this position in the local coordinate frame*/
13 float z; /*< Local Z position of this position in the local coordinate frame*/
14 float q[4]; /*< World to surface normal and heading transformation of the takeoff position. Used to indicate the heading and slope of the ground*/
15 float approach_x; /*< 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.*/
16 float approach_y; /*< 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.*/
17 float approach_z; /*< 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.*/
18 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
19}) mavlink_home_position_t;
20
21#define MAVLINK_MSG_ID_HOME_POSITION_LEN 60
22#define MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN 52
23#define MAVLINK_MSG_ID_242_LEN 60
24#define MAVLINK_MSG_ID_242_MIN_LEN 52
25
26#define MAVLINK_MSG_ID_HOME_POSITION_CRC 104
27#define MAVLINK_MSG_ID_242_CRC 104
28
29#define MAVLINK_MSG_HOME_POSITION_FIELD_Q_LEN 4
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_HOME_POSITION { \
33 242, \
34 "HOME_POSITION", \
35 11, \
36 { { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_home_position_t, latitude) }, \
37 { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_home_position_t, longitude) }, \
38 { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_home_position_t, altitude) }, \
39 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_home_position_t, x) }, \
40 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_home_position_t, y) }, \
41 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_home_position_t, z) }, \
42 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_home_position_t, q) }, \
43 { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_home_position_t, approach_x) }, \
44 { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_home_position_t, approach_y) }, \
45 { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_home_position_t, approach_z) }, \
46 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 52, offsetof(mavlink_home_position_t, time_usec) }, \
47 } \
48}
49#else
50#define MAVLINK_MESSAGE_INFO_HOME_POSITION { \
51 "HOME_POSITION", \
52 11, \
53 { { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_home_position_t, latitude) }, \
54 { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_home_position_t, longitude) }, \
55 { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_home_position_t, altitude) }, \
56 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_home_position_t, x) }, \
57 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_home_position_t, y) }, \
58 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_home_position_t, z) }, \
59 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_home_position_t, q) }, \
60 { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_home_position_t, approach_x) }, \
61 { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_home_position_t, approach_y) }, \
62 { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_home_position_t, approach_z) }, \
63 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 52, offsetof(mavlink_home_position_t, time_usec) }, \
64 } \
65}
66#endif
67
87static 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
120 msg->msgid = MAVLINK_MSG_ID_HOME_POSITION;
121 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);
122}
123
143static inline uint16_t mavlink_msg_home_position_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
144 mavlink_message_t* msg,
145 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)
146{
147#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
148 char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN];
149 _mav_put_int32_t(buf, 0, latitude);
150 _mav_put_int32_t(buf, 4, longitude);
151 _mav_put_int32_t(buf, 8, altitude);
152 _mav_put_float(buf, 12, x);
153 _mav_put_float(buf, 16, y);
154 _mav_put_float(buf, 20, z);
155 _mav_put_float(buf, 40, approach_x);
156 _mav_put_float(buf, 44, approach_y);
157 _mav_put_float(buf, 48, approach_z);
158 _mav_put_uint64_t(buf, 52, time_usec);
159 _mav_put_float_array(buf, 24, q, 4);
160 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HOME_POSITION_LEN);
161#else
162 mavlink_home_position_t packet;
163 packet.latitude = latitude;
164 packet.longitude = longitude;
165 packet.altitude = altitude;
166 packet.x = x;
167 packet.y = y;
168 packet.z = z;
169 packet.approach_x = approach_x;
170 packet.approach_y = approach_y;
171 packet.approach_z = approach_z;
172 packet.time_usec = time_usec;
173 mav_array_memcpy(packet.q, q, sizeof(float)*4);
174 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HOME_POSITION_LEN);
175#endif
176
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
189static 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)
190{
191 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);
192}
193
203static 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)
204{
205 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);
206}
207
224#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
225
226static 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)
227{
228#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
229 char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN];
230 _mav_put_int32_t(buf, 0, latitude);
231 _mav_put_int32_t(buf, 4, longitude);
232 _mav_put_int32_t(buf, 8, altitude);
233 _mav_put_float(buf, 12, x);
234 _mav_put_float(buf, 16, y);
235 _mav_put_float(buf, 20, z);
236 _mav_put_float(buf, 40, approach_x);
237 _mav_put_float(buf, 44, approach_y);
238 _mav_put_float(buf, 48, approach_z);
239 _mav_put_uint64_t(buf, 52, time_usec);
240 _mav_put_float_array(buf, 24, q, 4);
241 _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);
242#else
243 mavlink_home_position_t packet;
244 packet.latitude = latitude;
245 packet.longitude = longitude;
246 packet.altitude = altitude;
247 packet.x = x;
248 packet.y = y;
249 packet.z = z;
250 packet.approach_x = approach_x;
251 packet.approach_y = approach_y;
252 packet.approach_z = approach_z;
253 packet.time_usec = time_usec;
254 mav_array_memcpy(packet.q, q, sizeof(float)*4);
255 _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);
256#endif
257}
258
264static inline void mavlink_msg_home_position_send_struct(mavlink_channel_t chan, const mavlink_home_position_t* home_position)
265{
266#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
267 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);
268#else
269 _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);
270#endif
271}
272
273#if MAVLINK_MSG_ID_HOME_POSITION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
274/*
275 This varient of _send() can be used to save stack space by re-using
276 memory from the receive buffer. The caller provides a
277 mavlink_message_t which is the size of a full mavlink message. This
278 is usually the receive buffer for the channel, and allows a reply to an
279 incoming message with minimum stack space usage.
280 */
281static 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)
282{
283#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
284 char *buf = (char *)msgbuf;
285 _mav_put_int32_t(buf, 0, latitude);
286 _mav_put_int32_t(buf, 4, longitude);
287 _mav_put_int32_t(buf, 8, altitude);
288 _mav_put_float(buf, 12, x);
289 _mav_put_float(buf, 16, y);
290 _mav_put_float(buf, 20, z);
291 _mav_put_float(buf, 40, approach_x);
292 _mav_put_float(buf, 44, approach_y);
293 _mav_put_float(buf, 48, approach_z);
294 _mav_put_uint64_t(buf, 52, time_usec);
295 _mav_put_float_array(buf, 24, q, 4);
296 _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);
297#else
298 mavlink_home_position_t *packet = (mavlink_home_position_t *)msgbuf;
299 packet->latitude = latitude;
300 packet->longitude = longitude;
301 packet->altitude = altitude;
302 packet->x = x;
303 packet->y = y;
304 packet->z = z;
305 packet->approach_x = approach_x;
306 packet->approach_y = approach_y;
307 packet->approach_z = approach_z;
308 packet->time_usec = time_usec;
309 mav_array_memcpy(packet->q, q, sizeof(float)*4);
310 _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);
311#endif
312}
313#endif
314
315#endif
316
317// MESSAGE HOME_POSITION UNPACKING
318
319
325static inline int32_t mavlink_msg_home_position_get_latitude(const mavlink_message_t* msg)
326{
327 return _MAV_RETURN_int32_t(msg, 0);
328}
329
335static inline int32_t mavlink_msg_home_position_get_longitude(const mavlink_message_t* msg)
336{
337 return _MAV_RETURN_int32_t(msg, 4);
338}
339
345static inline int32_t mavlink_msg_home_position_get_altitude(const mavlink_message_t* msg)
346{
347 return _MAV_RETURN_int32_t(msg, 8);
348}
349
355static inline float mavlink_msg_home_position_get_x(const mavlink_message_t* msg)
356{
357 return _MAV_RETURN_float(msg, 12);
358}
359
365static inline float mavlink_msg_home_position_get_y(const mavlink_message_t* msg)
366{
367 return _MAV_RETURN_float(msg, 16);
368}
369
375static inline float mavlink_msg_home_position_get_z(const mavlink_message_t* msg)
376{
377 return _MAV_RETURN_float(msg, 20);
378}
379
385static inline uint16_t mavlink_msg_home_position_get_q(const mavlink_message_t* msg, float *q)
386{
387 return _MAV_RETURN_float_array(msg, q, 4, 24);
388}
389
395static inline float mavlink_msg_home_position_get_approach_x(const mavlink_message_t* msg)
396{
397 return _MAV_RETURN_float(msg, 40);
398}
399
405static inline float mavlink_msg_home_position_get_approach_y(const mavlink_message_t* msg)
406{
407 return _MAV_RETURN_float(msg, 44);
408}
409
415static inline float mavlink_msg_home_position_get_approach_z(const mavlink_message_t* msg)
416{
417 return _MAV_RETURN_float(msg, 48);
418}
419
425static inline uint64_t mavlink_msg_home_position_get_time_usec(const mavlink_message_t* msg)
426{
427 return _MAV_RETURN_uint64_t(msg, 52);
428}
429
436static inline void mavlink_msg_home_position_decode(const mavlink_message_t* msg, mavlink_home_position_t* home_position)
437{
438#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
439 home_position->latitude = mavlink_msg_home_position_get_latitude(msg);
440 home_position->longitude = mavlink_msg_home_position_get_longitude(msg);
441 home_position->altitude = mavlink_msg_home_position_get_altitude(msg);
442 home_position->x = mavlink_msg_home_position_get_x(msg);
443 home_position->y = mavlink_msg_home_position_get_y(msg);
444 home_position->z = mavlink_msg_home_position_get_z(msg);
445 mavlink_msg_home_position_get_q(msg, home_position->q);
446 home_position->approach_x = mavlink_msg_home_position_get_approach_x(msg);
447 home_position->approach_y = mavlink_msg_home_position_get_approach_y(msg);
448 home_position->approach_z = mavlink_msg_home_position_get_approach_z(msg);
449 home_position->time_usec = mavlink_msg_home_position_get_time_usec(msg);
450#else
451 uint8_t len = msg->len < MAVLINK_MSG_ID_HOME_POSITION_LEN? msg->len : MAVLINK_MSG_ID_HOME_POSITION_LEN;
452 memset(home_position, 0, MAVLINK_MSG_ID_HOME_POSITION_LEN);
453 memcpy(home_position, _MAV_PAYLOAD(msg), len);
454#endif
455}