Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_hil_actuator_controls.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE HIL_ACTUATOR_CONTROLS PACKING
3
4#define MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS 93
5
6
8 uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
9 uint64_t flags; /*< Flags bitmask.*/
10 float controls[16]; /*< Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.*/
11 uint8_t mode; /*< System mode. Includes arming state.*/
12} mavlink_hil_actuator_controls_t;
13
14#define MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN 81
15#define MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN 81
16#define MAVLINK_MSG_ID_93_LEN 81
17#define MAVLINK_MSG_ID_93_MIN_LEN 81
18
19#define MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC 47
20#define MAVLINK_MSG_ID_93_CRC 47
21
22#define MAVLINK_MSG_HIL_ACTUATOR_CONTROLS_FIELD_CONTROLS_LEN 16
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_HIL_ACTUATOR_CONTROLS {
26 93,
27 "HIL_ACTUATOR_CONTROLS",
28 4,
29 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_actuator_controls_t, time_usec) },
30 { "controls", NULL, MAVLINK_TYPE_FLOAT, 16, 16, offsetof(mavlink_hil_actuator_controls_t, controls) },
31 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 80, offsetof(mavlink_hil_actuator_controls_t, mode) },
32 { "flags", NULL, MAVLINK_TYPE_UINT64_T, 0, 8, offsetof(mavlink_hil_actuator_controls_t, flags) },
33 } \
34}
35#else
36#define MAVLINK_MESSAGE_INFO_HIL_ACTUATOR_CONTROLS {
37 "HIL_ACTUATOR_CONTROLS",
38 4,
39 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_actuator_controls_t, time_usec) },
40 { "controls", NULL, MAVLINK_TYPE_FLOAT, 16, 16, offsetof(mavlink_hil_actuator_controls_t, controls) },
41 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 80, offsetof(mavlink_hil_actuator_controls_t, mode) },
42 { "flags", NULL, MAVLINK_TYPE_UINT64_T, 0, 8, offsetof(mavlink_hil_actuator_controls_t, flags) },
43 } \
44}
45#endif
46
47/**
48 * @brief Pack a hil_actuator_controls message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
52 *
53 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
54 * @param controls Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.
55 * @param mode System mode. Includes arming state.
56 * @param flags Flags bitmask.
57 * @return length of the message in bytes (excluding serial stream start sign)
58 */
59static inline uint16_t mavlink_msg_hil_actuator_controls_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint64_t time_usec, const float *controls, uint8_t mode, uint64_t flags)
61{
62#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
64 _mav_put_uint64_t(buf, 0, time_usec);
65 _mav_put_uint64_t(buf, 8, flags);
66 _mav_put_uint8_t(buf, 80, mode);
67 _mav_put_float_array(buf, 16, controls, 16);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
69#else
70 mavlink_hil_actuator_controls_t packet;
71 packet.time_usec = time_usec;
72 packet.flags = flags;
73 packet.mode = mode;
74 mav_array_memcpy(packet.controls, controls, sizeof(float)*16);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
76#endif
77
80}
81
82/**
83 * @brief Pack a hil_actuator_controls message
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param status MAVLink status structure
87 * @param msg The MAVLink message to compress the data into
88 *
89 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
90 * @param controls Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.
91 * @param mode System mode. Includes arming state.
92 * @param flags Flags bitmask.
93 * @return length of the message in bytes (excluding serial stream start sign)
94 */
95static inline uint16_t mavlink_msg_hil_actuator_controls_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
96 uint64_t time_usec, const float *controls, uint8_t mode, uint64_t flags)
97{
98#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
100 _mav_put_uint64_t(buf, 0, time_usec);
101 _mav_put_uint64_t(buf, 8, flags);
102 _mav_put_uint8_t(buf, 80, mode);
103 _mav_put_float_array(buf, 16, controls, 16);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
105#else
106 mavlink_hil_actuator_controls_t packet;
107 packet.time_usec = time_usec;
108 packet.flags = flags;
109 packet.mode = mode;
110 mav_array_memcpy(packet.controls, controls, sizeof(float)*16);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
112#endif
113
115#if MAVLINK_CRC_EXTRA
116 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
117#else
118 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
119#endif
120}
121
122/**
123 * @brief Pack a hil_actuator_controls message on a channel
124 * @param system_id ID of this system
125 * @param component_id ID of this component (e.g. 200 for IMU)
126 * @param chan The MAVLink channel this message will be sent over
127 * @param msg The MAVLink message to compress the data into
128 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
129 * @param controls Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.
130 * @param mode System mode. Includes arming state.
131 * @param flags Flags bitmask.
132 * @return length of the message in bytes (excluding serial stream start sign)
133 */
134static inline uint16_t mavlink_msg_hil_actuator_controls_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
135 mavlink_message_t* msg,
136 uint64_t time_usec,const float *controls,uint8_t mode,uint64_t flags)
137{
138#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
140 _mav_put_uint64_t(buf, 0, time_usec);
141 _mav_put_uint64_t(buf, 8, flags);
142 _mav_put_uint8_t(buf, 80, mode);
143 _mav_put_float_array(buf, 16, controls, 16);
144 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
145#else
146 mavlink_hil_actuator_controls_t packet;
147 packet.time_usec = time_usec;
148 packet.flags = flags;
149 packet.mode = mode;
150 mav_array_memcpy(packet.controls, controls, sizeof(float)*16);
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
152#endif
153
155 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
156}
157
158/**
159 * @brief Encode a hil_actuator_controls struct
160 *
161 * @param system_id ID of this system
162 * @param component_id ID of this component (e.g. 200 for IMU)
163 * @param msg The MAVLink message to compress the data into
164 * @param hil_actuator_controls C-struct to read the message contents from
165 */
166static inline uint16_t mavlink_msg_hil_actuator_controls_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_actuator_controls_t* hil_actuator_controls)
167{
168 return mavlink_msg_hil_actuator_controls_pack(system_id, component_id, msg, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags);
169}
170
171/**
172 * @brief Encode a hil_actuator_controls struct on a channel
173 *
174 * @param system_id ID of this system
175 * @param component_id ID of this component (e.g. 200 for IMU)
176 * @param chan The MAVLink channel this message will be sent over
177 * @param msg The MAVLink message to compress the data into
178 * @param hil_actuator_controls C-struct to read the message contents from
179 */
180static inline uint16_t mavlink_msg_hil_actuator_controls_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_actuator_controls_t* hil_actuator_controls)
181{
182 return mavlink_msg_hil_actuator_controls_pack_chan(system_id, component_id, chan, msg, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags);
183}
184
185/**
186 * @brief Encode a hil_actuator_controls struct with provided status structure
187 *
188 * @param system_id ID of this system
189 * @param component_id ID of this component (e.g. 200 for IMU)
190 * @param status MAVLink status structure
191 * @param msg The MAVLink message to compress the data into
192 * @param hil_actuator_controls C-struct to read the message contents from
193 */
194static inline uint16_t mavlink_msg_hil_actuator_controls_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_actuator_controls_t* hil_actuator_controls)
195{
196 return mavlink_msg_hil_actuator_controls_pack_status(system_id, component_id, _status, msg, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags);
197}
198
199/**
200 * @brief Send a hil_actuator_controls message
201 * @param chan MAVLink channel to send the message
202 *
203 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
204 * @param controls Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.
205 * @param mode System mode. Includes arming state.
206 * @param flags Flags bitmask.
207 */
208#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
209
210static inline void mavlink_msg_hil_actuator_controls_send(mavlink_channel_t chan, uint64_t time_usec, const float *controls, uint8_t mode, uint64_t flags)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 char buf[MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN];
214 _mav_put_uint64_t(buf, 0, time_usec);
215 _mav_put_uint64_t(buf, 8, flags);
216 _mav_put_uint8_t(buf, 80, mode);
217 _mav_put_float_array(buf, 16, controls, 16);
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS, buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
219#else
220 mavlink_hil_actuator_controls_t packet;
221 packet.time_usec = time_usec;
222 packet.flags = flags;
223 packet.mode = mode;
224 mav_array_memcpy(packet.controls, controls, sizeof(float)*16);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS, (const char *)&packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
226#endif
227}
228
229/**
230 * @brief Send a hil_actuator_controls message
231 * @param chan MAVLink channel to send the message
232 * @param struct The MAVLink struct to serialize
233 */
234static inline void mavlink_msg_hil_actuator_controls_send_struct(mavlink_channel_t chan, const mavlink_hil_actuator_controls_t* hil_actuator_controls)
235{
236#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 mavlink_msg_hil_actuator_controls_send(chan, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags);
238#else
239 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS, (const char *)hil_actuator_controls, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
240#endif
241}
242
243#if MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
244/*
245 This variant of _send() can be used to save stack space by reusing
246 memory from the receive buffer. The caller provides a
247 mavlink_message_t which is the size of a full mavlink message. This
248 is usually the receive buffer for the channel, and allows a reply to an
249 incoming message with minimum stack space usage.
250 */
251static inline void mavlink_msg_hil_actuator_controls_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, const float *controls, uint8_t mode, uint64_t flags)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_uint64_t(buf, 0, time_usec);
256 _mav_put_uint64_t(buf, 8, flags);
257 _mav_put_uint8_t(buf, 80, mode);
258 _mav_put_float_array(buf, 16, controls, 16);
259 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS, buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
260#else
261 mavlink_hil_actuator_controls_t *packet = (mavlink_hil_actuator_controls_t *)msgbuf;
262 packet->time_usec = time_usec;
263 packet->flags = flags;
264 packet->mode = mode;
265 mav_array_memcpy(packet->controls, controls, sizeof(float)*16);
266 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS, (const char *)packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC);
267#endif
268}
269#endif
270
271#endif
272
273// MESSAGE HIL_ACTUATOR_CONTROLS UNPACKING
274
275
276/**
277 * @brief Get field time_usec from hil_actuator_controls message
278 *
279 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
280 */
281static inline uint64_t mavlink_msg_hil_actuator_controls_get_time_usec(const mavlink_message_t* msg)
282{
283 return _MAV_RETURN_uint64_t(msg, 0);
284}
285
286/**
287 * @brief Get field controls from hil_actuator_controls message
288 *
289 * @return Control outputs -1 .. 1. Channel assignment depends on the simulated hardware.
290 */
291static inline uint16_t mavlink_msg_hil_actuator_controls_get_controls(const mavlink_message_t* msg, float *controls)
292{
293 return _MAV_RETURN_float_array(msg, controls, 16, 16);
294}
295
296/**
297 * @brief Get field mode from hil_actuator_controls message
298 *
299 * @return System mode. Includes arming state.
300 */
301static inline uint8_t mavlink_msg_hil_actuator_controls_get_mode(const mavlink_message_t* msg)
302{
303 return _MAV_RETURN_uint8_t(msg, 80);
304}
305
306/**
307 * @brief Get field flags from hil_actuator_controls message
308 *
309 * @return Flags bitmask.
310 */
311static inline uint64_t mavlink_msg_hil_actuator_controls_get_flags(const mavlink_message_t* msg)
312{
313 return _MAV_RETURN_uint64_t(msg, 8);
314}
315
316/**
317 * @brief Decode a hil_actuator_controls message into a struct
318 *
319 * @param msg The message to decode
320 * @param hil_actuator_controls C-struct to decode the message contents into
321 */
322static inline void mavlink_msg_hil_actuator_controls_decode(const mavlink_message_t* msg, mavlink_hil_actuator_controls_t* hil_actuator_controls)
323{
324#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
325 hil_actuator_controls->time_usec = mavlink_msg_hil_actuator_controls_get_time_usec(msg);
326 hil_actuator_controls->flags = mavlink_msg_hil_actuator_controls_get_flags(msg);
327 mavlink_msg_hil_actuator_controls_get_controls(msg, hil_actuator_controls->controls);
328 hil_actuator_controls->mode = mavlink_msg_hil_actuator_controls_get_mode(msg);
329#else
330 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN? msg->len : MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN;
331 memset(hil_actuator_controls, 0, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN);
332 memcpy(hil_actuator_controls, _MAV_PAYLOAD(msg), len);
333#endif
334}