Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_local_position_ned.h
blob2f4224d08b3eab729f28d20ad09b9701a0c62ab0
1 // MESSAGE LOCAL_POSITION_NED PACKING
3 #define MAVLINK_MSG_ID_LOCAL_POSITION_NED 32
5 typedef struct __mavlink_local_position_ned_t {
6 uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
7 float x; ///< X Position
8 float y; ///< Y Position
9 float z; ///< Z Position
10 float vx; ///< X Speed
11 float vy; ///< Y Speed
12 float vz; ///< Z Speed
13 } mavlink_local_position_ned_t;
15 #define MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN 28
16 #define MAVLINK_MSG_ID_32_LEN 28
19 #define MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED \
20 { \
21 "LOCAL_POSITION_NED", \
22 7, \
23 { \
24 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_local_position_ned_t, time_boot_ms) }, \
25 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_local_position_ned_t, x) }, \
26 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_local_position_ned_t, y) }, \
27 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_local_position_ned_t, z) }, \
28 { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_local_position_ned_t, vx) }, \
29 { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_local_position_ned_t, vy) }, \
30 { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_local_position_ned_t, vz) }, \
31 } \
35 /**
36 * @brief Pack a local_position_ned message
37 * @param system_id ID of this system
38 * @param component_id ID of this component (e.g. 200 for IMU)
39 * @param msg The MAVLink message to compress the data into
41 * @param time_boot_ms Timestamp (milliseconds since system boot)
42 * @param x X Position
43 * @param y Y Position
44 * @param z Z Position
45 * @param vx X Speed
46 * @param vy Y Speed
47 * @param vz Z Speed
48 * @return length of the message in bytes (excluding serial stream start sign)
50 static inline uint16_t mavlink_msg_local_position_ned_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
51 uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
54 char buf[28];
55 _mav_put_uint32_t(buf, 0, time_boot_ms);
56 _mav_put_float(buf, 4, x);
57 _mav_put_float(buf, 8, y);
58 _mav_put_float(buf, 12, z);
59 _mav_put_float(buf, 16, vx);
60 _mav_put_float(buf, 20, vy);
61 _mav_put_float(buf, 24, vz);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
64 #else
65 mavlink_local_position_ned_t packet;
66 packet.time_boot_ms = time_boot_ms;
67 packet.x = x;
68 packet.y = y;
69 packet.z = z;
70 packet.vx = vx;
71 packet.vy = vy;
72 packet.vz = vz;
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
75 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
77 msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED;
78 return mavlink_finalize_message(msg, system_id, component_id, 28, 185);
81 /**
82 * @brief Pack a local_position_ned message on a channel
83 * @param system_id ID of this system
84 * @param component_id ID of this component (e.g. 200 for IMU)
85 * @param chan The MAVLink channel this message was sent over
86 * @param msg The MAVLink message to compress the data into
87 * @param time_boot_ms Timestamp (milliseconds since system boot)
88 * @param x X Position
89 * @param y Y Position
90 * @param z Z Position
91 * @param vx X Speed
92 * @param vy Y Speed
93 * @param vz Z Speed
94 * @return length of the message in bytes (excluding serial stream start sign)
96 static inline uint16_t mavlink_msg_local_position_ned_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
97 mavlink_message_t *msg,
98 uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
100 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
101 char buf[28];
102 _mav_put_uint32_t(buf, 0, time_boot_ms);
103 _mav_put_float(buf, 4, x);
104 _mav_put_float(buf, 8, y);
105 _mav_put_float(buf, 12, z);
106 _mav_put_float(buf, 16, vx);
107 _mav_put_float(buf, 20, vy);
108 _mav_put_float(buf, 24, vz);
110 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
111 #else
112 mavlink_local_position_ned_t packet;
113 packet.time_boot_ms = time_boot_ms;
114 packet.x = x;
115 packet.y = y;
116 packet.z = z;
117 packet.vx = vx;
118 packet.vy = vy;
119 packet.vz = vz;
121 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
122 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
124 msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED;
125 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28, 185);
129 * @brief Encode a local_position_ned struct into a message
131 * @param system_id ID of this system
132 * @param component_id ID of this component (e.g. 200 for IMU)
133 * @param msg The MAVLink message to compress the data into
134 * @param local_position_ned C-struct to read the message contents from
136 static inline uint16_t mavlink_msg_local_position_ned_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_local_position_ned_t *local_position_ned)
138 return mavlink_msg_local_position_ned_pack(system_id, component_id, msg, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz);
142 * @brief Send a local_position_ned message
143 * @param chan MAVLink channel to send the message
145 * @param time_boot_ms Timestamp (milliseconds since system boot)
146 * @param x X Position
147 * @param y Y Position
148 * @param z Z Position
149 * @param vx X Speed
150 * @param vy Y Speed
151 * @param vz Z Speed
153 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
155 static inline void mavlink_msg_local_position_ned_send(mavlink_channel_t chan, uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
157 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
158 char buf[28];
159 _mav_put_uint32_t(buf, 0, time_boot_ms);
160 _mav_put_float(buf, 4, x);
161 _mav_put_float(buf, 8, y);
162 _mav_put_float(buf, 12, z);
163 _mav_put_float(buf, 16, vx);
164 _mav_put_float(buf, 20, vy);
165 _mav_put_float(buf, 24, vz);
167 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, buf, 28, 185);
168 #else
169 mavlink_local_position_ned_t packet;
170 packet.time_boot_ms = time_boot_ms;
171 packet.x = x;
172 packet.y = y;
173 packet.z = z;
174 packet.vx = vx;
175 packet.vy = vy;
176 packet.vz = vz;
178 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, (const char *)&packet, 28, 185);
179 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
184 // MESSAGE LOCAL_POSITION_NED UNPACKING
188 * @brief Get field time_boot_ms from local_position_ned message
190 * @return Timestamp (milliseconds since system boot)
192 static inline uint32_t mavlink_msg_local_position_ned_get_time_boot_ms(const mavlink_message_t *msg)
194 return _MAV_RETURN_uint32_t(msg, 0);
198 * @brief Get field x from local_position_ned message
200 * @return X Position
202 static inline float mavlink_msg_local_position_ned_get_x(const mavlink_message_t *msg)
204 return _MAV_RETURN_float(msg, 4);
208 * @brief Get field y from local_position_ned message
210 * @return Y Position
212 static inline float mavlink_msg_local_position_ned_get_y(const mavlink_message_t *msg)
214 return _MAV_RETURN_float(msg, 8);
218 * @brief Get field z from local_position_ned message
220 * @return Z Position
222 static inline float mavlink_msg_local_position_ned_get_z(const mavlink_message_t *msg)
224 return _MAV_RETURN_float(msg, 12);
228 * @brief Get field vx from local_position_ned message
230 * @return X Speed
232 static inline float mavlink_msg_local_position_ned_get_vx(const mavlink_message_t *msg)
234 return _MAV_RETURN_float(msg, 16);
238 * @brief Get field vy from local_position_ned message
240 * @return Y Speed
242 static inline float mavlink_msg_local_position_ned_get_vy(const mavlink_message_t *msg)
244 return _MAV_RETURN_float(msg, 20);
248 * @brief Get field vz from local_position_ned message
250 * @return Z Speed
252 static inline float mavlink_msg_local_position_ned_get_vz(const mavlink_message_t *msg)
254 return _MAV_RETURN_float(msg, 24);
258 * @brief Decode a local_position_ned message into a struct
260 * @param msg The message to decode
261 * @param local_position_ned C-struct to decode the message contents into
263 static inline void mavlink_msg_local_position_ned_decode(const mavlink_message_t *msg, mavlink_local_position_ned_t *local_position_ned)
265 #if MAVLINK_NEED_BYTE_SWAP
266 local_position_ned->time_boot_ms = mavlink_msg_local_position_ned_get_time_boot_ms(msg);
267 local_position_ned->x = mavlink_msg_local_position_ned_get_x(msg);
268 local_position_ned->y = mavlink_msg_local_position_ned_get_y(msg);
269 local_position_ned->z = mavlink_msg_local_position_ned_get_z(msg);
270 local_position_ned->vx = mavlink_msg_local_position_ned_get_vx(msg);
271 local_position_ned->vy = mavlink_msg_local_position_ned_get_vy(msg);
272 local_position_ned->vz = mavlink_msg_local_position_ned_get_vz(msg);
273 #else
274 memcpy(local_position_ned, _MAV_PAYLOAD(msg), 28);
275 #endif