RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_hil_controls.h
1#pragma once
2// MESSAGE HIL_CONTROLS PACKING
3
4#define MAVLINK_MSG_ID_HIL_CONTROLS 91
5
6MAVPACKED(
7typedef struct __mavlink_hil_controls_t {
8 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
9 float roll_ailerons; /*< Control output -1 .. 1*/
10 float pitch_elevator; /*< Control output -1 .. 1*/
11 float yaw_rudder; /*< Control output -1 .. 1*/
12 float throttle; /*< Throttle 0 .. 1*/
13 float aux1; /*< Aux 1, -1 .. 1*/
14 float aux2; /*< Aux 2, -1 .. 1*/
15 float aux3; /*< Aux 3, -1 .. 1*/
16 float aux4; /*< Aux 4, -1 .. 1*/
17 uint8_t mode; /*< System mode (MAV_MODE)*/
18 uint8_t nav_mode; /*< Navigation mode (MAV_NAV_MODE)*/
19}) mavlink_hil_controls_t;
20
21#define MAVLINK_MSG_ID_HIL_CONTROLS_LEN 42
22#define MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN 42
23#define MAVLINK_MSG_ID_91_LEN 42
24#define MAVLINK_MSG_ID_91_MIN_LEN 42
25
26#define MAVLINK_MSG_ID_HIL_CONTROLS_CRC 63
27#define MAVLINK_MSG_ID_91_CRC 63
28
29
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_HIL_CONTROLS { \
33 91, \
34 "HIL_CONTROLS", \
35 11, \
36 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_controls_t, time_usec) }, \
37 { "roll_ailerons", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_controls_t, roll_ailerons) }, \
38 { "pitch_elevator", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_controls_t, pitch_elevator) }, \
39 { "yaw_rudder", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_controls_t, yaw_rudder) }, \
40 { "throttle", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_controls_t, throttle) }, \
41 { "aux1", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_controls_t, aux1) }, \
42 { "aux2", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_controls_t, aux2) }, \
43 { "aux3", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_controls_t, aux3) }, \
44 { "aux4", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_controls_t, aux4) }, \
45 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_hil_controls_t, mode) }, \
46 { "nav_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_hil_controls_t, nav_mode) }, \
47 } \
48}
49#else
50#define MAVLINK_MESSAGE_INFO_HIL_CONTROLS { \
51 "HIL_CONTROLS", \
52 11, \
53 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_controls_t, time_usec) }, \
54 { "roll_ailerons", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_controls_t, roll_ailerons) }, \
55 { "pitch_elevator", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_controls_t, pitch_elevator) }, \
56 { "yaw_rudder", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_controls_t, yaw_rudder) }, \
57 { "throttle", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_controls_t, throttle) }, \
58 { "aux1", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_controls_t, aux1) }, \
59 { "aux2", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_controls_t, aux2) }, \
60 { "aux3", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_controls_t, aux3) }, \
61 { "aux4", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_controls_t, aux4) }, \
62 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_hil_controls_t, mode) }, \
63 { "nav_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_hil_controls_t, nav_mode) }, \
64 } \
65}
66#endif
67
87static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
88 uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode)
89{
90#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
91 char buf[MAVLINK_MSG_ID_HIL_CONTROLS_LEN];
92 _mav_put_uint64_t(buf, 0, time_usec);
93 _mav_put_float(buf, 8, roll_ailerons);
94 _mav_put_float(buf, 12, pitch_elevator);
95 _mav_put_float(buf, 16, yaw_rudder);
96 _mav_put_float(buf, 20, throttle);
97 _mav_put_float(buf, 24, aux1);
98 _mav_put_float(buf, 28, aux2);
99 _mav_put_float(buf, 32, aux3);
100 _mav_put_float(buf, 36, aux4);
101 _mav_put_uint8_t(buf, 40, mode);
102 _mav_put_uint8_t(buf, 41, nav_mode);
103
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_CONTROLS_LEN);
105#else
106 mavlink_hil_controls_t packet;
107 packet.time_usec = time_usec;
108 packet.roll_ailerons = roll_ailerons;
109 packet.pitch_elevator = pitch_elevator;
110 packet.yaw_rudder = yaw_rudder;
111 packet.throttle = throttle;
112 packet.aux1 = aux1;
113 packet.aux2 = aux2;
114 packet.aux3 = aux3;
115 packet.aux4 = aux4;
116 packet.mode = mode;
117 packet.nav_mode = nav_mode;
118
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_CONTROLS_LEN);
120#endif
121
122 msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
123 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
124}
125
145static inline uint16_t mavlink_msg_hil_controls_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
146 mavlink_message_t* msg,
147 uint64_t time_usec,float roll_ailerons,float pitch_elevator,float yaw_rudder,float throttle,float aux1,float aux2,float aux3,float aux4,uint8_t mode,uint8_t nav_mode)
148{
149#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
150 char buf[MAVLINK_MSG_ID_HIL_CONTROLS_LEN];
151 _mav_put_uint64_t(buf, 0, time_usec);
152 _mav_put_float(buf, 8, roll_ailerons);
153 _mav_put_float(buf, 12, pitch_elevator);
154 _mav_put_float(buf, 16, yaw_rudder);
155 _mav_put_float(buf, 20, throttle);
156 _mav_put_float(buf, 24, aux1);
157 _mav_put_float(buf, 28, aux2);
158 _mav_put_float(buf, 32, aux3);
159 _mav_put_float(buf, 36, aux4);
160 _mav_put_uint8_t(buf, 40, mode);
161 _mav_put_uint8_t(buf, 41, nav_mode);
162
163 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_CONTROLS_LEN);
164#else
165 mavlink_hil_controls_t packet;
166 packet.time_usec = time_usec;
167 packet.roll_ailerons = roll_ailerons;
168 packet.pitch_elevator = pitch_elevator;
169 packet.yaw_rudder = yaw_rudder;
170 packet.throttle = throttle;
171 packet.aux1 = aux1;
172 packet.aux2 = aux2;
173 packet.aux3 = aux3;
174 packet.aux4 = aux4;
175 packet.mode = mode;
176 packet.nav_mode = nav_mode;
177
178 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_CONTROLS_LEN);
179#endif
180
181 msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
182 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
183}
184
193static inline uint16_t mavlink_msg_hil_controls_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_controls_t* hil_controls)
194{
195 return mavlink_msg_hil_controls_pack(system_id, component_id, msg, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode);
196}
197
207static inline uint16_t mavlink_msg_hil_controls_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_controls_t* hil_controls)
208{
209 return mavlink_msg_hil_controls_pack_chan(system_id, component_id, chan, msg, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode);
210}
211
228#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
229
230static inline void mavlink_msg_hil_controls_send(mavlink_channel_t chan, uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode)
231{
232#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
233 char buf[MAVLINK_MSG_ID_HIL_CONTROLS_LEN];
234 _mav_put_uint64_t(buf, 0, time_usec);
235 _mav_put_float(buf, 8, roll_ailerons);
236 _mav_put_float(buf, 12, pitch_elevator);
237 _mav_put_float(buf, 16, yaw_rudder);
238 _mav_put_float(buf, 20, throttle);
239 _mav_put_float(buf, 24, aux1);
240 _mav_put_float(buf, 28, aux2);
241 _mav_put_float(buf, 32, aux3);
242 _mav_put_float(buf, 36, aux4);
243 _mav_put_uint8_t(buf, 40, mode);
244 _mav_put_uint8_t(buf, 41, nav_mode);
245
246 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, buf, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
247#else
248 mavlink_hil_controls_t packet;
249 packet.time_usec = time_usec;
250 packet.roll_ailerons = roll_ailerons;
251 packet.pitch_elevator = pitch_elevator;
252 packet.yaw_rudder = yaw_rudder;
253 packet.throttle = throttle;
254 packet.aux1 = aux1;
255 packet.aux2 = aux2;
256 packet.aux3 = aux3;
257 packet.aux4 = aux4;
258 packet.mode = mode;
259 packet.nav_mode = nav_mode;
260
261 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)&packet, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
262#endif
263}
264
270static inline void mavlink_msg_hil_controls_send_struct(mavlink_channel_t chan, const mavlink_hil_controls_t* hil_controls)
271{
272#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
273 mavlink_msg_hil_controls_send(chan, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode);
274#else
275 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)hil_controls, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
276#endif
277}
278
279#if MAVLINK_MSG_ID_HIL_CONTROLS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
280/*
281 This varient of _send() can be used to save stack space by re-using
282 memory from the receive buffer. The caller provides a
283 mavlink_message_t which is the size of a full mavlink message. This
284 is usually the receive buffer for the channel, and allows a reply to an
285 incoming message with minimum stack space usage.
286 */
287static inline void mavlink_msg_hil_controls_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 char *buf = (char *)msgbuf;
291 _mav_put_uint64_t(buf, 0, time_usec);
292 _mav_put_float(buf, 8, roll_ailerons);
293 _mav_put_float(buf, 12, pitch_elevator);
294 _mav_put_float(buf, 16, yaw_rudder);
295 _mav_put_float(buf, 20, throttle);
296 _mav_put_float(buf, 24, aux1);
297 _mav_put_float(buf, 28, aux2);
298 _mav_put_float(buf, 32, aux3);
299 _mav_put_float(buf, 36, aux4);
300 _mav_put_uint8_t(buf, 40, mode);
301 _mav_put_uint8_t(buf, 41, nav_mode);
302
303 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, buf, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
304#else
305 mavlink_hil_controls_t *packet = (mavlink_hil_controls_t *)msgbuf;
306 packet->time_usec = time_usec;
307 packet->roll_ailerons = roll_ailerons;
308 packet->pitch_elevator = pitch_elevator;
309 packet->yaw_rudder = yaw_rudder;
310 packet->throttle = throttle;
311 packet->aux1 = aux1;
312 packet->aux2 = aux2;
313 packet->aux3 = aux3;
314 packet->aux4 = aux4;
315 packet->mode = mode;
316 packet->nav_mode = nav_mode;
317
318 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)packet, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC);
319#endif
320}
321#endif
322
323#endif
324
325// MESSAGE HIL_CONTROLS UNPACKING
326
327
333static inline uint64_t mavlink_msg_hil_controls_get_time_usec(const mavlink_message_t* msg)
334{
335 return _MAV_RETURN_uint64_t(msg, 0);
336}
337
343static inline float mavlink_msg_hil_controls_get_roll_ailerons(const mavlink_message_t* msg)
344{
345 return _MAV_RETURN_float(msg, 8);
346}
347
353static inline float mavlink_msg_hil_controls_get_pitch_elevator(const mavlink_message_t* msg)
354{
355 return _MAV_RETURN_float(msg, 12);
356}
357
363static inline float mavlink_msg_hil_controls_get_yaw_rudder(const mavlink_message_t* msg)
364{
365 return _MAV_RETURN_float(msg, 16);
366}
367
373static inline float mavlink_msg_hil_controls_get_throttle(const mavlink_message_t* msg)
374{
375 return _MAV_RETURN_float(msg, 20);
376}
377
383static inline float mavlink_msg_hil_controls_get_aux1(const mavlink_message_t* msg)
384{
385 return _MAV_RETURN_float(msg, 24);
386}
387
393static inline float mavlink_msg_hil_controls_get_aux2(const mavlink_message_t* msg)
394{
395 return _MAV_RETURN_float(msg, 28);
396}
397
403static inline float mavlink_msg_hil_controls_get_aux3(const mavlink_message_t* msg)
404{
405 return _MAV_RETURN_float(msg, 32);
406}
407
413static inline float mavlink_msg_hil_controls_get_aux4(const mavlink_message_t* msg)
414{
415 return _MAV_RETURN_float(msg, 36);
416}
417
423static inline uint8_t mavlink_msg_hil_controls_get_mode(const mavlink_message_t* msg)
424{
425 return _MAV_RETURN_uint8_t(msg, 40);
426}
427
433static inline uint8_t mavlink_msg_hil_controls_get_nav_mode(const mavlink_message_t* msg)
434{
435 return _MAV_RETURN_uint8_t(msg, 41);
436}
437
444static inline void mavlink_msg_hil_controls_decode(const mavlink_message_t* msg, mavlink_hil_controls_t* hil_controls)
445{
446#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
447 hil_controls->time_usec = mavlink_msg_hil_controls_get_time_usec(msg);
448 hil_controls->roll_ailerons = mavlink_msg_hil_controls_get_roll_ailerons(msg);
449 hil_controls->pitch_elevator = mavlink_msg_hil_controls_get_pitch_elevator(msg);
450 hil_controls->yaw_rudder = mavlink_msg_hil_controls_get_yaw_rudder(msg);
451 hil_controls->throttle = mavlink_msg_hil_controls_get_throttle(msg);
452 hil_controls->aux1 = mavlink_msg_hil_controls_get_aux1(msg);
453 hil_controls->aux2 = mavlink_msg_hil_controls_get_aux2(msg);
454 hil_controls->aux3 = mavlink_msg_hil_controls_get_aux3(msg);
455 hil_controls->aux4 = mavlink_msg_hil_controls_get_aux4(msg);
456 hil_controls->mode = mavlink_msg_hil_controls_get_mode(msg);
457 hil_controls->nav_mode = mavlink_msg_hil_controls_get_nav_mode(msg);
458#else
459 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_CONTROLS_LEN? msg->len : MAVLINK_MSG_ID_HIL_CONTROLS_LEN;
460 memset(hil_controls, 0, MAVLINK_MSG_ID_HIL_CONTROLS_LEN);
461 memcpy(hil_controls, _MAV_PAYLOAD(msg), len);
462#endif
463}