Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_nav_controller_output.h
blob25fcce698a16fb2aa59d52fdc48e4dad4f5fdb34
1 // MESSAGE NAV_CONTROLLER_OUTPUT PACKING
3 #define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT 62
5 typedef struct __mavlink_nav_controller_output_t {
6 float nav_roll; ///< Current desired roll in degrees
7 float nav_pitch; ///< Current desired pitch in degrees
8 float alt_error; ///< Current altitude error in meters
9 float aspd_error; ///< Current airspeed error in meters/second
10 float xtrack_error; ///< Current crosstrack error on x-y plane in meters
11 int16_t nav_bearing; ///< Current desired heading in degrees
12 int16_t target_bearing; ///< Bearing to current MISSION/target in degrees
13 uint16_t wp_dist; ///< Distance to active MISSION in meters
14 } mavlink_nav_controller_output_t;
16 #define MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN 26
17 #define MAVLINK_MSG_ID_62_LEN 26
20 #define MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT \
21 { \
22 "NAV_CONTROLLER_OUTPUT", \
23 8, \
24 { \
25 { "nav_roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_nav_controller_output_t, nav_roll) }, \
26 { "nav_pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_nav_controller_output_t, nav_pitch) }, \
27 { "alt_error", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_nav_controller_output_t, alt_error) }, \
28 { "aspd_error", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_nav_controller_output_t, aspd_error) }, \
29 { "xtrack_error", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_nav_controller_output_t, xtrack_error) }, \
30 { "nav_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_nav_controller_output_t, nav_bearing) }, \
31 { "target_bearing", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_nav_controller_output_t, target_bearing) }, \
32 { "wp_dist", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_nav_controller_output_t, wp_dist) }, \
33 } \
37 /**
38 * @brief Pack a nav_controller_output message
39 * @param system_id ID of this system
40 * @param component_id ID of this component (e.g. 200 for IMU)
41 * @param msg The MAVLink message to compress the data into
43 * @param nav_roll Current desired roll in degrees
44 * @param nav_pitch Current desired pitch in degrees
45 * @param nav_bearing Current desired heading in degrees
46 * @param target_bearing Bearing to current MISSION/target in degrees
47 * @param wp_dist Distance to active MISSION in meters
48 * @param alt_error Current altitude error in meters
49 * @param aspd_error Current airspeed error in meters/second
50 * @param xtrack_error Current crosstrack error on x-y plane in meters
51 * @return length of the message in bytes (excluding serial stream start sign)
53 static inline uint16_t mavlink_msg_nav_controller_output_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
54 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)
56 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
57 char buf[26];
58 _mav_put_float(buf, 0, nav_roll);
59 _mav_put_float(buf, 4, nav_pitch);
60 _mav_put_float(buf, 8, alt_error);
61 _mav_put_float(buf, 12, aspd_error);
62 _mav_put_float(buf, 16, xtrack_error);
63 _mav_put_int16_t(buf, 20, nav_bearing);
64 _mav_put_int16_t(buf, 22, target_bearing);
65 _mav_put_uint16_t(buf, 24, wp_dist);
67 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26);
68 #else
69 mavlink_nav_controller_output_t packet;
70 packet.nav_roll = nav_roll;
71 packet.nav_pitch = nav_pitch;
72 packet.alt_error = alt_error;
73 packet.aspd_error = aspd_error;
74 packet.xtrack_error = xtrack_error;
75 packet.nav_bearing = nav_bearing;
76 packet.target_bearing = target_bearing;
77 packet.wp_dist = wp_dist;
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26);
80 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
82 msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT;
83 return mavlink_finalize_message(msg, system_id, component_id, 26, 183);
86 /**
87 * @brief Pack a nav_controller_output message on a channel
88 * @param system_id ID of this system
89 * @param component_id ID of this component (e.g. 200 for IMU)
90 * @param chan The MAVLink channel this message was sent over
91 * @param msg The MAVLink message to compress the data into
92 * @param nav_roll Current desired roll in degrees
93 * @param nav_pitch Current desired pitch in degrees
94 * @param nav_bearing Current desired heading in degrees
95 * @param target_bearing Bearing to current MISSION/target in degrees
96 * @param wp_dist Distance to active MISSION in meters
97 * @param alt_error Current altitude error in meters
98 * @param aspd_error Current airspeed error in meters/second
99 * @param xtrack_error Current crosstrack error on x-y plane in meters
100 * @return length of the message in bytes (excluding serial stream start sign)
102 static inline uint16_t mavlink_msg_nav_controller_output_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
103 mavlink_message_t *msg,
104 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)
106 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
107 char buf[26];
108 _mav_put_float(buf, 0, nav_roll);
109 _mav_put_float(buf, 4, nav_pitch);
110 _mav_put_float(buf, 8, alt_error);
111 _mav_put_float(buf, 12, aspd_error);
112 _mav_put_float(buf, 16, xtrack_error);
113 _mav_put_int16_t(buf, 20, nav_bearing);
114 _mav_put_int16_t(buf, 22, target_bearing);
115 _mav_put_uint16_t(buf, 24, wp_dist);
117 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26);
118 #else
119 mavlink_nav_controller_output_t packet;
120 packet.nav_roll = nav_roll;
121 packet.nav_pitch = nav_pitch;
122 packet.alt_error = alt_error;
123 packet.aspd_error = aspd_error;
124 packet.xtrack_error = xtrack_error;
125 packet.nav_bearing = nav_bearing;
126 packet.target_bearing = target_bearing;
127 packet.wp_dist = wp_dist;
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26);
130 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
132 msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT;
133 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 26, 183);
137 * @brief Encode a nav_controller_output struct into a message
139 * @param system_id ID of this system
140 * @param component_id ID of this component (e.g. 200 for IMU)
141 * @param msg The MAVLink message to compress the data into
142 * @param nav_controller_output C-struct to read the message contents from
144 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)
146 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);
150 * @brief Send a nav_controller_output message
151 * @param chan MAVLink channel to send the message
153 * @param nav_roll Current desired roll in degrees
154 * @param nav_pitch Current desired pitch in degrees
155 * @param nav_bearing Current desired heading in degrees
156 * @param target_bearing Bearing to current MISSION/target in degrees
157 * @param wp_dist Distance to active MISSION in meters
158 * @param alt_error Current altitude error in meters
159 * @param aspd_error Current airspeed error in meters/second
160 * @param xtrack_error Current crosstrack error on x-y plane in meters
162 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
164 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)
166 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
167 char buf[26];
168 _mav_put_float(buf, 0, nav_roll);
169 _mav_put_float(buf, 4, nav_pitch);
170 _mav_put_float(buf, 8, alt_error);
171 _mav_put_float(buf, 12, aspd_error);
172 _mav_put_float(buf, 16, xtrack_error);
173 _mav_put_int16_t(buf, 20, nav_bearing);
174 _mav_put_int16_t(buf, 22, target_bearing);
175 _mav_put_uint16_t(buf, 24, wp_dist);
177 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, buf, 26, 183);
178 #else
179 mavlink_nav_controller_output_t packet;
180 packet.nav_roll = nav_roll;
181 packet.nav_pitch = nav_pitch;
182 packet.alt_error = alt_error;
183 packet.aspd_error = aspd_error;
184 packet.xtrack_error = xtrack_error;
185 packet.nav_bearing = nav_bearing;
186 packet.target_bearing = target_bearing;
187 packet.wp_dist = wp_dist;
189 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT, (const char *)&packet, 26, 183);
190 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
195 // MESSAGE NAV_CONTROLLER_OUTPUT UNPACKING
199 * @brief Get field nav_roll from nav_controller_output message
201 * @return Current desired roll in degrees
203 static inline float mavlink_msg_nav_controller_output_get_nav_roll(const mavlink_message_t *msg)
205 return _MAV_RETURN_float(msg, 0);
209 * @brief Get field nav_pitch from nav_controller_output message
211 * @return Current desired pitch in degrees
213 static inline float mavlink_msg_nav_controller_output_get_nav_pitch(const mavlink_message_t *msg)
215 return _MAV_RETURN_float(msg, 4);
219 * @brief Get field nav_bearing from nav_controller_output message
221 * @return Current desired heading in degrees
223 static inline int16_t mavlink_msg_nav_controller_output_get_nav_bearing(const mavlink_message_t *msg)
225 return _MAV_RETURN_int16_t(msg, 20);
229 * @brief Get field target_bearing from nav_controller_output message
231 * @return Bearing to current MISSION/target in degrees
233 static inline int16_t mavlink_msg_nav_controller_output_get_target_bearing(const mavlink_message_t *msg)
235 return _MAV_RETURN_int16_t(msg, 22);
239 * @brief Get field wp_dist from nav_controller_output message
241 * @return Distance to active MISSION in meters
243 static inline uint16_t mavlink_msg_nav_controller_output_get_wp_dist(const mavlink_message_t *msg)
245 return _MAV_RETURN_uint16_t(msg, 24);
249 * @brief Get field alt_error from nav_controller_output message
251 * @return Current altitude error in meters
253 static inline float mavlink_msg_nav_controller_output_get_alt_error(const mavlink_message_t *msg)
255 return _MAV_RETURN_float(msg, 8);
259 * @brief Get field aspd_error from nav_controller_output message
261 * @return Current airspeed error in meters/second
263 static inline float mavlink_msg_nav_controller_output_get_aspd_error(const mavlink_message_t *msg)
265 return _MAV_RETURN_float(msg, 12);
269 * @brief Get field xtrack_error from nav_controller_output message
271 * @return Current crosstrack error on x-y plane in meters
273 static inline float mavlink_msg_nav_controller_output_get_xtrack_error(const mavlink_message_t *msg)
275 return _MAV_RETURN_float(msg, 16);
279 * @brief Decode a nav_controller_output message into a struct
281 * @param msg The message to decode
282 * @param nav_controller_output C-struct to decode the message contents into
284 static inline void mavlink_msg_nav_controller_output_decode(const mavlink_message_t *msg, mavlink_nav_controller_output_t *nav_controller_output)
286 #if MAVLINK_NEED_BYTE_SWAP
287 nav_controller_output->nav_roll = mavlink_msg_nav_controller_output_get_nav_roll(msg);
288 nav_controller_output->nav_pitch = mavlink_msg_nav_controller_output_get_nav_pitch(msg);
289 nav_controller_output->alt_error = mavlink_msg_nav_controller_output_get_alt_error(msg);
290 nav_controller_output->aspd_error = mavlink_msg_nav_controller_output_get_aspd_error(msg);
291 nav_controller_output->xtrack_error = mavlink_msg_nav_controller_output_get_xtrack_error(msg);
292 nav_controller_output->nav_bearing = mavlink_msg_nav_controller_output_get_nav_bearing(msg);
293 nav_controller_output->target_bearing = mavlink_msg_nav_controller_output_get_target_bearing(msg);
294 nav_controller_output->wp_dist = mavlink_msg_nav_controller_output_get_wp_dist(msg);
295 #else
296 memcpy(nav_controller_output, _MAV_PAYLOAD(msg), 26);
297 #endif