Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_hil_controls.h
blob1d2f7a8f3e50ff457f7a5fd5aded4d7afeb185d9
1 // MESSAGE HIL_CONTROLS PACKING
3 #define MAVLINK_MSG_ID_HIL_CONTROLS 91
5 typedef struct __mavlink_hil_controls_t {
6 uint64_t time_usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
7 float roll_ailerons; ///< Control output -1 .. 1
8 float pitch_elevator; ///< Control output -1 .. 1
9 float yaw_rudder; ///< Control output -1 .. 1
10 float throttle; ///< Throttle 0 .. 1
11 float aux1; ///< Aux 1, -1 .. 1
12 float aux2; ///< Aux 2, -1 .. 1
13 float aux3; ///< Aux 3, -1 .. 1
14 float aux4; ///< Aux 4, -1 .. 1
15 uint8_t mode; ///< System mode (MAV_MODE)
16 uint8_t nav_mode; ///< Navigation mode (MAV_NAV_MODE)
17 } mavlink_hil_controls_t;
19 #define MAVLINK_MSG_ID_HIL_CONTROLS_LEN 42
20 #define MAVLINK_MSG_ID_91_LEN 42
23 #define MAVLINK_MESSAGE_INFO_HIL_CONTROLS \
24 { \
25 "HIL_CONTROLS", \
26 11, \
27 { \
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 } \
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
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)
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)
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);
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;
94 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
95 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
97 msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
98 return mavlink_finalize_message(msg, system_id, component_id, 42, 63);
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)
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)
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);
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;
153 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
154 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
156 msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
157 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 63);
161 * @brief Encode a hil_controls struct into a message
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
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)
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);
174 * @brief Send a hil_controls message
175 * @param chan MAVLink channel to send the message
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)
189 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
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)
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);
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;
222 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)&packet, 42, 63);
223 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
226 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
228 // MESSAGE HIL_CONTROLS UNPACKING
232 * @brief Get field time_usec from hil_controls message
234 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
236 static inline uint64_t mavlink_msg_hil_controls_get_time_usec(const mavlink_message_t *msg)
238 return _MAV_RETURN_uint64_t(msg, 0);
242 * @brief Get field roll_ailerons from hil_controls message
244 * @return Control output -1 .. 1
246 static inline float mavlink_msg_hil_controls_get_roll_ailerons(const mavlink_message_t *msg)
248 return _MAV_RETURN_float(msg, 8);
252 * @brief Get field pitch_elevator from hil_controls message
254 * @return Control output -1 .. 1
256 static inline float mavlink_msg_hil_controls_get_pitch_elevator(const mavlink_message_t *msg)
258 return _MAV_RETURN_float(msg, 12);
262 * @brief Get field yaw_rudder from hil_controls message
264 * @return Control output -1 .. 1
266 static inline float mavlink_msg_hil_controls_get_yaw_rudder(const mavlink_message_t *msg)
268 return _MAV_RETURN_float(msg, 16);
272 * @brief Get field throttle from hil_controls message
274 * @return Throttle 0 .. 1
276 static inline float mavlink_msg_hil_controls_get_throttle(const mavlink_message_t *msg)
278 return _MAV_RETURN_float(msg, 20);
282 * @brief Get field aux1 from hil_controls message
284 * @return Aux 1, -1 .. 1
286 static inline float mavlink_msg_hil_controls_get_aux1(const mavlink_message_t *msg)
288 return _MAV_RETURN_float(msg, 24);
292 * @brief Get field aux2 from hil_controls message
294 * @return Aux 2, -1 .. 1
296 static inline float mavlink_msg_hil_controls_get_aux2(const mavlink_message_t *msg)
298 return _MAV_RETURN_float(msg, 28);
302 * @brief Get field aux3 from hil_controls message
304 * @return Aux 3, -1 .. 1
306 static inline float mavlink_msg_hil_controls_get_aux3(const mavlink_message_t *msg)
308 return _MAV_RETURN_float(msg, 32);
312 * @brief Get field aux4 from hil_controls message
314 * @return Aux 4, -1 .. 1
316 static inline float mavlink_msg_hil_controls_get_aux4(const mavlink_message_t *msg)
318 return _MAV_RETURN_float(msg, 36);
322 * @brief Get field mode from hil_controls message
324 * @return System mode (MAV_MODE)
326 static inline uint8_t mavlink_msg_hil_controls_get_mode(const mavlink_message_t *msg)
328 return _MAV_RETURN_uint8_t(msg, 40);
332 * @brief Get field nav_mode from hil_controls message
334 * @return Navigation mode (MAV_NAV_MODE)
336 static inline uint8_t mavlink_msg_hil_controls_get_nav_mode(const mavlink_message_t *msg)
338 return _MAV_RETURN_uint8_t(msg, 41);
342 * @brief Decode a hil_controls message into a struct
344 * @param msg The message to decode
345 * @param hil_controls C-struct to decode the message contents into
347 static inline void mavlink_msg_hil_controls_decode(const mavlink_message_t *msg, mavlink_hil_controls_t *hil_controls)
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