mavlink_msg_state_correction.h 10.2 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3 4
// MESSAGE STATE_CORRECTION PACKING

#define MAVLINK_MSG_ID_STATE_CORRECTION 64

lm's avatar
lm committed
5
typedef struct __mavlink_state_correction_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7 8 9 10 11 12 13 14 15
 float xErr; ///< x position error
 float yErr; ///< y position error
 float zErr; ///< z position error
 float rollErr; ///< roll error (radians)
 float pitchErr; ///< pitch error (radians)
 float yawErr; ///< yaw error (radians)
 float vxErr; ///< x velocity
 float vyErr; ///< y velocity
 float vzErr; ///< z velocity
James Goppert's avatar
James Goppert committed
16 17
} mavlink_state_correction_t;

lm's avatar
lm committed
18 19 20 21 22 23 24 25
#define MAVLINK_MSG_ID_STATE_CORRECTION_LEN 36
#define MAVLINK_MSG_ID_64_LEN 36



#define MAVLINK_MESSAGE_INFO_STATE_CORRECTION { \
	"STATE_CORRECTION", \
	9, \
lm's avatar
lm committed
26 27 28 29 30 31 32 33 34
	{  { "xErr", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_state_correction_t, xErr) }, \
         { "yErr", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_state_correction_t, yErr) }, \
         { "zErr", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_state_correction_t, zErr) }, \
         { "rollErr", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_state_correction_t, rollErr) }, \
         { "pitchErr", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_state_correction_t, pitchErr) }, \
         { "yawErr", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_state_correction_t, yawErr) }, \
         { "vxErr", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_state_correction_t, vxErr) }, \
         { "vyErr", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_state_correction_t, vyErr) }, \
         { "vzErr", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_state_correction_t, vzErr) }, \
lm's avatar
lm committed
35 36 37 38
         } \
}


James Goppert's avatar
James Goppert committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/**
 * @brief Pack a state_correction 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 xErr x position error
 * @param yErr y position error
 * @param zErr z position error
 * @param rollErr roll error (radians)
 * @param pitchErr pitch error (radians)
 * @param yawErr yaw error (radians)
 * @param vxErr x velocity
 * @param vyErr y velocity
 * @param vzErr z velocity
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
56 57
static inline uint16_t mavlink_msg_state_correction_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       float xErr, float yErr, float zErr, float rollErr, float pitchErr, float yawErr, float vxErr, float vyErr, float vzErr)
James Goppert's avatar
James Goppert committed
58
{
LM's avatar
LM committed
59 60 61 62 63 64 65 66 67 68 69 70
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[36];
	_mav_put_float(buf, 0, xErr);
	_mav_put_float(buf, 4, yErr);
	_mav_put_float(buf, 8, zErr);
	_mav_put_float(buf, 12, rollErr);
	_mav_put_float(buf, 16, pitchErr);
	_mav_put_float(buf, 20, yawErr);
	_mav_put_float(buf, 24, vxErr);
	_mav_put_float(buf, 28, vyErr);
	_mav_put_float(buf, 32, vzErr);

71
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36);
LM's avatar
LM committed
72 73 74 75 76 77 78 79 80 81 82
#else
	mavlink_state_correction_t packet;
	packet.xErr = xErr;
	packet.yErr = yErr;
	packet.zErr = zErr;
	packet.rollErr = rollErr;
	packet.pitchErr = pitchErr;
	packet.yawErr = yawErr;
	packet.vxErr = vxErr;
	packet.vyErr = vyErr;
	packet.vzErr = vzErr;
James Goppert's avatar
James Goppert committed
83

84
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36);
LM's avatar
LM committed
85
#endif
lm's avatar
lm committed
86

LM's avatar
LM committed
87
	msg->msgid = MAVLINK_MSG_ID_STATE_CORRECTION;
lm's avatar
lm committed
88
	return mavlink_finalize_message(msg, system_id, component_id, 36, 130);
James Goppert's avatar
James Goppert committed
89 90 91
}

/**
lm's avatar
lm committed
92
 * @brief Pack a state_correction message on a channel
James Goppert's avatar
James Goppert committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
 * @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 xErr x position error
 * @param yErr y position error
 * @param zErr z position error
 * @param rollErr roll error (radians)
 * @param pitchErr pitch error (radians)
 * @param yawErr yaw error (radians)
 * @param vxErr x velocity
 * @param vyErr y velocity
 * @param vzErr z velocity
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
108 109 110
static inline uint16_t mavlink_msg_state_correction_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           float xErr,float yErr,float zErr,float rollErr,float pitchErr,float yawErr,float vxErr,float vyErr,float vzErr)
James Goppert's avatar
James Goppert committed
111
{
LM's avatar
LM committed
112 113 114 115 116 117 118 119 120 121 122 123
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[36];
	_mav_put_float(buf, 0, xErr);
	_mav_put_float(buf, 4, yErr);
	_mav_put_float(buf, 8, zErr);
	_mav_put_float(buf, 12, rollErr);
	_mav_put_float(buf, 16, pitchErr);
	_mav_put_float(buf, 20, yawErr);
	_mav_put_float(buf, 24, vxErr);
	_mav_put_float(buf, 28, vyErr);
	_mav_put_float(buf, 32, vzErr);

124
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36);
LM's avatar
LM committed
125 126 127 128 129 130 131 132 133 134 135
#else
	mavlink_state_correction_t packet;
	packet.xErr = xErr;
	packet.yErr = yErr;
	packet.zErr = zErr;
	packet.rollErr = rollErr;
	packet.pitchErr = pitchErr;
	packet.yawErr = yawErr;
	packet.vxErr = vxErr;
	packet.vyErr = vyErr;
	packet.vzErr = vzErr;
James Goppert's avatar
James Goppert committed
136

137
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36);
LM's avatar
LM committed
138
#endif
lm's avatar
lm committed
139

LM's avatar
LM committed
140
	msg->msgid = MAVLINK_MSG_ID_STATE_CORRECTION;
lm's avatar
lm committed
141
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 36, 130);
James Goppert's avatar
James Goppert committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
}

/**
 * @brief Encode a state_correction 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 state_correction C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_state_correction_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_state_correction_t* state_correction)
{
	return mavlink_msg_state_correction_pack(system_id, component_id, msg, state_correction->xErr, state_correction->yErr, state_correction->zErr, state_correction->rollErr, state_correction->pitchErr, state_correction->yawErr, state_correction->vxErr, state_correction->vyErr, state_correction->vzErr);
}

/**
 * @brief Send a state_correction message
 * @param chan MAVLink channel to send the message
 *
 * @param xErr x position error
 * @param yErr y position error
 * @param zErr z position error
 * @param rollErr roll error (radians)
 * @param pitchErr pitch error (radians)
 * @param yawErr yaw error (radians)
 * @param vxErr x velocity
 * @param vyErr y velocity
 * @param vzErr z velocity
 */
lm's avatar
lm committed
171 172
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

lm's avatar
lm committed
173 174
static inline void mavlink_msg_state_correction_send(mavlink_channel_t chan, float xErr, float yErr, float zErr, float rollErr, float pitchErr, float yawErr, float vxErr, float vyErr, float vzErr)
{
LM's avatar
LM committed
175 176 177 178 179 180 181 182 183 184 185
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[36];
	_mav_put_float(buf, 0, xErr);
	_mav_put_float(buf, 4, yErr);
	_mav_put_float(buf, 8, zErr);
	_mav_put_float(buf, 12, rollErr);
	_mav_put_float(buf, 16, pitchErr);
	_mav_put_float(buf, 20, yawErr);
	_mav_put_float(buf, 24, vxErr);
	_mav_put_float(buf, 28, vyErr);
	_mav_put_float(buf, 32, vzErr);
LM's avatar
LM committed
186

LM's avatar
LM committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATE_CORRECTION, buf, 36, 130);
#else
	mavlink_state_correction_t packet;
	packet.xErr = xErr;
	packet.yErr = yErr;
	packet.zErr = zErr;
	packet.rollErr = rollErr;
	packet.pitchErr = pitchErr;
	packet.yawErr = yawErr;
	packet.vxErr = vxErr;
	packet.vyErr = vyErr;
	packet.vzErr = vzErr;

	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATE_CORRECTION, (const char *)&packet, 36, 130);
#endif
James Goppert's avatar
James Goppert committed
202 203 204
}

#endif
lm's avatar
lm committed
205

James Goppert's avatar
James Goppert committed
206 207
// MESSAGE STATE_CORRECTION UNPACKING

lm's avatar
lm committed
208

James Goppert's avatar
James Goppert committed
209 210 211 212 213 214 215
/**
 * @brief Get field xErr from state_correction message
 *
 * @return x position error
 */
static inline float mavlink_msg_state_correction_get_xErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
216
	return _MAV_RETURN_float(msg,  0);
James Goppert's avatar
James Goppert committed
217 218 219 220 221 222 223 224 225
}

/**
 * @brief Get field yErr from state_correction message
 *
 * @return y position error
 */
static inline float mavlink_msg_state_correction_get_yErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
226
	return _MAV_RETURN_float(msg,  4);
James Goppert's avatar
James Goppert committed
227 228 229 230 231 232 233 234 235
}

/**
 * @brief Get field zErr from state_correction message
 *
 * @return z position error
 */
static inline float mavlink_msg_state_correction_get_zErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
236
	return _MAV_RETURN_float(msg,  8);
James Goppert's avatar
James Goppert committed
237 238 239 240 241 242 243 244 245
}

/**
 * @brief Get field rollErr from state_correction message
 *
 * @return roll error (radians)
 */
static inline float mavlink_msg_state_correction_get_rollErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
246
	return _MAV_RETURN_float(msg,  12);
James Goppert's avatar
James Goppert committed
247 248 249 250 251 252 253 254 255
}

/**
 * @brief Get field pitchErr from state_correction message
 *
 * @return pitch error (radians)
 */
static inline float mavlink_msg_state_correction_get_pitchErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
256
	return _MAV_RETURN_float(msg,  16);
James Goppert's avatar
James Goppert committed
257 258 259 260 261 262 263 264 265
}

/**
 * @brief Get field yawErr from state_correction message
 *
 * @return yaw error (radians)
 */
static inline float mavlink_msg_state_correction_get_yawErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
266
	return _MAV_RETURN_float(msg,  20);
James Goppert's avatar
James Goppert committed
267 268 269 270 271 272 273 274 275
}

/**
 * @brief Get field vxErr from state_correction message
 *
 * @return x velocity
 */
static inline float mavlink_msg_state_correction_get_vxErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
276
	return _MAV_RETURN_float(msg,  24);
James Goppert's avatar
James Goppert committed
277 278 279 280 281 282 283 284 285
}

/**
 * @brief Get field vyErr from state_correction message
 *
 * @return y velocity
 */
static inline float mavlink_msg_state_correction_get_vyErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
286
	return _MAV_RETURN_float(msg,  28);
James Goppert's avatar
James Goppert committed
287 288 289 290 291 292 293 294 295
}

/**
 * @brief Get field vzErr from state_correction message
 *
 * @return z velocity
 */
static inline float mavlink_msg_state_correction_get_vzErr(const mavlink_message_t* msg)
{
LM's avatar
LM committed
296
	return _MAV_RETURN_float(msg,  32);
James Goppert's avatar
James Goppert committed
297 298 299 300 301 302 303 304 305 306
}

/**
 * @brief Decode a state_correction message into a struct
 *
 * @param msg The message to decode
 * @param state_correction C-struct to decode the message contents into
 */
static inline void mavlink_msg_state_correction_decode(const mavlink_message_t* msg, mavlink_state_correction_t* state_correction)
{
lm's avatar
lm committed
307 308 309 310 311 312 313 314 315 316 317
#if MAVLINK_NEED_BYTE_SWAP
	state_correction->xErr = mavlink_msg_state_correction_get_xErr(msg);
	state_correction->yErr = mavlink_msg_state_correction_get_yErr(msg);
	state_correction->zErr = mavlink_msg_state_correction_get_zErr(msg);
	state_correction->rollErr = mavlink_msg_state_correction_get_rollErr(msg);
	state_correction->pitchErr = mavlink_msg_state_correction_get_pitchErr(msg);
	state_correction->yawErr = mavlink_msg_state_correction_get_yawErr(msg);
	state_correction->vxErr = mavlink_msg_state_correction_get_vxErr(msg);
	state_correction->vyErr = mavlink_msg_state_correction_get_vyErr(msg);
	state_correction->vzErr = mavlink_msg_state_correction_get_vzErr(msg);
#else
LM's avatar
LM committed
318
	memcpy(state_correction, _MAV_PAYLOAD(msg), 36);
lm's avatar
lm committed
319
#endif
James Goppert's avatar
James Goppert committed
320
}