RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_set_home_position.h
1#pragma once
2// MESSAGE SET_HOME_POSITION PACKING
3
4#define MAVLINK_MSG_ID_SET_HOME_POSITION 243
5
6MAVPACKED(
7typedef struct __mavlink_set_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 uint8_t target_system; /*< System ID.*/
19 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
20}) mavlink_set_home_position_t;
21
22#define MAVLINK_MSG_ID_SET_HOME_POSITION_LEN 61
23#define MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN 53
24#define MAVLINK_MSG_ID_243_LEN 61
25#define MAVLINK_MSG_ID_243_MIN_LEN 53
26
27#define MAVLINK_MSG_ID_SET_HOME_POSITION_CRC 85
28#define MAVLINK_MSG_ID_243_CRC 85
29
30#define MAVLINK_MSG_SET_HOME_POSITION_FIELD_Q_LEN 4
31
32#if MAVLINK_COMMAND_24BIT
33#define MAVLINK_MESSAGE_INFO_SET_HOME_POSITION { \
34 243, \
35 "SET_HOME_POSITION", \
36 12, \
37 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 52, offsetof(mavlink_set_home_position_t, target_system) }, \
38 { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_set_home_position_t, latitude) }, \
39 { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_set_home_position_t, longitude) }, \
40 { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_set_home_position_t, altitude) }, \
41 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_set_home_position_t, x) }, \
42 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_set_home_position_t, y) }, \
43 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_set_home_position_t, z) }, \
44 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_set_home_position_t, q) }, \
45 { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_set_home_position_t, approach_x) }, \
46 { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_set_home_position_t, approach_y) }, \
47 { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_set_home_position_t, approach_z) }, \
48 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 53, offsetof(mavlink_set_home_position_t, time_usec) }, \
49 } \
50}
51#else
52#define MAVLINK_MESSAGE_INFO_SET_HOME_POSITION { \
53 "SET_HOME_POSITION", \
54 12, \
55 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 52, offsetof(mavlink_set_home_position_t, target_system) }, \
56 { "latitude", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_set_home_position_t, latitude) }, \
57 { "longitude", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_set_home_position_t, longitude) }, \
58 { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_set_home_position_t, altitude) }, \
59 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_set_home_position_t, x) }, \
60 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_set_home_position_t, y) }, \
61 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_set_home_position_t, z) }, \
62 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_set_home_position_t, q) }, \
63 { "approach_x", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_set_home_position_t, approach_x) }, \
64 { "approach_y", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_set_home_position_t, approach_y) }, \
65 { "approach_z", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_set_home_position_t, approach_z) }, \
66 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 53, offsetof(mavlink_set_home_position_t, time_usec) }, \
67 } \
68}
69#endif
70
91static inline uint16_t mavlink_msg_set_home_position_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
92 uint8_t target_system, 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)
93{
94#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
95 char buf[MAVLINK_MSG_ID_SET_HOME_POSITION_LEN];
96 _mav_put_int32_t(buf, 0, latitude);
97 _mav_put_int32_t(buf, 4, longitude);
98 _mav_put_int32_t(buf, 8, altitude);
99 _mav_put_float(buf, 12, x);
100 _mav_put_float(buf, 16, y);
101 _mav_put_float(buf, 20, z);
102 _mav_put_float(buf, 40, approach_x);
103 _mav_put_float(buf, 44, approach_y);
104 _mav_put_float(buf, 48, approach_z);
105 _mav_put_uint8_t(buf, 52, target_system);
106 _mav_put_uint64_t(buf, 53, time_usec);
107 _mav_put_float_array(buf, 24, q, 4);
108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN);
109#else
110 mavlink_set_home_position_t packet;
111 packet.latitude = latitude;
112 packet.longitude = longitude;
113 packet.altitude = altitude;
114 packet.x = x;
115 packet.y = y;
116 packet.z = z;
117 packet.approach_x = approach_x;
118 packet.approach_y = approach_y;
119 packet.approach_z = approach_z;
120 packet.target_system = target_system;
121 packet.time_usec = time_usec;
122 mav_array_memcpy(packet.q, q, sizeof(float)*4);
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN);
124#endif
125
126 msg->msgid = MAVLINK_MSG_ID_SET_HOME_POSITION;
127 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
128}
129
150static inline uint16_t mavlink_msg_set_home_position_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
151 mavlink_message_t* msg,
152 uint8_t target_system,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)
153{
154#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
155 char buf[MAVLINK_MSG_ID_SET_HOME_POSITION_LEN];
156 _mav_put_int32_t(buf, 0, latitude);
157 _mav_put_int32_t(buf, 4, longitude);
158 _mav_put_int32_t(buf, 8, altitude);
159 _mav_put_float(buf, 12, x);
160 _mav_put_float(buf, 16, y);
161 _mav_put_float(buf, 20, z);
162 _mav_put_float(buf, 40, approach_x);
163 _mav_put_float(buf, 44, approach_y);
164 _mav_put_float(buf, 48, approach_z);
165 _mav_put_uint8_t(buf, 52, target_system);
166 _mav_put_uint64_t(buf, 53, time_usec);
167 _mav_put_float_array(buf, 24, q, 4);
168 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN);
169#else
170 mavlink_set_home_position_t packet;
171 packet.latitude = latitude;
172 packet.longitude = longitude;
173 packet.altitude = altitude;
174 packet.x = x;
175 packet.y = y;
176 packet.z = z;
177 packet.approach_x = approach_x;
178 packet.approach_y = approach_y;
179 packet.approach_z = approach_z;
180 packet.target_system = target_system;
181 packet.time_usec = time_usec;
182 mav_array_memcpy(packet.q, q, sizeof(float)*4);
183 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN);
184#endif
185
186 msg->msgid = MAVLINK_MSG_ID_SET_HOME_POSITION;
187 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
188}
189
198static inline uint16_t mavlink_msg_set_home_position_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_home_position_t* set_home_position)
199{
200 return mavlink_msg_set_home_position_pack(system_id, component_id, msg, set_home_position->target_system, set_home_position->latitude, set_home_position->longitude, set_home_position->altitude, set_home_position->x, set_home_position->y, set_home_position->z, set_home_position->q, set_home_position->approach_x, set_home_position->approach_y, set_home_position->approach_z, set_home_position->time_usec);
201}
202
212static inline uint16_t mavlink_msg_set_home_position_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_set_home_position_t* set_home_position)
213{
214 return mavlink_msg_set_home_position_pack_chan(system_id, component_id, chan, msg, set_home_position->target_system, set_home_position->latitude, set_home_position->longitude, set_home_position->altitude, set_home_position->x, set_home_position->y, set_home_position->z, set_home_position->q, set_home_position->approach_x, set_home_position->approach_y, set_home_position->approach_z, set_home_position->time_usec);
215}
216
234#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
235
236static inline void mavlink_msg_set_home_position_send(mavlink_channel_t chan, uint8_t target_system, 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)
237{
238#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
239 char buf[MAVLINK_MSG_ID_SET_HOME_POSITION_LEN];
240 _mav_put_int32_t(buf, 0, latitude);
241 _mav_put_int32_t(buf, 4, longitude);
242 _mav_put_int32_t(buf, 8, altitude);
243 _mav_put_float(buf, 12, x);
244 _mav_put_float(buf, 16, y);
245 _mav_put_float(buf, 20, z);
246 _mav_put_float(buf, 40, approach_x);
247 _mav_put_float(buf, 44, approach_y);
248 _mav_put_float(buf, 48, approach_z);
249 _mav_put_uint8_t(buf, 52, target_system);
250 _mav_put_uint64_t(buf, 53, time_usec);
251 _mav_put_float_array(buf, 24, q, 4);
252 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_HOME_POSITION, buf, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
253#else
254 mavlink_set_home_position_t packet;
255 packet.latitude = latitude;
256 packet.longitude = longitude;
257 packet.altitude = altitude;
258 packet.x = x;
259 packet.y = y;
260 packet.z = z;
261 packet.approach_x = approach_x;
262 packet.approach_y = approach_y;
263 packet.approach_z = approach_z;
264 packet.target_system = target_system;
265 packet.time_usec = time_usec;
266 mav_array_memcpy(packet.q, q, sizeof(float)*4);
267 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_HOME_POSITION, (const char *)&packet, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
268#endif
269}
270
276static inline void mavlink_msg_set_home_position_send_struct(mavlink_channel_t chan, const mavlink_set_home_position_t* set_home_position)
277{
278#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
279 mavlink_msg_set_home_position_send(chan, set_home_position->target_system, set_home_position->latitude, set_home_position->longitude, set_home_position->altitude, set_home_position->x, set_home_position->y, set_home_position->z, set_home_position->q, set_home_position->approach_x, set_home_position->approach_y, set_home_position->approach_z, set_home_position->time_usec);
280#else
281 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_HOME_POSITION, (const char *)set_home_position, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
282#endif
283}
284
285#if MAVLINK_MSG_ID_SET_HOME_POSITION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
286/*
287 This varient of _send() can be used to save stack space by re-using
288 memory from the receive buffer. The caller provides a
289 mavlink_message_t which is the size of a full mavlink message. This
290 is usually the receive buffer for the channel, and allows a reply to an
291 incoming message with minimum stack space usage.
292 */
293static inline void mavlink_msg_set_home_position_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, 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)
294{
295#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
296 char *buf = (char *)msgbuf;
297 _mav_put_int32_t(buf, 0, latitude);
298 _mav_put_int32_t(buf, 4, longitude);
299 _mav_put_int32_t(buf, 8, altitude);
300 _mav_put_float(buf, 12, x);
301 _mav_put_float(buf, 16, y);
302 _mav_put_float(buf, 20, z);
303 _mav_put_float(buf, 40, approach_x);
304 _mav_put_float(buf, 44, approach_y);
305 _mav_put_float(buf, 48, approach_z);
306 _mav_put_uint8_t(buf, 52, target_system);
307 _mav_put_uint64_t(buf, 53, time_usec);
308 _mav_put_float_array(buf, 24, q, 4);
309 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_HOME_POSITION, buf, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
310#else
311 mavlink_set_home_position_t *packet = (mavlink_set_home_position_t *)msgbuf;
312 packet->latitude = latitude;
313 packet->longitude = longitude;
314 packet->altitude = altitude;
315 packet->x = x;
316 packet->y = y;
317 packet->z = z;
318 packet->approach_x = approach_x;
319 packet->approach_y = approach_y;
320 packet->approach_z = approach_z;
321 packet->target_system = target_system;
322 packet->time_usec = time_usec;
323 mav_array_memcpy(packet->q, q, sizeof(float)*4);
324 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_HOME_POSITION, (const char *)packet, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC);
325#endif
326}
327#endif
328
329#endif
330
331// MESSAGE SET_HOME_POSITION UNPACKING
332
333
339static inline uint8_t mavlink_msg_set_home_position_get_target_system(const mavlink_message_t* msg)
340{
341 return _MAV_RETURN_uint8_t(msg, 52);
342}
343
349static inline int32_t mavlink_msg_set_home_position_get_latitude(const mavlink_message_t* msg)
350{
351 return _MAV_RETURN_int32_t(msg, 0);
352}
353
359static inline int32_t mavlink_msg_set_home_position_get_longitude(const mavlink_message_t* msg)
360{
361 return _MAV_RETURN_int32_t(msg, 4);
362}
363
369static inline int32_t mavlink_msg_set_home_position_get_altitude(const mavlink_message_t* msg)
370{
371 return _MAV_RETURN_int32_t(msg, 8);
372}
373
379static inline float mavlink_msg_set_home_position_get_x(const mavlink_message_t* msg)
380{
381 return _MAV_RETURN_float(msg, 12);
382}
383
389static inline float mavlink_msg_set_home_position_get_y(const mavlink_message_t* msg)
390{
391 return _MAV_RETURN_float(msg, 16);
392}
393
399static inline float mavlink_msg_set_home_position_get_z(const mavlink_message_t* msg)
400{
401 return _MAV_RETURN_float(msg, 20);
402}
403
409static inline uint16_t mavlink_msg_set_home_position_get_q(const mavlink_message_t* msg, float *q)
410{
411 return _MAV_RETURN_float_array(msg, q, 4, 24);
412}
413
419static inline float mavlink_msg_set_home_position_get_approach_x(const mavlink_message_t* msg)
420{
421 return _MAV_RETURN_float(msg, 40);
422}
423
429static inline float mavlink_msg_set_home_position_get_approach_y(const mavlink_message_t* msg)
430{
431 return _MAV_RETURN_float(msg, 44);
432}
433
439static inline float mavlink_msg_set_home_position_get_approach_z(const mavlink_message_t* msg)
440{
441 return _MAV_RETURN_float(msg, 48);
442}
443
449static inline uint64_t mavlink_msg_set_home_position_get_time_usec(const mavlink_message_t* msg)
450{
451 return _MAV_RETURN_uint64_t(msg, 53);
452}
453
460static inline void mavlink_msg_set_home_position_decode(const mavlink_message_t* msg, mavlink_set_home_position_t* set_home_position)
461{
462#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
463 set_home_position->latitude = mavlink_msg_set_home_position_get_latitude(msg);
464 set_home_position->longitude = mavlink_msg_set_home_position_get_longitude(msg);
465 set_home_position->altitude = mavlink_msg_set_home_position_get_altitude(msg);
466 set_home_position->x = mavlink_msg_set_home_position_get_x(msg);
467 set_home_position->y = mavlink_msg_set_home_position_get_y(msg);
468 set_home_position->z = mavlink_msg_set_home_position_get_z(msg);
469 mavlink_msg_set_home_position_get_q(msg, set_home_position->q);
470 set_home_position->approach_x = mavlink_msg_set_home_position_get_approach_x(msg);
471 set_home_position->approach_y = mavlink_msg_set_home_position_get_approach_y(msg);
472 set_home_position->approach_z = mavlink_msg_set_home_position_get_approach_z(msg);
473 set_home_position->target_system = mavlink_msg_set_home_position_get_target_system(msg);
474 set_home_position->time_usec = mavlink_msg_set_home_position_get_time_usec(msg);
475#else
476 uint8_t len = msg->len < MAVLINK_MSG_ID_SET_HOME_POSITION_LEN? msg->len : MAVLINK_MSG_ID_SET_HOME_POSITION_LEN;
477 memset(set_home_position, 0, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN);
478 memcpy(set_home_position, _MAV_PAYLOAD(msg), len);
479#endif
480}