RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_nav_controller_output.h
1#pragma once
2// MESSAGE NAV_CONTROLLER_OUTPUT PACKING
3
4#define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT 62
5
6MAVPACKED(
7typedef struct __mavlink_nav_controller_output_t {
8 float nav_roll; /*< Current desired roll in degrees*/
9 float nav_pitch; /*< Current desired pitch in degrees*/
10 float alt_error; /*< Current altitude error in meters*/
11 float aspd_error; /*< Current airspeed error in meters/second*/
12 float xtrack_error; /*< Current crosstrack error on x-y plane in meters*/
13 int16_t nav_bearing; /*< Current desired heading in degrees*/
14 int16_t target_bearing; /*< Bearing to current waypoint/target in degrees*/
15 uint16_t wp_dist; /*< Distance to active waypoint in meters*/
16}) mavlink_nav_controller_output_t;
17
18#define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN 26
19#define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN 26
20#define MAVLINK_MSG_ID_62_LEN 26
21#define MAVLINK_MSG_ID_62_MIN_LEN 26
22
23#define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC 183
24#define MAVLINK_MSG_ID_62_CRC 183
25
26
27
28#if MAVLINK_COMMAND_24BIT
29#define MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT { \
30 62, \
31 "NAV_CONTROLLER_OUTPUT", \
32 8, \
33 { { "nav_roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_nav_controller_output_t, nav_roll) }, \
34 { "nav_pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_nav_controller_output_t, nav_pitch) }, \
35 { "nav_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_nav_controller_output_t, nav_bearing) }, \
36 { "target_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_nav_controller_output_t, target_bearing) }, \
37 { "wp_dist", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_nav_controller_output_t, wp_dist) }, \
38 { "alt_error", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_nav_controller_output_t, alt_error) }, \
39 { "aspd_error", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_nav_controller_output_t, aspd_error) }, \
40 { "xtrack_error", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_nav_controller_output_t, xtrack_error) }, \
41 } \
42}
43#else
44#define MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT { \
45 "NAV_CONTROLLER_OUTPUT", \
46 8, \
47 { { "nav_roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_nav_controller_output_t, nav_roll) }, \
48 { "nav_pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_nav_controller_output_t, nav_pitch) }, \
49 { "nav_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_nav_controller_output_t, nav_bearing) }, \
50 { "target_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_nav_controller_output_t, target_bearing) }, \
51 { "wp_dist", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_nav_controller_output_t, wp_dist) }, \
52 { "alt_error", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_nav_controller_output_t, alt_error) }, \
53 { "aspd_error", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_nav_controller_output_t, aspd_error) }, \
54 { "xtrack_error", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_nav_controller_output_t, xtrack_error) }, \
55 } \
56}
57#endif
58
59/**
60 * @brief Pack a nav_controller_output message
61 * @param system_id ID of this system
62 * @param component_id ID of this component (e.g. 200 for IMU)
63 * @param msg The MAVLink message to compress the data into
64 *
65 * @param nav_roll Current desired roll in degrees
66 * @param nav_pitch Current desired pitch in degrees
67 * @param nav_bearing Current desired heading in degrees
68 * @param target_bearing Bearing to current waypoint/target in degrees
69 * @param wp_dist Distance to active waypoint in meters
70 * @param alt_error Current altitude error in meters
71 * @param aspd_error Current airspeed error in meters/second
72 * @param xtrack_error Current crosstrack error on x-y plane in meters
73 * @return length of the message in bytes (excluding serial stream start sign)
74 */
75static inline uint16_t mavlink_msg_nav_controller_output_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
76 float nav_roll, float nav_pitch, int16_t nav_bearing, int16_t target_bearing, uint16_t wp_dist, float alt_error, float aspd_error, float xtrack_error)
77{
78#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
79 char buf[MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN];
80 _mav_put_float(buf, 0, nav_roll);
81 _mav_put_float(buf, 4, nav_pitch);
82 _mav_put_float(buf, 8, alt_error);
83 _mav_put_float(buf, 12, aspd_error);
84 _mav_put_float(buf, 16, xtrack_error);
85 _mav_put_int16_t(buf, 20, nav_bearing);
86 _mav_put_int16_t(buf, 22, target_bearing);
87 _mav_put_uint16_t(buf, 24, wp_dist);
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
90#else
91 mavlink_nav_controller_output_t packet;
92 packet.nav_roll = nav_roll;
93 packet.nav_pitch = nav_pitch;
94 packet.alt_error = alt_error;
95 packet.aspd_error = aspd_error;
96 packet.xtrack_error = xtrack_error;
97 packet.nav_bearing = nav_bearing;
98 packet.target_bearing = target_bearing;
99 packet.wp_dist = wp_dist;
100
101 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
102#endif
103
104 msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT;
105 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
106}
107
108/**
109 * @brief Pack a nav_controller_output message on a channel
110 * @param system_id ID of this system
111 * @param component_id ID of this component (e.g. 200 for IMU)
112 * @param chan The MAVLink channel this message will be sent over
113 * @param msg The MAVLink message to compress the data into
114 * @param nav_roll Current desired roll in degrees
115 * @param nav_pitch Current desired pitch in degrees
116 * @param nav_bearing Current desired heading in degrees
117 * @param target_bearing Bearing to current waypoint/target in degrees
118 * @param wp_dist Distance to active waypoint in meters
119 * @param alt_error Current altitude error in meters
120 * @param aspd_error Current airspeed error in meters/second
121 * @param xtrack_error Current crosstrack error on x-y plane in meters
122 * @return length of the message in bytes (excluding serial stream start sign)
123 */
124static inline uint16_t mavlink_msg_nav_controller_output_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
125 mavlink_message_t* msg,
126 float nav_roll,float nav_pitch,int16_t nav_bearing,int16_t target_bearing,uint16_t wp_dist,float alt_error,float aspd_error,float xtrack_error)
127{
128#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
129 char buf[MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN];
130 _mav_put_float(buf, 0, nav_roll);
131 _mav_put_float(buf, 4, nav_pitch);
132 _mav_put_float(buf, 8, alt_error);
133 _mav_put_float(buf, 12, aspd_error);
134 _mav_put_float(buf, 16, xtrack_error);
135 _mav_put_int16_t(buf, 20, nav_bearing);
136 _mav_put_int16_t(buf, 22, target_bearing);
137 _mav_put_uint16_t(buf, 24, wp_dist);
138
139 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
140#else
141 mavlink_nav_controller_output_t packet;
142 packet.nav_roll = nav_roll;
143 packet.nav_pitch = nav_pitch;
144 packet.alt_error = alt_error;
145 packet.aspd_error = aspd_error;
146 packet.xtrack_error = xtrack_error;
147 packet.nav_bearing = nav_bearing;
148 packet.target_bearing = target_bearing;
149 packet.wp_dist = wp_dist;
150
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
152#endif
153
154 msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT;
155 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
156}
157
158/**
159 * @brief Encode a nav_controller_output 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 nav_controller_output C-struct to read the message contents from
165 */
166static inline uint16_t mavlink_msg_nav_controller_output_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_nav_controller_output_t* nav_controller_output)
167{
168 return mavlink_msg_nav_controller_output_pack(system_id, component_id, msg, nav_controller_output->nav_roll, nav_controller_output->nav_pitch, nav_controller_output->nav_bearing, nav_controller_output->target_bearing, nav_controller_output->wp_dist, nav_controller_output->alt_error, nav_controller_output->aspd_error, nav_controller_output->xtrack_error);
169}
170
171/**
172 * @brief Encode a nav_controller_output 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 nav_controller_output C-struct to read the message contents from
179 */
180static inline uint16_t mavlink_msg_nav_controller_output_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_nav_controller_output_t* nav_controller_output)
181{
182 return mavlink_msg_nav_controller_output_pack_chan(system_id, component_id, chan, msg, nav_controller_output->nav_roll, nav_controller_output->nav_pitch, nav_controller_output->nav_bearing, nav_controller_output->target_bearing, nav_controller_output->wp_dist, nav_controller_output->alt_error, nav_controller_output->aspd_error, nav_controller_output->xtrack_error);
183}
184
185/**
186 * @brief Send a nav_controller_output message
187 * @param chan MAVLink channel to send the message
188 *
189 * @param nav_roll Current desired roll in degrees
190 * @param nav_pitch Current desired pitch in degrees
191 * @param nav_bearing Current desired heading in degrees
192 * @param target_bearing Bearing to current waypoint/target in degrees
193 * @param wp_dist Distance to active waypoint in meters
194 * @param alt_error Current altitude error in meters
195 * @param aspd_error Current airspeed error in meters/second
196 * @param xtrack_error Current crosstrack error on x-y plane in meters
197 */
198#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
199
200static inline void mavlink_msg_nav_controller_output_send(mavlink_channel_t chan, float nav_roll, float nav_pitch, int16_t nav_bearing, int16_t target_bearing, uint16_t wp_dist, float alt_error, float aspd_error, float xtrack_error)
201{
202#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
203 char buf[MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN];
204 _mav_put_float(buf, 0, nav_roll);
205 _mav_put_float(buf, 4, nav_pitch);
206 _mav_put_float(buf, 8, alt_error);
207 _mav_put_float(buf, 12, aspd_error);
208 _mav_put_float(buf, 16, xtrack_error);
209 _mav_put_int16_t(buf, 20, nav_bearing);
210 _mav_put_int16_t(buf, 22, target_bearing);
211 _mav_put_uint16_t(buf, 24, wp_dist);
212
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, buf, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
214#else
215 mavlink_nav_controller_output_t packet;
216 packet.nav_roll = nav_roll;
217 packet.nav_pitch = nav_pitch;
218 packet.alt_error = alt_error;
219 packet.aspd_error = aspd_error;
220 packet.xtrack_error = xtrack_error;
221 packet.nav_bearing = nav_bearing;
222 packet.target_bearing = target_bearing;
223 packet.wp_dist = wp_dist;
224
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, (const char *)&packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
226#endif
227}
228
229/**
230 * @brief Send a nav_controller_output message
231 * @param chan MAVLink channel to send the message
232 * @param struct The MAVLink struct to serialize
233 */
234static inline void mavlink_msg_nav_controller_output_send_struct(mavlink_channel_t chan, const mavlink_nav_controller_output_t* nav_controller_output)
235{
236#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 mavlink_msg_nav_controller_output_send(chan, nav_controller_output->nav_roll, nav_controller_output->nav_pitch, nav_controller_output->nav_bearing, nav_controller_output->target_bearing, nav_controller_output->wp_dist, nav_controller_output->alt_error, nav_controller_output->aspd_error, nav_controller_output->xtrack_error);
238#else
239 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, (const char *)nav_controller_output, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
240#endif
241}
242
243#if MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
244/*
245 This varient of _send() can be used to save stack space by re-using
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_nav_controller_output_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float nav_roll, float nav_pitch, int16_t nav_bearing, int16_t target_bearing, uint16_t wp_dist, float alt_error, float aspd_error, float xtrack_error)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_float(buf, 0, nav_roll);
256 _mav_put_float(buf, 4, nav_pitch);
257 _mav_put_float(buf, 8, alt_error);
258 _mav_put_float(buf, 12, aspd_error);
259 _mav_put_float(buf, 16, xtrack_error);
260 _mav_put_int16_t(buf, 20, nav_bearing);
261 _mav_put_int16_t(buf, 22, target_bearing);
262 _mav_put_uint16_t(buf, 24, wp_dist);
263
264 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, buf, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
265#else
266 mavlink_nav_controller_output_t *packet = (mavlink_nav_controller_output_t *)msgbuf;
267 packet->nav_roll = nav_roll;
268 packet->nav_pitch = nav_pitch;
269 packet->alt_error = alt_error;
270 packet->aspd_error = aspd_error;
271 packet->xtrack_error = xtrack_error;
272 packet->nav_bearing = nav_bearing;
273 packet->target_bearing = target_bearing;
274 packet->wp_dist = wp_dist;
275
276 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, (const char *)packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC);
277#endif
278}
279#endif
280
281#endif
282
283// MESSAGE NAV_CONTROLLER_OUTPUT UNPACKING
284
285
286/**
287 * @brief Get field nav_roll from nav_controller_output message
288 *
289 * @return Current desired roll in degrees
290 */
291static inline float mavlink_msg_nav_controller_output_get_nav_roll(const mavlink_message_t* msg)
292{
293 return _MAV_RETURN_float(msg, 0);
294}
295
296/**
297 * @brief Get field nav_pitch from nav_controller_output message
298 *
299 * @return Current desired pitch in degrees
300 */
301static inline float mavlink_msg_nav_controller_output_get_nav_pitch(const mavlink_message_t* msg)
302{
303 return _MAV_RETURN_float(msg, 4);
304}
305
306/**
307 * @brief Get field nav_bearing from nav_controller_output message
308 *
309 * @return Current desired heading in degrees
310 */
311static inline int16_t mavlink_msg_nav_controller_output_get_nav_bearing(const mavlink_message_t* msg)
312{
313 return _MAV_RETURN_int16_t(msg, 20);
314}
315
316/**
317 * @brief Get field target_bearing from nav_controller_output message
318 *
319 * @return Bearing to current waypoint/target in degrees
320 */
321static inline int16_t mavlink_msg_nav_controller_output_get_target_bearing(const mavlink_message_t* msg)
322{
323 return _MAV_RETURN_int16_t(msg, 22);
324}
325
326/**
327 * @brief Get field wp_dist from nav_controller_output message
328 *
329 * @return Distance to active waypoint in meters
330 */
331static inline uint16_t mavlink_msg_nav_controller_output_get_wp_dist(const mavlink_message_t* msg)
332{
333 return _MAV_RETURN_uint16_t(msg, 24);
334}
335
336/**
337 * @brief Get field alt_error from nav_controller_output message
338 *
339 * @return Current altitude error in meters
340 */
341static inline float mavlink_msg_nav_controller_output_get_alt_error(const mavlink_message_t* msg)
342{
343 return _MAV_RETURN_float(msg, 8);
344}
345
346/**
347 * @brief Get field aspd_error from nav_controller_output message
348 *
349 * @return Current airspeed error in meters/second
350 */
351static inline float mavlink_msg_nav_controller_output_get_aspd_error(const mavlink_message_t* msg)
352{
353 return _MAV_RETURN_float(msg, 12);
354}
355
356/**
357 * @brief Get field xtrack_error from nav_controller_output message
358 *
359 * @return Current crosstrack error on x-y plane in meters
360 */
361static inline float mavlink_msg_nav_controller_output_get_xtrack_error(const mavlink_message_t* msg)
362{
363 return _MAV_RETURN_float(msg, 16);
364}
365
366/**
367 * @brief Decode a nav_controller_output message into a struct
368 *
369 * @param msg The message to decode
370 * @param nav_controller_output C-struct to decode the message contents into
371 */
372static inline void mavlink_msg_nav_controller_output_decode(const mavlink_message_t* msg, mavlink_nav_controller_output_t* nav_controller_output)
373{
374#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
375 nav_controller_output->nav_roll = mavlink_msg_nav_controller_output_get_nav_roll(msg);
376 nav_controller_output->nav_pitch = mavlink_msg_nav_controller_output_get_nav_pitch(msg);
377 nav_controller_output->alt_error = mavlink_msg_nav_controller_output_get_alt_error(msg);
378 nav_controller_output->aspd_error = mavlink_msg_nav_controller_output_get_aspd_error(msg);
379 nav_controller_output->xtrack_error = mavlink_msg_nav_controller_output_get_xtrack_error(msg);
380 nav_controller_output->nav_bearing = mavlink_msg_nav_controller_output_get_nav_bearing(msg);
381 nav_controller_output->target_bearing = mavlink_msg_nav_controller_output_get_target_bearing(msg);
382 nav_controller_output->wp_dist = mavlink_msg_nav_controller_output_get_wp_dist(msg);
383#else
384 uint8_t len = msg->len < MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN? msg->len : MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN;
385 memset(nav_controller_output, 0, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
386 memcpy(nav_controller_output, _MAV_PAYLOAD(msg), len);
387#endif
388}