RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_manual_setpoint.h
1#pragma once
2// MESSAGE MANUAL_SETPOINT PACKING
3
4#define MAVLINK_MSG_ID_MANUAL_SETPOINT 81
5
6MAVPACKED(
7typedef struct __mavlink_manual_setpoint_t {
8 uint32_t time_boot_ms; /*< Timestamp in milliseconds since system boot*/
9 float roll; /*< Desired roll rate in radians per second*/
10 float pitch; /*< Desired pitch rate in radians per second*/
11 float yaw; /*< Desired yaw rate in radians per second*/
12 float thrust; /*< Collective thrust, normalized to 0 .. 1*/
13 uint8_t mode_switch; /*< Flight mode switch position, 0.. 255*/
14 uint8_t manual_override_switch; /*< Override mode switch position, 0.. 255*/
15}) mavlink_manual_setpoint_t;
16
17#define MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN 22
18#define MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN 22
19#define MAVLINK_MSG_ID_81_LEN 22
20#define MAVLINK_MSG_ID_81_MIN_LEN 22
21
22#define MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC 106
23#define MAVLINK_MSG_ID_81_CRC 106
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_MANUAL_SETPOINT { \
29 81, \
30 "MANUAL_SETPOINT", \
31 7, \
32 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_manual_setpoint_t, time_boot_ms) }, \
33 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_manual_setpoint_t, roll) }, \
34 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_manual_setpoint_t, pitch) }, \
35 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_manual_setpoint_t, yaw) }, \
36 { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_manual_setpoint_t, thrust) }, \
37 { "mode_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_manual_setpoint_t, mode_switch) }, \
38 { "manual_override_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_manual_setpoint_t, manual_override_switch) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_MANUAL_SETPOINT { \
43 "MANUAL_SETPOINT", \
44 7, \
45 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_manual_setpoint_t, time_boot_ms) }, \
46 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_manual_setpoint_t, roll) }, \
47 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_manual_setpoint_t, pitch) }, \
48 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_manual_setpoint_t, yaw) }, \
49 { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_manual_setpoint_t, thrust) }, \
50 { "mode_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_manual_setpoint_t, mode_switch) }, \
51 { "manual_override_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_manual_setpoint_t, manual_override_switch) }, \
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a manual_setpoint message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
61 *
62 * @param time_boot_ms Timestamp in milliseconds since system boot
63 * @param roll Desired roll rate in radians per second
64 * @param pitch Desired pitch rate in radians per second
65 * @param yaw Desired yaw rate in radians per second
66 * @param thrust Collective thrust, normalized to 0 .. 1
67 * @param mode_switch Flight mode switch position, 0.. 255
68 * @param manual_override_switch Override mode switch position, 0.. 255
69 * @return length of the message in bytes (excluding serial stream start sign)
70 */
71static inline uint16_t mavlink_msg_manual_setpoint_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN];
76 _mav_put_uint32_t(buf, 0, time_boot_ms);
77 _mav_put_float(buf, 4, roll);
78 _mav_put_float(buf, 8, pitch);
79 _mav_put_float(buf, 12, yaw);
80 _mav_put_float(buf, 16, thrust);
81 _mav_put_uint8_t(buf, 20, mode_switch);
82 _mav_put_uint8_t(buf, 21, manual_override_switch);
83
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN);
85#else
86 mavlink_manual_setpoint_t packet;
87 packet.time_boot_ms = time_boot_ms;
88 packet.roll = roll;
89 packet.pitch = pitch;
90 packet.yaw = yaw;
91 packet.thrust = thrust;
92 packet.mode_switch = mode_switch;
93 packet.manual_override_switch = manual_override_switch;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_MANUAL_SETPOINT;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
100}
101
102/**
103 * @brief Pack a manual_setpoint message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param time_boot_ms Timestamp in milliseconds since system boot
109 * @param roll Desired roll rate in radians per second
110 * @param pitch Desired pitch rate in radians per second
111 * @param yaw Desired yaw rate in radians per second
112 * @param thrust Collective thrust, normalized to 0 .. 1
113 * @param mode_switch Flight mode switch position, 0.. 255
114 * @param manual_override_switch Override mode switch position, 0.. 255
115 * @return length of the message in bytes (excluding serial stream start sign)
116 */
117static inline uint16_t mavlink_msg_manual_setpoint_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 uint32_t time_boot_ms,float roll,float pitch,float yaw,float thrust,uint8_t mode_switch,uint8_t manual_override_switch)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN];
123 _mav_put_uint32_t(buf, 0, time_boot_ms);
124 _mav_put_float(buf, 4, roll);
125 _mav_put_float(buf, 8, pitch);
126 _mav_put_float(buf, 12, yaw);
127 _mav_put_float(buf, 16, thrust);
128 _mav_put_uint8_t(buf, 20, mode_switch);
129 _mav_put_uint8_t(buf, 21, manual_override_switch);
130
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN);
132#else
133 mavlink_manual_setpoint_t packet;
134 packet.time_boot_ms = time_boot_ms;
135 packet.roll = roll;
136 packet.pitch = pitch;
137 packet.yaw = yaw;
138 packet.thrust = thrust;
139 packet.mode_switch = mode_switch;
140 packet.manual_override_switch = manual_override_switch;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_MANUAL_SETPOINT;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
147}
148
149/**
150 * @brief Encode a manual_setpoint struct
151 *
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param manual_setpoint C-struct to read the message contents from
156 */
157static inline uint16_t mavlink_msg_manual_setpoint_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_manual_setpoint_t* manual_setpoint)
158{
159 return mavlink_msg_manual_setpoint_pack(system_id, component_id, msg, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch);
160}
161
162/**
163 * @brief Encode a manual_setpoint struct on a channel
164 *
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param manual_setpoint C-struct to read the message contents from
170 */
171static inline uint16_t mavlink_msg_manual_setpoint_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_manual_setpoint_t* manual_setpoint)
172{
173 return mavlink_msg_manual_setpoint_pack_chan(system_id, component_id, chan, msg, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch);
174}
175
176/**
177 * @brief Send a manual_setpoint message
178 * @param chan MAVLink channel to send the message
179 *
180 * @param time_boot_ms Timestamp in milliseconds since system boot
181 * @param roll Desired roll rate in radians per second
182 * @param pitch Desired pitch rate in radians per second
183 * @param yaw Desired yaw rate in radians per second
184 * @param thrust Collective thrust, normalized to 0 .. 1
185 * @param mode_switch Flight mode switch position, 0.. 255
186 * @param manual_override_switch Override mode switch position, 0.. 255
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_manual_setpoint_send(mavlink_channel_t chan, uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN];
194 _mav_put_uint32_t(buf, 0, time_boot_ms);
195 _mav_put_float(buf, 4, roll);
196 _mav_put_float(buf, 8, pitch);
197 _mav_put_float(buf, 12, yaw);
198 _mav_put_float(buf, 16, thrust);
199 _mav_put_uint8_t(buf, 20, mode_switch);
200 _mav_put_uint8_t(buf, 21, manual_override_switch);
201
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, buf, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
203#else
204 mavlink_manual_setpoint_t packet;
205 packet.time_boot_ms = time_boot_ms;
206 packet.roll = roll;
207 packet.pitch = pitch;
208 packet.yaw = yaw;
209 packet.thrust = thrust;
210 packet.mode_switch = mode_switch;
211 packet.manual_override_switch = manual_override_switch;
212
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, (const char *)&packet, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
214#endif
215}
216
217/**
218 * @brief Send a manual_setpoint message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
221 */
222static inline void mavlink_msg_manual_setpoint_send_struct(mavlink_channel_t chan, const mavlink_manual_setpoint_t* manual_setpoint)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_manual_setpoint_send(chan, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch);
226#else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, (const char *)manual_setpoint, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
228#endif
229}
230
231#if MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
232/*
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
238 */
239static inline void mavlink_msg_manual_setpoint_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_uint32_t(buf, 0, time_boot_ms);
244 _mav_put_float(buf, 4, roll);
245 _mav_put_float(buf, 8, pitch);
246 _mav_put_float(buf, 12, yaw);
247 _mav_put_float(buf, 16, thrust);
248 _mav_put_uint8_t(buf, 20, mode_switch);
249 _mav_put_uint8_t(buf, 21, manual_override_switch);
250
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, buf, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
252#else
253 mavlink_manual_setpoint_t *packet = (mavlink_manual_setpoint_t *)msgbuf;
254 packet->time_boot_ms = time_boot_ms;
255 packet->roll = roll;
256 packet->pitch = pitch;
257 packet->yaw = yaw;
258 packet->thrust = thrust;
259 packet->mode_switch = mode_switch;
260 packet->manual_override_switch = manual_override_switch;
261
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, (const char *)packet, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE MANUAL_SETPOINT UNPACKING
270
271
272/**
273 * @brief Get field time_boot_ms from manual_setpoint message
274 *
275 * @return Timestamp in milliseconds since system boot
276 */
277static inline uint32_t mavlink_msg_manual_setpoint_get_time_boot_ms(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_uint32_t(msg, 0);
280}
281
282/**
283 * @brief Get field roll from manual_setpoint message
284 *
285 * @return Desired roll rate in radians per second
286 */
287static inline float mavlink_msg_manual_setpoint_get_roll(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_float(msg, 4);
290}
291
292/**
293 * @brief Get field pitch from manual_setpoint message
294 *
295 * @return Desired pitch rate in radians per second
296 */
297static inline float mavlink_msg_manual_setpoint_get_pitch(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_float(msg, 8);
300}
301
302/**
303 * @brief Get field yaw from manual_setpoint message
304 *
305 * @return Desired yaw rate in radians per second
306 */
307static inline float mavlink_msg_manual_setpoint_get_yaw(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_float(msg, 12);
310}
311
312/**
313 * @brief Get field thrust from manual_setpoint message
314 *
315 * @return Collective thrust, normalized to 0 .. 1
316 */
317static inline float mavlink_msg_manual_setpoint_get_thrust(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_float(msg, 16);
320}
321
322/**
323 * @brief Get field mode_switch from manual_setpoint message
324 *
325 * @return Flight mode switch position, 0.. 255
326 */
327static inline uint8_t mavlink_msg_manual_setpoint_get_mode_switch(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_uint8_t(msg, 20);
330}
331
332/**
333 * @brief Get field manual_override_switch from manual_setpoint message
334 *
335 * @return Override mode switch position, 0.. 255
336 */
337static inline uint8_t mavlink_msg_manual_setpoint_get_manual_override_switch(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_uint8_t(msg, 21);
340}
341
342/**
343 * @brief Decode a manual_setpoint message into a struct
344 *
345 * @param msg The message to decode
346 * @param manual_setpoint C-struct to decode the message contents into
347 */
348static inline void mavlink_msg_manual_setpoint_decode(const mavlink_message_t* msg, mavlink_manual_setpoint_t* manual_setpoint)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 manual_setpoint->time_boot_ms = mavlink_msg_manual_setpoint_get_time_boot_ms(msg);
352 manual_setpoint->roll = mavlink_msg_manual_setpoint_get_roll(msg);
353 manual_setpoint->pitch = mavlink_msg_manual_setpoint_get_pitch(msg);
354 manual_setpoint->yaw = mavlink_msg_manual_setpoint_get_yaw(msg);
355 manual_setpoint->thrust = mavlink_msg_manual_setpoint_get_thrust(msg);
356 manual_setpoint->mode_switch = mavlink_msg_manual_setpoint_get_mode_switch(msg);
357 manual_setpoint->manual_override_switch = mavlink_msg_manual_setpoint_get_manual_override_switch(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN? msg->len : MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN;
360 memset(manual_setpoint, 0, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN);
361 memcpy(manual_setpoint, _MAV_PAYLOAD(msg), len);
362#endif
363}