mavlink_msg_global_position_int.h 9.95 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3
// MESSAGE GLOBAL_POSITION_INT PACKING

#define MAVLINK_MSG_ID_GLOBAL_POSITION_INT 73
LM's avatar
LM committed
4 5
#define MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN 20
#define MAVLINK_MSG_73_LEN 20
lm's avatar
lm committed
6 7
#define MAVLINK_MSG_ID_GLOBAL_POSITION_INT_KEY 0xD4
#define MAVLINK_MSG_73_KEY 0xD4
James Goppert's avatar
James Goppert committed
8 9 10

typedef struct __mavlink_global_position_int_t 
{
lm's avatar
lm committed
11 12 13 14 15 16 17
	int32_t lat;	///< Latitude, expressed as * 1E7
	int32_t lon;	///< Longitude, expressed as * 1E7
	int32_t alt;	///< Altitude in meters, expressed as * 1000 (millimeters), above MSL
	int16_t vx;	///< Ground X Speed (Latitude), expressed as m/s * 100
	int16_t vy;	///< Ground Y Speed (Longitude), expressed as m/s * 100
	int16_t vz;	///< Ground Z Speed (Altitude), expressed as m/s * 100
	uint16_t hdg;	///< Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
18 19 20 21 22 23 24 25 26 27 28

} mavlink_global_position_int_t;

/**
 * @brief Pack a global_position_int message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param lat Latitude, expressed as * 1E7
 * @param lon Longitude, expressed as * 1E7
LM's avatar
LM committed
29
 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
James Goppert's avatar
James Goppert committed
30 31 32
 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
LM's avatar
LM committed
33
 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
34 35
 * @return length of the message in bytes (excluding serial stream start sign)
 */
LM's avatar
LM committed
36
static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
James Goppert's avatar
James Goppert committed
37
{
lm's avatar
lm committed
38
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
39 40
	msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT;

lm's avatar
lm committed
41 42 43 44 45 46 47
	p->lat = lat;	// int32_t:Latitude, expressed as * 1E7
	p->lon = lon;	// int32_t:Longitude, expressed as * 1E7
	p->alt = alt;	// int32_t:Altitude in meters, expressed as * 1000 (millimeters), above MSL
	p->vx = vx;	// int16_t:Ground X Speed (Latitude), expressed as m/s * 100
	p->vy = vy;	// int16_t:Ground Y Speed (Longitude), expressed as m/s * 100
	p->vz = vz;	// int16_t:Ground Z Speed (Altitude), expressed as m/s * 100
	p->hdg = hdg;	// uint16_t:Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
48

lm's avatar
lm committed
49
	return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN);
James Goppert's avatar
James Goppert committed
50 51 52 53 54 55 56 57 58 59
}

/**
 * @brief Pack a global_position_int message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param lat Latitude, expressed as * 1E7
 * @param lon Longitude, expressed as * 1E7
LM's avatar
LM committed
60
 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
James Goppert's avatar
James Goppert committed
61 62 63
 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
LM's avatar
LM committed
64
 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
65 66
 * @return length of the message in bytes (excluding serial stream start sign)
 */
LM's avatar
LM committed
67
static inline uint16_t mavlink_msg_global_position_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
James Goppert's avatar
James Goppert committed
68
{
lm's avatar
lm committed
69
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
70 71
	msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT;

lm's avatar
lm committed
72 73 74 75 76 77 78
	p->lat = lat;	// int32_t:Latitude, expressed as * 1E7
	p->lon = lon;	// int32_t:Longitude, expressed as * 1E7
	p->alt = alt;	// int32_t:Altitude in meters, expressed as * 1000 (millimeters), above MSL
	p->vx = vx;	// int16_t:Ground X Speed (Latitude), expressed as m/s * 100
	p->vy = vy;	// int16_t:Ground Y Speed (Longitude), expressed as m/s * 100
	p->vz = vz;	// int16_t:Ground Z Speed (Altitude), expressed as m/s * 100
	p->hdg = hdg;	// uint16_t:Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
79

lm's avatar
lm committed
80
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN);
James Goppert's avatar
James Goppert committed
81 82 83 84 85 86 87 88 89 90 91 92
}

/**
 * @brief Encode a global_position_int struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param global_position_int C-struct to read the message contents from
 */
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)
{
LM's avatar
LM committed
93
	return mavlink_msg_global_position_int_pack(system_id, component_id, msg, global_position_int->lat, global_position_int->lon, global_position_int->alt, global_position_int->vx, global_position_int->vy, global_position_int->vz, global_position_int->hdg);
James Goppert's avatar
James Goppert committed
94 95
}

lm's avatar
lm committed
96 97

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
James Goppert's avatar
James Goppert committed
98 99 100 101 102 103
/**
 * @brief Send a global_position_int message
 * @param chan MAVLink channel to send the message
 *
 * @param lat Latitude, expressed as * 1E7
 * @param lon Longitude, expressed as * 1E7
LM's avatar
LM committed
104
 * @param alt Altitude in meters, expressed as * 1000 (millimeters), above MSL
James Goppert's avatar
James Goppert committed
105 106 107
 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
LM's avatar
LM committed
108
 * @param hdg Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
James Goppert's avatar
James Goppert committed
109
 */
LM's avatar
LM committed
110
static inline void mavlink_msg_global_position_int_send(mavlink_channel_t chan, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg)
lm's avatar
lm committed
111 112 113 114
{
	mavlink_header_t hdr;
	mavlink_global_position_int_t payload;

lm's avatar
lm committed
115 116 117 118 119 120 121 122
	MAVLINK_BUFFER_CHECK_START( chan, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN )
	payload.lat = lat;	// int32_t:Latitude, expressed as * 1E7
	payload.lon = lon;	// int32_t:Longitude, expressed as * 1E7
	payload.alt = alt;	// int32_t:Altitude in meters, expressed as * 1000 (millimeters), above MSL
	payload.vx = vx;	// int16_t:Ground X Speed (Latitude), expressed as m/s * 100
	payload.vy = vy;	// int16_t:Ground Y Speed (Longitude), expressed as m/s * 100
	payload.vz = vz;	// int16_t:Ground Z Speed (Altitude), expressed as m/s * 100
	payload.hdg = hdg;	// uint16_t:Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
lm's avatar
lm committed
123 124 125 126 127 128 129 130 131 132

	hdr.STX = MAVLINK_STX;
	hdr.len = MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN;
	hdr.msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT;
	hdr.sysid = mavlink_system.sysid;
	hdr.compid = mavlink_system.compid;
	hdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;
	mavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;
	mavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );

lm's avatar
lm committed
133 134 135 136 137 138
	crc_init(&hdr.ck);
	crc_calculate_mem((uint8_t *)&hdr.len, &hdr.ck, MAVLINK_CORE_HEADER_LEN);
	crc_calculate_mem((uint8_t *)&payload, &hdr.ck, hdr.len );
	crc_accumulate( 0xD4, &hdr.ck); /// include key in X25 checksum
	mavlink_send_mem(chan, (uint8_t *)&hdr.ck, MAVLINK_NUM_CHECKSUM_BYTES);
	MAVLINK_BUFFER_CHECK_END
James Goppert's avatar
James Goppert committed
139 140 141 142 143 144 145 146 147 148 149 150
}

#endif
// MESSAGE GLOBAL_POSITION_INT UNPACKING

/**
 * @brief Get field lat from global_position_int message
 *
 * @return Latitude, expressed as * 1E7
 */
static inline int32_t mavlink_msg_global_position_int_get_lat(const mavlink_message_t* msg)
{
lm's avatar
lm committed
151 152
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int32_t)(p->lat);
James Goppert's avatar
James Goppert committed
153 154 155 156 157 158 159 160 161
}

/**
 * @brief Get field lon from global_position_int message
 *
 * @return Longitude, expressed as * 1E7
 */
static inline int32_t mavlink_msg_global_position_int_get_lon(const mavlink_message_t* msg)
{
lm's avatar
lm committed
162 163
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int32_t)(p->lon);
James Goppert's avatar
James Goppert committed
164 165 166 167 168
}

/**
 * @brief Get field alt from global_position_int message
 *
LM's avatar
LM committed
169
 * @return Altitude in meters, expressed as * 1000 (millimeters), above MSL
James Goppert's avatar
James Goppert committed
170 171 172
 */
static inline int32_t mavlink_msg_global_position_int_get_alt(const mavlink_message_t* msg)
{
lm's avatar
lm committed
173 174
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int32_t)(p->alt);
James Goppert's avatar
James Goppert committed
175 176 177 178 179 180 181 182 183
}

/**
 * @brief Get field vx from global_position_int message
 *
 * @return Ground X Speed (Latitude), expressed as m/s * 100
 */
static inline int16_t mavlink_msg_global_position_int_get_vx(const mavlink_message_t* msg)
{
lm's avatar
lm committed
184 185
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int16_t)(p->vx);
James Goppert's avatar
James Goppert committed
186 187 188 189 190 191 192 193 194
}

/**
 * @brief Get field vy from global_position_int message
 *
 * @return Ground Y Speed (Longitude), expressed as m/s * 100
 */
static inline int16_t mavlink_msg_global_position_int_get_vy(const mavlink_message_t* msg)
{
lm's avatar
lm committed
195 196
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int16_t)(p->vy);
James Goppert's avatar
James Goppert committed
197 198 199 200 201 202 203 204 205
}

/**
 * @brief Get field vz from global_position_int message
 *
 * @return Ground Z Speed (Altitude), expressed as m/s * 100
 */
static inline int16_t mavlink_msg_global_position_int_get_vz(const mavlink_message_t* msg)
{
lm's avatar
lm committed
206 207
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (int16_t)(p->vz);
James Goppert's avatar
James Goppert committed
208 209
}

LM's avatar
LM committed
210 211 212 213 214 215 216 217 218 219 220
/**
 * @brief Get field hdg from global_position_int message
 *
 * @return Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
 */
static inline uint16_t mavlink_msg_global_position_int_get_hdg(const mavlink_message_t* msg)
{
	mavlink_global_position_int_t *p = (mavlink_global_position_int_t *)&msg->payload[0];
	return (uint16_t)(p->hdg);
}

James Goppert's avatar
James Goppert committed
221 222 223 224 225 226 227 228
/**
 * @brief Decode a global_position_int message into a struct
 *
 * @param msg The message to decode
 * @param global_position_int C-struct to decode the message contents into
 */
static inline void mavlink_msg_global_position_int_decode(const mavlink_message_t* msg, mavlink_global_position_int_t* global_position_int)
{
lm's avatar
lm committed
229
	memcpy( global_position_int, msg->payload, sizeof(mavlink_global_position_int_t));
James Goppert's avatar
James Goppert committed
230
}