before merging master
[inav.git] / lib / main / MAVLink / common / mavlink_msg_nav_controller_output.h
blob2d9e8c0c5c230fab26003015b4a5544b470b5390
1 #pragma once
2 // MESSAGE NAV_CONTROLLER_OUTPUT PACKING
4 #define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT 62
7 typedef struct __mavlink_nav_controller_output_t {
8 float nav_roll; /*< [deg] Current desired roll*/
9 float nav_pitch; /*< [deg] Current desired pitch*/
10 float alt_error; /*< [m] Current altitude error*/
11 float aspd_error; /*< [m/s] Current airspeed error*/
12 float xtrack_error; /*< [m] Current crosstrack error on x-y plane*/
13 int16_t nav_bearing; /*< [deg] Current desired heading*/
14 int16_t target_bearing; /*< [deg] Bearing to current waypoint/target*/
15 uint16_t wp_dist; /*< [m] Distance to active waypoint*/
16 } mavlink_nav_controller_output_t;
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
23 #define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC 183
24 #define MAVLINK_MSG_ID_62_CRC 183
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 } \
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 } \
57 #endif
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
65 * @param nav_roll [deg] Current desired roll
66 * @param nav_pitch [deg] Current desired pitch
67 * @param nav_bearing [deg] Current desired heading
68 * @param target_bearing [deg] Bearing to current waypoint/target
69 * @param wp_dist [m] Distance to active waypoint
70 * @param alt_error [m] Current altitude error
71 * @param aspd_error [m/s] Current airspeed error
72 * @param xtrack_error [m] Current crosstrack error on x-y plane
73 * @return length of the message in bytes (excluding serial stream start sign)
75 static 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)
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);
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;
101 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
102 #endif
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);
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 [deg] Current desired roll
115 * @param nav_pitch [deg] Current desired pitch
116 * @param nav_bearing [deg] Current desired heading
117 * @param target_bearing [deg] Bearing to current waypoint/target
118 * @param wp_dist [m] Distance to active waypoint
119 * @param alt_error [m] Current altitude error
120 * @param aspd_error [m/s] Current airspeed error
121 * @param xtrack_error [m] Current crosstrack error on x-y plane
122 * @return length of the message in bytes (excluding serial stream start sign)
124 static 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)
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);
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;
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN);
152 #endif
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);
159 * @brief Encode a nav_controller_output struct
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
166 static 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)
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);
172 * @brief Encode a nav_controller_output struct on a channel
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
180 static 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)
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);
186 * @brief Send a nav_controller_output message
187 * @param chan MAVLink channel to send the message
189 * @param nav_roll [deg] Current desired roll
190 * @param nav_pitch [deg] Current desired pitch
191 * @param nav_bearing [deg] Current desired heading
192 * @param target_bearing [deg] Bearing to current waypoint/target
193 * @param wp_dist [m] Distance to active waypoint
194 * @param alt_error [m] Current altitude error
195 * @param aspd_error [m/s] Current airspeed error
196 * @param xtrack_error [m] Current crosstrack error on x-y plane
198 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
200 static 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)
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);
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;
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
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
234 static inline void mavlink_msg_nav_controller_output_send_struct(mavlink_channel_t chan, const mavlink_nav_controller_output_t* nav_controller_output)
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
243 #if MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
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.
251 static 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)
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);
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;
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
279 #endif
281 #endif
283 // MESSAGE NAV_CONTROLLER_OUTPUT UNPACKING
287 * @brief Get field nav_roll from nav_controller_output message
289 * @return [deg] Current desired roll
291 static inline float mavlink_msg_nav_controller_output_get_nav_roll(const mavlink_message_t* msg)
293 return _MAV_RETURN_float(msg, 0);
297 * @brief Get field nav_pitch from nav_controller_output message
299 * @return [deg] Current desired pitch
301 static inline float mavlink_msg_nav_controller_output_get_nav_pitch(const mavlink_message_t* msg)
303 return _MAV_RETURN_float(msg, 4);
307 * @brief Get field nav_bearing from nav_controller_output message
309 * @return [deg] Current desired heading
311 static inline int16_t mavlink_msg_nav_controller_output_get_nav_bearing(const mavlink_message_t* msg)
313 return _MAV_RETURN_int16_t(msg, 20);
317 * @brief Get field target_bearing from nav_controller_output message
319 * @return [deg] Bearing to current waypoint/target
321 static inline int16_t mavlink_msg_nav_controller_output_get_target_bearing(const mavlink_message_t* msg)
323 return _MAV_RETURN_int16_t(msg, 22);
327 * @brief Get field wp_dist from nav_controller_output message
329 * @return [m] Distance to active waypoint
331 static inline uint16_t mavlink_msg_nav_controller_output_get_wp_dist(const mavlink_message_t* msg)
333 return _MAV_RETURN_uint16_t(msg, 24);
337 * @brief Get field alt_error from nav_controller_output message
339 * @return [m] Current altitude error
341 static inline float mavlink_msg_nav_controller_output_get_alt_error(const mavlink_message_t* msg)
343 return _MAV_RETURN_float(msg, 8);
347 * @brief Get field aspd_error from nav_controller_output message
349 * @return [m/s] Current airspeed error
351 static inline float mavlink_msg_nav_controller_output_get_aspd_error(const mavlink_message_t* msg)
353 return _MAV_RETURN_float(msg, 12);
357 * @brief Get field xtrack_error from nav_controller_output message
359 * @return [m] Current crosstrack error on x-y plane
361 static inline float mavlink_msg_nav_controller_output_get_xtrack_error(const mavlink_message_t* msg)
363 return _MAV_RETURN_float(msg, 16);
367 * @brief Decode a nav_controller_output message into a struct
369 * @param msg The message to decode
370 * @param nav_controller_output C-struct to decode the message contents into
372 static inline void mavlink_msg_nav_controller_output_decode(const mavlink_message_t* msg, mavlink_nav_controller_output_t* nav_controller_output)
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