source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_manual_control.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 17.3 KB
Line 
1// MESSAGE MANUAL_CONTROL PACKING
2
3#define MAVLINK_MSG_ID_MANUAL_CONTROL 69
4
5typedef struct MAVLINK_PACKED __mavlink_manual_control_t
6{
7 int16_t x; /*< X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.*/
8 int16_t y; /*< Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.*/
9 int16_t z; /*< Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.*/
10 int16_t r; /*< R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.*/
11 uint16_t buttons; /*< A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.*/
12 uint8_t target; /*< The system to be controlled.*/
13} mavlink_manual_control_t;
14
15#define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 11
16#define MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN 11
17#define MAVLINK_MSG_ID_69_LEN 11
18#define MAVLINK_MSG_ID_69_MIN_LEN 11
19
20#define MAVLINK_MSG_ID_MANUAL_CONTROL_CRC 243
21#define MAVLINK_MSG_ID_69_CRC 243
22
23
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
27 69, \
28 "MANUAL_CONTROL", \
29 6, \
30 { { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
31 { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
32 { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
33 { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
34 { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
35 { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
36 } \
37}
38#else
39#define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
40 "MANUAL_CONTROL", \
41 6, \
42 { { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
43 { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
44 { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
45 { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
46 { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
47 { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
48 } \
49}
50#endif
51
52/**
53 * @brief Pack a manual_control message
54 * @param system_id ID of this system
55 * @param component_id ID of this component (e.g. 200 for IMU)
56 * @param msg The MAVLink message to compress the data into
57 *
58 * @param target The system to be controlled.
59 * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
60 * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
61 * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
62 * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
63 * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
64 * @return length of the message in bytes (excluding serial stream start sign)
65 */
66static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
67 uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
68{
69#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
70 char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
71 _mav_put_int16_t(buf, 0, x);
72 _mav_put_int16_t(buf, 2, y);
73 _mav_put_int16_t(buf, 4, z);
74 _mav_put_int16_t(buf, 6, r);
75 _mav_put_uint16_t(buf, 8, buttons);
76 _mav_put_uint8_t(buf, 10, target);
77
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
79#else
80 mavlink_manual_control_t packet;
81 packet.x = x;
82 packet.y = y;
83 packet.z = z;
84 packet.r = r;
85 packet.buttons = buttons;
86 packet.target = target;
87
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
89#endif
90
91 msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
92 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
93}
94
95/**
96 * @brief Pack a manual_control message on a channel
97 * @param system_id ID of this system
98 * @param component_id ID of this component (e.g. 200 for IMU)
99 * @param chan The MAVLink channel this message will be sent over
100 * @param msg The MAVLink message to compress the data into
101 * @param target The system to be controlled.
102 * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
103 * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
104 * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
105 * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
106 * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
107 * @return length of the message in bytes (excluding serial stream start sign)
108 */
109static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
110 mavlink_message_t* msg,
111 uint8_t target,int16_t x,int16_t y,int16_t z,int16_t r,uint16_t buttons)
112{
113#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114 char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
115 _mav_put_int16_t(buf, 0, x);
116 _mav_put_int16_t(buf, 2, y);
117 _mav_put_int16_t(buf, 4, z);
118 _mav_put_int16_t(buf, 6, r);
119 _mav_put_uint16_t(buf, 8, buttons);
120 _mav_put_uint8_t(buf, 10, target);
121
122 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
123#else
124 mavlink_manual_control_t packet;
125 packet.x = x;
126 packet.y = y;
127 packet.z = z;
128 packet.r = r;
129 packet.buttons = buttons;
130 packet.target = target;
131
132 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
133#endif
134
135 msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
136 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
137}
138
139/**
140 * @brief Encode a manual_control struct
141 *
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param msg The MAVLink message to compress the data into
145 * @param manual_control C-struct to read the message contents from
146 */
147static inline uint16_t mavlink_msg_manual_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control)
148{
149 return mavlink_msg_manual_control_pack(system_id, component_id, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
150}
151
152/**
153 * @brief Encode a manual_control struct on a channel
154 *
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param manual_control C-struct to read the message contents from
160 */
161static inline uint16_t mavlink_msg_manual_control_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control)
162{
163 return mavlink_msg_manual_control_pack_chan(system_id, component_id, chan, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
164}
165
166/**
167 * @brief Send a manual_control message
168 * @param chan MAVLink channel to send the message
169 *
170 * @param target The system to be controlled.
171 * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
172 * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
173 * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
174 * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
175 * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
176 */
177#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
178
179static inline void mavlink_msg_manual_control_send(mavlink_channel_t chan, uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
180{
181#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
183 _mav_put_int16_t(buf, 0, x);
184 _mav_put_int16_t(buf, 2, y);
185 _mav_put_int16_t(buf, 4, z);
186 _mav_put_int16_t(buf, 6, r);
187 _mav_put_uint16_t(buf, 8, buttons);
188 _mav_put_uint8_t(buf, 10, target);
189
190 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
191#else
192 mavlink_manual_control_t packet;
193 packet.x = x;
194 packet.y = y;
195 packet.z = z;
196 packet.r = r;
197 packet.buttons = buttons;
198 packet.target = target;
199
200 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)&packet, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
201#endif
202}
203
204/**
205 * @brief Send a manual_control message
206 * @param chan MAVLink channel to send the message
207 * @param struct The MAVLink struct to serialize
208 */
209static inline void mavlink_msg_manual_control_send_struct(mavlink_channel_t chan, const mavlink_manual_control_t* manual_control)
210{
211#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
212 mavlink_msg_manual_control_send(chan, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
213#else
214 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)manual_control, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
215#endif
216}
217
218#if MAVLINK_MSG_ID_MANUAL_CONTROL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
219/*
220 This varient of _send() can be used to save stack space by re-using
221 memory from the receive buffer. The caller provides a
222 mavlink_message_t which is the size of a full mavlink message. This
223 is usually the receive buffer for the channel, and allows a reply to an
224 incoming message with minimum stack space usage.
225 */
226static inline void mavlink_msg_manual_control_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
227{
228#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
229 char *buf = (char *)msgbuf;
230 _mav_put_int16_t(buf, 0, x);
231 _mav_put_int16_t(buf, 2, y);
232 _mav_put_int16_t(buf, 4, z);
233 _mav_put_int16_t(buf, 6, r);
234 _mav_put_uint16_t(buf, 8, buttons);
235 _mav_put_uint8_t(buf, 10, target);
236
237 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
238#else
239 mavlink_manual_control_t *packet = (mavlink_manual_control_t *)msgbuf;
240 packet->x = x;
241 packet->y = y;
242 packet->z = z;
243 packet->r = r;
244 packet->buttons = buttons;
245 packet->target = target;
246
247 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)packet, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
248#endif
249}
250#endif
251
252#endif
253
254// MESSAGE MANUAL_CONTROL UNPACKING
255
256
257/**
258 * @brief Get field target from manual_control message
259 *
260 * @return The system to be controlled.
261 */
262static inline uint8_t mavlink_msg_manual_control_get_target(const mavlink_message_t* msg)
263{
264 return _MAV_RETURN_uint8_t(msg, 10);
265}
266
267/**
268 * @brief Get field x from manual_control message
269 *
270 * @return X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
271 */
272static inline int16_t mavlink_msg_manual_control_get_x(const mavlink_message_t* msg)
273{
274 return _MAV_RETURN_int16_t(msg, 0);
275}
276
277/**
278 * @brief Get field y from manual_control message
279 *
280 * @return Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
281 */
282static inline int16_t mavlink_msg_manual_control_get_y(const mavlink_message_t* msg)
283{
284 return _MAV_RETURN_int16_t(msg, 2);
285}
286
287/**
288 * @brief Get field z from manual_control message
289 *
290 * @return Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
291 */
292static inline int16_t mavlink_msg_manual_control_get_z(const mavlink_message_t* msg)
293{
294 return _MAV_RETURN_int16_t(msg, 4);
295}
296
297/**
298 * @brief Get field r from manual_control message
299 *
300 * @return R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
301 */
302static inline int16_t mavlink_msg_manual_control_get_r(const mavlink_message_t* msg)
303{
304 return _MAV_RETURN_int16_t(msg, 6);
305}
306
307/**
308 * @brief Get field buttons from manual_control message
309 *
310 * @return A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
311 */
312static inline uint16_t mavlink_msg_manual_control_get_buttons(const mavlink_message_t* msg)
313{
314 return _MAV_RETURN_uint16_t(msg, 8);
315}
316
317/**
318 * @brief Decode a manual_control message into a struct
319 *
320 * @param msg The message to decode
321 * @param manual_control C-struct to decode the message contents into
322 */
323static inline void mavlink_msg_manual_control_decode(const mavlink_message_t* msg, mavlink_manual_control_t* manual_control)
324{
325#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
326 manual_control->x = mavlink_msg_manual_control_get_x(msg);
327 manual_control->y = mavlink_msg_manual_control_get_y(msg);
328 manual_control->z = mavlink_msg_manual_control_get_z(msg);
329 manual_control->r = mavlink_msg_manual_control_get_r(msg);
330 manual_control->buttons = mavlink_msg_manual_control_get_buttons(msg);
331 manual_control->target = mavlink_msg_manual_control_get_target(msg);
332#else
333 uint8_t len = msg->len < MAVLINK_MSG_ID_MANUAL_CONTROL_LEN? msg->len : MAVLINK_MSG_ID_MANUAL_CONTROL_LEN;
334 memset(manual_control, 0, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
335 memcpy(manual_control, _MAV_PAYLOAD(msg), len);
336#endif
337}
Note: See TracBrowser for help on using the repository browser.