Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
// MESSAGE HIL_CONTROLS PACKING
2
 
3
#define MAVLINK_MSG_ID_HIL_CONTROLS 91
4
 
5
typedef struct __mavlink_hil_controls_t
6
{
7
 uint64_t time_usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
8
 float roll_ailerons; ///< Control output -1 .. 1
9
 float pitch_elevator; ///< Control output -1 .. 1
10
 float yaw_rudder; ///< Control output -1 .. 1
11
 float throttle; ///< Throttle 0 .. 1
12
 float aux1; ///< Aux 1, -1 .. 1
13
 float aux2; ///< Aux 2, -1 .. 1
14
 float aux3; ///< Aux 3, -1 .. 1
15
 float aux4; ///< Aux 4, -1 .. 1
16
 uint8_t mode; ///< System mode (MAV_MODE)
17
 uint8_t nav_mode; ///< Navigation mode (MAV_NAV_MODE)
18
} mavlink_hil_controls_t;
19
 
20
#define MAVLINK_MSG_ID_HIL_CONTROLS_LEN 42
21
#define MAVLINK_MSG_ID_91_LEN 42
22
 
23
 
24
 
25
#define MAVLINK_MESSAGE_INFO_HIL_CONTROLS { \
26
        "HIL_CONTROLS", \
27
        11, \
28
        {  { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_controls_t, time_usec) }, \
29
         { "roll_ailerons", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_controls_t, roll_ailerons) }, \
30
         { "pitch_elevator", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_controls_t, pitch_elevator) }, \
31
         { "yaw_rudder", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_controls_t, yaw_rudder) }, \
32
         { "throttle", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_controls_t, throttle) }, \
33
         { "aux1", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_controls_t, aux1) }, \
34
         { "aux2", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_controls_t, aux2) }, \
35
         { "aux3", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_controls_t, aux3) }, \
36
         { "aux4", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_controls_t, aux4) }, \
37
         { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_hil_controls_t, mode) }, \
38
         { "nav_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_hil_controls_t, nav_mode) }, \
39
         } \
40
}
41
 
42
 
43
/**
44
 * @brief Pack a hil_controls message
45
 * @param system_id ID of this system
46
 * @param component_id ID of this component (e.g. 200 for IMU)
47
 * @param msg The MAVLink message to compress the data into
48
 *
49
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
50
 * @param roll_ailerons Control output -1 .. 1
51
 * @param pitch_elevator Control output -1 .. 1
52
 * @param yaw_rudder Control output -1 .. 1
53
 * @param throttle Throttle 0 .. 1
54
 * @param aux1 Aux 1, -1 .. 1
55
 * @param aux2 Aux 2, -1 .. 1
56
 * @param aux3 Aux 3, -1 .. 1
57
 * @param aux4 Aux 4, -1 .. 1
58
 * @param mode System mode (MAV_MODE)
59
 * @param nav_mode Navigation mode (MAV_NAV_MODE)
60
 * @return length of the message in bytes (excluding serial stream start sign)
61
 */
62
static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63
                                                       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)
64
{
65
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66
        char buf[42];
67
        _mav_put_uint64_t(buf, 0, time_usec);
68
        _mav_put_float(buf, 8, roll_ailerons);
69
        _mav_put_float(buf, 12, pitch_elevator);
70
        _mav_put_float(buf, 16, yaw_rudder);
71
        _mav_put_float(buf, 20, throttle);
72
        _mav_put_float(buf, 24, aux1);
73
        _mav_put_float(buf, 28, aux2);
74
        _mav_put_float(buf, 32, aux3);
75
        _mav_put_float(buf, 36, aux4);
76
        _mav_put_uint8_t(buf, 40, mode);
77
        _mav_put_uint8_t(buf, 41, nav_mode);
78
 
79
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
80
#else
81
        mavlink_hil_controls_t packet;
82
        packet.time_usec = time_usec;
83
        packet.roll_ailerons = roll_ailerons;
84
        packet.pitch_elevator = pitch_elevator;
85
        packet.yaw_rudder = yaw_rudder;
86
        packet.throttle = throttle;
87
        packet.aux1 = aux1;
88
        packet.aux2 = aux2;
89
        packet.aux3 = aux3;
90
        packet.aux4 = aux4;
91
        packet.mode = mode;
92
        packet.nav_mode = nav_mode;
93
 
94
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
95
#endif
96
 
97
        msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
98
        return mavlink_finalize_message(msg, system_id, component_id, 42, 63);
99
}
100
 
101
/**
102
 * @brief Pack a hil_controls message on a channel
103
 * @param system_id ID of this system
104
 * @param component_id ID of this component (e.g. 200 for IMU)
105
 * @param chan The MAVLink channel this message was sent over
106
 * @param msg The MAVLink message to compress the data into
107
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
108
 * @param roll_ailerons Control output -1 .. 1
109
 * @param pitch_elevator Control output -1 .. 1
110
 * @param yaw_rudder Control output -1 .. 1
111
 * @param throttle Throttle 0 .. 1
112
 * @param aux1 Aux 1, -1 .. 1
113
 * @param aux2 Aux 2, -1 .. 1
114
 * @param aux3 Aux 3, -1 .. 1
115
 * @param aux4 Aux 4, -1 .. 1
116
 * @param mode System mode (MAV_MODE)
117
 * @param nav_mode Navigation mode (MAV_NAV_MODE)
118
 * @return length of the message in bytes (excluding serial stream start sign)
119
 */
120
static inline uint16_t mavlink_msg_hil_controls_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
121
                                                           mavlink_message_t* msg,
122
                                                           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)
123
{
124
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
125
        char buf[42];
126
        _mav_put_uint64_t(buf, 0, time_usec);
127
        _mav_put_float(buf, 8, roll_ailerons);
128
        _mav_put_float(buf, 12, pitch_elevator);
129
        _mav_put_float(buf, 16, yaw_rudder);
130
        _mav_put_float(buf, 20, throttle);
131
        _mav_put_float(buf, 24, aux1);
132
        _mav_put_float(buf, 28, aux2);
133
        _mav_put_float(buf, 32, aux3);
134
        _mav_put_float(buf, 36, aux4);
135
        _mav_put_uint8_t(buf, 40, mode);
136
        _mav_put_uint8_t(buf, 41, nav_mode);
137
 
138
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
139
#else
140
        mavlink_hil_controls_t packet;
141
        packet.time_usec = time_usec;
142
        packet.roll_ailerons = roll_ailerons;
143
        packet.pitch_elevator = pitch_elevator;
144
        packet.yaw_rudder = yaw_rudder;
145
        packet.throttle = throttle;
146
        packet.aux1 = aux1;
147
        packet.aux2 = aux2;
148
        packet.aux3 = aux3;
149
        packet.aux4 = aux4;
150
        packet.mode = mode;
151
        packet.nav_mode = nav_mode;
152
 
153
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
154
#endif
155
 
156
        msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
157
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 63);
158
}
159
 
160
/**
161
 * @brief Encode a hil_controls struct into a message
162
 *
163
 * @param system_id ID of this system
164
 * @param component_id ID of this component (e.g. 200 for IMU)
165
 * @param msg The MAVLink message to compress the data into
166
 * @param hil_controls C-struct to read the message contents from
167
 */
168
static 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)
169
{
170
        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);
171
}
172
 
173
/**
174
 * @brief Send a hil_controls message
175
 * @param chan MAVLink channel to send the message
176
 *
177
 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
178
 * @param roll_ailerons Control output -1 .. 1
179
 * @param pitch_elevator Control output -1 .. 1
180
 * @param yaw_rudder Control output -1 .. 1
181
 * @param throttle Throttle 0 .. 1
182
 * @param aux1 Aux 1, -1 .. 1
183
 * @param aux2 Aux 2, -1 .. 1
184
 * @param aux3 Aux 3, -1 .. 1
185
 * @param aux4 Aux 4, -1 .. 1
186
 * @param mode System mode (MAV_MODE)
187
 * @param nav_mode Navigation mode (MAV_NAV_MODE)
188
 */
189
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
190
 
191
static 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)
192
{
193
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194
        char buf[42];
195
        _mav_put_uint64_t(buf, 0, time_usec);
196
        _mav_put_float(buf, 8, roll_ailerons);
197
        _mav_put_float(buf, 12, pitch_elevator);
198
        _mav_put_float(buf, 16, yaw_rudder);
199
        _mav_put_float(buf, 20, throttle);
200
        _mav_put_float(buf, 24, aux1);
201
        _mav_put_float(buf, 28, aux2);
202
        _mav_put_float(buf, 32, aux3);
203
        _mav_put_float(buf, 36, aux4);
204
        _mav_put_uint8_t(buf, 40, mode);
205
        _mav_put_uint8_t(buf, 41, nav_mode);
206
 
207
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, buf, 42, 63);
208
#else
209
        mavlink_hil_controls_t packet;
210
        packet.time_usec = time_usec;
211
        packet.roll_ailerons = roll_ailerons;
212
        packet.pitch_elevator = pitch_elevator;
213
        packet.yaw_rudder = yaw_rudder;
214
        packet.throttle = throttle;
215
        packet.aux1 = aux1;
216
        packet.aux2 = aux2;
217
        packet.aux3 = aux3;
218
        packet.aux4 = aux4;
219
        packet.mode = mode;
220
        packet.nav_mode = nav_mode;
221
 
222
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)&packet, 42, 63);
223
#endif
224
}
225
 
226
#endif
227
 
228
// MESSAGE HIL_CONTROLS UNPACKING
229
 
230
 
231
/**
232
 * @brief Get field time_usec from hil_controls message
233
 *
234
 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
235
 */
236
static inline uint64_t mavlink_msg_hil_controls_get_time_usec(const mavlink_message_t* msg)
237
{
238
        return _MAV_RETURN_uint64_t(msg,  0);
239
}
240
 
241
/**
242
 * @brief Get field roll_ailerons from hil_controls message
243
 *
244
 * @return Control output -1 .. 1
245
 */
246
static inline float mavlink_msg_hil_controls_get_roll_ailerons(const mavlink_message_t* msg)
247
{
248
        return _MAV_RETURN_float(msg,  8);
249
}
250
 
251
/**
252
 * @brief Get field pitch_elevator from hil_controls message
253
 *
254
 * @return Control output -1 .. 1
255
 */
256
static inline float mavlink_msg_hil_controls_get_pitch_elevator(const mavlink_message_t* msg)
257
{
258
        return _MAV_RETURN_float(msg,  12);
259
}
260
 
261
/**
262
 * @brief Get field yaw_rudder from hil_controls message
263
 *
264
 * @return Control output -1 .. 1
265
 */
266
static inline float mavlink_msg_hil_controls_get_yaw_rudder(const mavlink_message_t* msg)
267
{
268
        return _MAV_RETURN_float(msg,  16);
269
}
270
 
271
/**
272
 * @brief Get field throttle from hil_controls message
273
 *
274
 * @return Throttle 0 .. 1
275
 */
276
static inline float mavlink_msg_hil_controls_get_throttle(const mavlink_message_t* msg)
277
{
278
        return _MAV_RETURN_float(msg,  20);
279
}
280
 
281
/**
282
 * @brief Get field aux1 from hil_controls message
283
 *
284
 * @return Aux 1, -1 .. 1
285
 */
286
static inline float mavlink_msg_hil_controls_get_aux1(const mavlink_message_t* msg)
287
{
288
        return _MAV_RETURN_float(msg,  24);
289
}
290
 
291
/**
292
 * @brief Get field aux2 from hil_controls message
293
 *
294
 * @return Aux 2, -1 .. 1
295
 */
296
static inline float mavlink_msg_hil_controls_get_aux2(const mavlink_message_t* msg)
297
{
298
        return _MAV_RETURN_float(msg,  28);
299
}
300
 
301
/**
302
 * @brief Get field aux3 from hil_controls message
303
 *
304
 * @return Aux 3, -1 .. 1
305
 */
306
static inline float mavlink_msg_hil_controls_get_aux3(const mavlink_message_t* msg)
307
{
308
        return _MAV_RETURN_float(msg,  32);
309
}
310
 
311
/**
312
 * @brief Get field aux4 from hil_controls message
313
 *
314
 * @return Aux 4, -1 .. 1
315
 */
316
static inline float mavlink_msg_hil_controls_get_aux4(const mavlink_message_t* msg)
317
{
318
        return _MAV_RETURN_float(msg,  36);
319
}
320
 
321
/**
322
 * @brief Get field mode from hil_controls message
323
 *
324
 * @return System mode (MAV_MODE)
325
 */
326
static inline uint8_t mavlink_msg_hil_controls_get_mode(const mavlink_message_t* msg)
327
{
328
        return _MAV_RETURN_uint8_t(msg,  40);
329
}
330
 
331
/**
332
 * @brief Get field nav_mode from hil_controls message
333
 *
334
 * @return Navigation mode (MAV_NAV_MODE)
335
 */
336
static inline uint8_t mavlink_msg_hil_controls_get_nav_mode(const mavlink_message_t* msg)
337
{
338
        return _MAV_RETURN_uint8_t(msg,  41);
339
}
340
 
341
/**
342
 * @brief Decode a hil_controls message into a struct
343
 *
344
 * @param msg The message to decode
345
 * @param hil_controls C-struct to decode the message contents into
346
 */
347
static inline void mavlink_msg_hil_controls_decode(const mavlink_message_t* msg, mavlink_hil_controls_t* hil_controls)
348
{
349
#if MAVLINK_NEED_BYTE_SWAP
350
        hil_controls->time_usec = mavlink_msg_hil_controls_get_time_usec(msg);
351
        hil_controls->roll_ailerons = mavlink_msg_hil_controls_get_roll_ailerons(msg);
352
        hil_controls->pitch_elevator = mavlink_msg_hil_controls_get_pitch_elevator(msg);
353
        hil_controls->yaw_rudder = mavlink_msg_hil_controls_get_yaw_rudder(msg);
354
        hil_controls->throttle = mavlink_msg_hil_controls_get_throttle(msg);
355
        hil_controls->aux1 = mavlink_msg_hil_controls_get_aux1(msg);
356
        hil_controls->aux2 = mavlink_msg_hil_controls_get_aux2(msg);
357
        hil_controls->aux3 = mavlink_msg_hil_controls_get_aux3(msg);
358
        hil_controls->aux4 = mavlink_msg_hil_controls_get_aux4(msg);
359
        hil_controls->mode = mavlink_msg_hil_controls_get_mode(msg);
360
        hil_controls->nav_mode = mavlink_msg_hil_controls_get_nav_mode(msg);
361
#else
362
        memcpy(hil_controls, _MAV_PAYLOAD(msg), 42);
363
#endif
364
}