Merged in f5soh/librepilot/LP-607_world_mag_model_2015v2 (pull request #526)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_global_position_int.h
blob24b7e9ec52df7d710f7c464aedfc3330f8e1acfe
1 // MESSAGE GLOBAL_POSITION_INT PACKING
3 #define MAVLINK_MSG_ID_GLOBAL_POSITION_INT 33
5 typedef struct __mavlink_global_position_int_t {
6 uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
7 int32_t lat; ///< Latitude, expressed as * 1E7
8 int32_t lon; ///< Longitude, expressed as * 1E7
9 int32_t alt; ///< Altitude in meters, expressed as * 1000 (millimeters), above MSL
10 int32_t relative_alt; ///< Altitude above ground in meters, expressed as * 1000 (millimeters)
11 int16_t vx; ///< Ground X Speed (Latitude), expressed as m/s * 100
12 int16_t vy; ///< Ground Y Speed (Longitude), expressed as m/s * 100
13 int16_t vz; ///< Ground Z Speed (Altitude), expressed as m/s * 100
14 uint16_t hdg; ///< Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
15 } mavlink_global_position_int_t;
17 #define MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN 28
18 #define MAVLINK_MSG_ID_33_LEN 28
21 #define MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_INT \
22 { \
23 "GLOBAL_POSITION_INT", \
24 9, \
25 { \
26 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_global_position_int_t, time_boot_ms) }, \
27 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_global_position_int_t, lat) }, \
28 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_global_position_int_t, lon) }, \
29 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_global_position_int_t, alt) }, \
30 { "relative_alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_global_position_int_t, relative_alt) }, \
31 { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_global_position_int_t, vx) }, \
32 { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_global_position_int_t, vy) }, \
33 { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_global_position_int_t, vz) }, \
34 { "hdg", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_global_position_int_t, hdg) }, \
35 } \
39 /**
40 * @brief Pack a global_position_int message
41 * @param system_id ID of this system
42 * @param component_id ID of this component (e.g. 200 for IMU)
43 * @param msg The MAVLink message to compress the data into
45 * @param time_boot_ms Timestamp (milliseconds since system boot)
46 * @param lat Latitude, expressed as * 1E7
47 * @param lon Longitude, expressed as * 1E7
48 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
49 * @param relative_alt Altitude above ground in meters, expressed as * 1000 (millimeters)
50 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
51 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
52 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
53 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
54 * @return length of the message in bytes (excluding serial stream start sign)
56 static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
57 uint32_t time_boot_ms, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
59 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 char buf[28];
61 _mav_put_uint32_t(buf, 0, time_boot_ms);
62 _mav_put_int32_t(buf, 4, lat);
63 _mav_put_int32_t(buf, 8, lon);
64 _mav_put_int32_t(buf, 12, alt);
65 _mav_put_int32_t(buf, 16, relative_alt);
66 _mav_put_int16_t(buf, 20, vx);
67 _mav_put_int16_t(buf, 22, vy);
68 _mav_put_int16_t(buf, 24, vz);
69 _mav_put_uint16_t(buf, 26, hdg);
71 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
72 #else
73 mavlink_global_position_int_t packet;
74 packet.time_boot_ms = time_boot_ms;
75 packet.lat = lat;
76 packet.lon = lon;
77 packet.alt = alt;
78 packet.relative_alt = relative_alt;
79 packet.vx = vx;
80 packet.vy = vy;
81 packet.vz = vz;
82 packet.hdg = hdg;
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
85 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT;
88 return mavlink_finalize_message(msg, system_id, component_id, 28, 104);
91 /**
92 * @brief Pack a global_position_int message on a channel
93 * @param system_id ID of this system
94 * @param component_id ID of this component (e.g. 200 for IMU)
95 * @param chan The MAVLink channel this message was sent over
96 * @param msg The MAVLink message to compress the data into
97 * @param time_boot_ms Timestamp (milliseconds since system boot)
98 * @param lat Latitude, expressed as * 1E7
99 * @param lon Longitude, expressed as * 1E7
100 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
101 * @param relative_alt Altitude above ground in meters, expressed as * 1000 (millimeters)
102 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
103 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
104 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
105 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
106 * @return length of the message in bytes (excluding serial stream start sign)
108 static inline uint16_t mavlink_msg_global_position_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
109 mavlink_message_t *msg,
110 uint32_t time_boot_ms, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
112 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 char buf[28];
114 _mav_put_uint32_t(buf, 0, time_boot_ms);
115 _mav_put_int32_t(buf, 4, lat);
116 _mav_put_int32_t(buf, 8, lon);
117 _mav_put_int32_t(buf, 12, alt);
118 _mav_put_int32_t(buf, 16, relative_alt);
119 _mav_put_int16_t(buf, 20, vx);
120 _mav_put_int16_t(buf, 22, vy);
121 _mav_put_int16_t(buf, 24, vz);
122 _mav_put_uint16_t(buf, 26, hdg);
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
125 #else
126 mavlink_global_position_int_t packet;
127 packet.time_boot_ms = time_boot_ms;
128 packet.lat = lat;
129 packet.lon = lon;
130 packet.alt = alt;
131 packet.relative_alt = relative_alt;
132 packet.vx = vx;
133 packet.vy = vy;
134 packet.vz = vz;
135 packet.hdg = hdg;
137 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
138 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
140 msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT;
141 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28, 104);
145 * @brief Encode a global_position_int struct into a message
147 * @param system_id ID of this system
148 * @param component_id ID of this component (e.g. 200 for IMU)
149 * @param msg The MAVLink message to compress the data into
150 * @param global_position_int C-struct to read the message contents from
152 static inline uint16_t mavlink_msg_global_position_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_global_position_int_t *global_position_int)
154 return mavlink_msg_global_position_int_pack(system_id, component_id, msg, global_position_int->time_boot_ms, global_position_int->lat, global_position_int->lon, global_position_int->alt, global_position_int->relative_alt, global_position_int->vx, global_position_int->vy, global_position_int->vz, global_position_int->hdg);
158 * @brief Send a global_position_int message
159 * @param chan MAVLink channel to send the message
161 * @param time_boot_ms Timestamp (milliseconds since system boot)
162 * @param lat Latitude, expressed as * 1E7
163 * @param lon Longitude, expressed as * 1E7
164 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
165 * @param relative_alt Altitude above ground in meters, expressed as * 1000 (millimeters)
166 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
167 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
168 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
169 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
171 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
173 static inline void mavlink_msg_global_position_int_send(mavlink_channel_t chan, uint32_t time_boot_ms, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
175 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
176 char buf[28];
177 _mav_put_uint32_t(buf, 0, time_boot_ms);
178 _mav_put_int32_t(buf, 4, lat);
179 _mav_put_int32_t(buf, 8, lon);
180 _mav_put_int32_t(buf, 12, alt);
181 _mav_put_int32_t(buf, 16, relative_alt);
182 _mav_put_int16_t(buf, 20, vx);
183 _mav_put_int16_t(buf, 22, vy);
184 _mav_put_int16_t(buf, 24, vz);
185 _mav_put_uint16_t(buf, 26, hdg);
187 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GLOBAL_POSITION_INT, buf, 28, 104);
188 #else
189 mavlink_global_position_int_t packet;
190 packet.time_boot_ms = time_boot_ms;
191 packet.lat = lat;
192 packet.lon = lon;
193 packet.alt = alt;
194 packet.relative_alt = relative_alt;
195 packet.vx = vx;
196 packet.vy = vy;
197 packet.vz = vz;
198 packet.hdg = hdg;
200 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GLOBAL_POSITION_INT, (const char *)&packet, 28, 104);
201 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
204 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
206 // MESSAGE GLOBAL_POSITION_INT UNPACKING
210 * @brief Get field time_boot_ms from global_position_int message
212 * @return Timestamp (milliseconds since system boot)
214 static inline uint32_t mavlink_msg_global_position_int_get_time_boot_ms(const mavlink_message_t *msg)
216 return _MAV_RETURN_uint32_t(msg, 0);
220 * @brief Get field lat from global_position_int message
222 * @return Latitude, expressed as * 1E7
224 static inline int32_t mavlink_msg_global_position_int_get_lat(const mavlink_message_t *msg)
226 return _MAV_RETURN_int32_t(msg, 4);
230 * @brief Get field lon from global_position_int message
232 * @return Longitude, expressed as * 1E7
234 static inline int32_t mavlink_msg_global_position_int_get_lon(const mavlink_message_t *msg)
236 return _MAV_RETURN_int32_t(msg, 8);
240 * @brief Get field alt from global_position_int message
242 * @return Altitude in meters, expressed as * 1000 (millimeters), above MSL
244 static inline int32_t mavlink_msg_global_position_int_get_alt(const mavlink_message_t *msg)
246 return _MAV_RETURN_int32_t(msg, 12);
250 * @brief Get field relative_alt from global_position_int message
252 * @return Altitude above ground in meters, expressed as * 1000 (millimeters)
254 static inline int32_t mavlink_msg_global_position_int_get_relative_alt(const mavlink_message_t *msg)
256 return _MAV_RETURN_int32_t(msg, 16);
260 * @brief Get field vx from global_position_int message
262 * @return Ground X Speed (Latitude), expressed as m/s * 100
264 static inline int16_t mavlink_msg_global_position_int_get_vx(const mavlink_message_t *msg)
266 return _MAV_RETURN_int16_t(msg, 20);
270 * @brief Get field vy from global_position_int message
272 * @return Ground Y Speed (Longitude), expressed as m/s * 100
274 static inline int16_t mavlink_msg_global_position_int_get_vy(const mavlink_message_t *msg)
276 return _MAV_RETURN_int16_t(msg, 22);
280 * @brief Get field vz from global_position_int message
282 * @return Ground Z Speed (Altitude), expressed as m/s * 100
284 static inline int16_t mavlink_msg_global_position_int_get_vz(const mavlink_message_t *msg)
286 return _MAV_RETURN_int16_t(msg, 24);
290 * @brief Get field hdg from global_position_int message
292 * @return Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
294 static inline uint16_t mavlink_msg_global_position_int_get_hdg(const mavlink_message_t *msg)
296 return _MAV_RETURN_uint16_t(msg, 26);
300 * @brief Decode a global_position_int message into a struct
302 * @param msg The message to decode
303 * @param global_position_int C-struct to decode the message contents into
305 static inline void mavlink_msg_global_position_int_decode(const mavlink_message_t *msg, mavlink_global_position_int_t *global_position_int)
307 #if MAVLINK_NEED_BYTE_SWAP
308 global_position_int->time_boot_ms = mavlink_msg_global_position_int_get_time_boot_ms(msg);
309 global_position_int->lat = mavlink_msg_global_position_int_get_lat(msg);
310 global_position_int->lon = mavlink_msg_global_position_int_get_lon(msg);
311 global_position_int->alt = mavlink_msg_global_position_int_get_alt(msg);
312 global_position_int->relative_alt = mavlink_msg_global_position_int_get_relative_alt(msg);
313 global_position_int->vx = mavlink_msg_global_position_int_get_vx(msg);
314 global_position_int->vy = mavlink_msg_global_position_int_get_vy(msg);
315 global_position_int->vz = mavlink_msg_global_position_int_get_vz(msg);
316 global_position_int->hdg = mavlink_msg_global_position_int_get_hdg(msg);
317 #else
318 memcpy(global_position_int, _MAV_PAYLOAD(msg), 28);
319 #endif