mavlink_msg_sensor_offsets.h 13.3 KB
Newer Older
1 2 3 4
// MESSAGE SENSOR_OFFSETS PACKING

#define MAVLINK_MSG_ID_SENSOR_OFFSETS 150

lm's avatar
lm committed
5
typedef struct __mavlink_sensor_offsets_t
6
{
lm's avatar
lm committed
7 8 9 10 11 12 13 14 15 16 17 18
 float mag_declination; ///< magnetic declination (radians)
 int32_t raw_press; ///< raw pressure from barometer
 int32_t raw_temp; ///< raw temperature from barometer
 float gyro_cal_x; ///< gyro X calibration
 float gyro_cal_y; ///< gyro Y calibration
 float gyro_cal_z; ///< gyro Z calibration
 float accel_cal_x; ///< accel X calibration
 float accel_cal_y; ///< accel Y calibration
 float accel_cal_z; ///< accel Z calibration
 int16_t mag_ofs_x; ///< magnetometer X offset
 int16_t mag_ofs_y; ///< magnetometer Y offset
 int16_t mag_ofs_z; ///< magnetometer Z offset
19 20
} mavlink_sensor_offsets_t;

lm's avatar
lm committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#define MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN 42
#define MAVLINK_MSG_ID_150_LEN 42



#define MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS { \
	"SENSOR_OFFSETS", \
	12, \
	{  { "mag_declination", MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sensor_offsets_t, mag_declination) }, \
         { "raw_press", MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_sensor_offsets_t, raw_press) }, \
         { "raw_temp", MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_sensor_offsets_t, raw_temp) }, \
         { "gyro_cal_x", MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sensor_offsets_t, gyro_cal_x) }, \
         { "gyro_cal_y", MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_sensor_offsets_t, gyro_cal_y) }, \
         { "gyro_cal_z", MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_sensor_offsets_t, gyro_cal_z) }, \
         { "accel_cal_x", MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_sensor_offsets_t, accel_cal_x) }, \
         { "accel_cal_y", MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_sensor_offsets_t, accel_cal_y) }, \
         { "accel_cal_z", MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_sensor_offsets_t, accel_cal_z) }, \
         { "mag_ofs_x", MAVLINK_TYPE_INT16_T, 0, 36, offsetof(mavlink_sensor_offsets_t, mag_ofs_x) }, \
         { "mag_ofs_y", MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_sensor_offsets_t, mag_ofs_y) }, \
         { "mag_ofs_z", MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_sensor_offsets_t, mag_ofs_z) }, \
         } \
}


45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
/**
 * @brief Pack a sensor_offsets 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 mag_ofs_x magnetometer X offset
 * @param mag_ofs_y magnetometer Y offset
 * @param mag_ofs_z magnetometer Z offset
 * @param mag_declination magnetic declination (radians)
 * @param raw_press raw pressure from barometer
 * @param raw_temp raw temperature from barometer
 * @param gyro_cal_x gyro X calibration
 * @param gyro_cal_y gyro Y calibration
 * @param gyro_cal_z gyro Z calibration
 * @param accel_cal_x accel X calibration
 * @param accel_cal_y accel Y calibration
 * @param accel_cal_z accel Z calibration
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
65 66
static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
67 68 69
{
	msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;

lm's avatar
lm committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83
	put_float_by_index(msg, 0, mag_declination); // magnetic declination (radians)
	put_int32_t_by_index(msg, 4, raw_press); // raw pressure from barometer
	put_int32_t_by_index(msg, 8, raw_temp); // raw temperature from barometer
	put_float_by_index(msg, 12, gyro_cal_x); // gyro X calibration
	put_float_by_index(msg, 16, gyro_cal_y); // gyro Y calibration
	put_float_by_index(msg, 20, gyro_cal_z); // gyro Z calibration
	put_float_by_index(msg, 24, accel_cal_x); // accel X calibration
	put_float_by_index(msg, 28, accel_cal_y); // accel Y calibration
	put_float_by_index(msg, 32, accel_cal_z); // accel Z calibration
	put_int16_t_by_index(msg, 36, mag_ofs_x); // magnetometer X offset
	put_int16_t_by_index(msg, 38, mag_ofs_y); // magnetometer Y offset
	put_int16_t_by_index(msg, 40, mag_ofs_z); // magnetometer Z offset

	return mavlink_finalize_message(msg, system_id, component_id, 42, 134);
84 85 86
}

/**
lm's avatar
lm committed
87
 * @brief Pack a sensor_offsets message on a channel
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
 * @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 mag_ofs_x magnetometer X offset
 * @param mag_ofs_y magnetometer Y offset
 * @param mag_ofs_z magnetometer Z offset
 * @param mag_declination magnetic declination (radians)
 * @param raw_press raw pressure from barometer
 * @param raw_temp raw temperature from barometer
 * @param gyro_cal_x gyro X calibration
 * @param gyro_cal_y gyro Y calibration
 * @param gyro_cal_z gyro Z calibration
 * @param accel_cal_x accel X calibration
 * @param accel_cal_y accel Y calibration
 * @param accel_cal_z accel Z calibration
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           int16_t mag_ofs_x,int16_t mag_ofs_y,int16_t mag_ofs_z,float mag_declination,int32_t raw_press,int32_t raw_temp,float gyro_cal_x,float gyro_cal_y,float gyro_cal_z,float accel_cal_x,float accel_cal_y,float accel_cal_z)
{
	msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;

	put_float_by_index(msg, 0, mag_declination); // magnetic declination (radians)
	put_int32_t_by_index(msg, 4, raw_press); // raw pressure from barometer
	put_int32_t_by_index(msg, 8, raw_temp); // raw temperature from barometer
	put_float_by_index(msg, 12, gyro_cal_x); // gyro X calibration
	put_float_by_index(msg, 16, gyro_cal_y); // gyro Y calibration
	put_float_by_index(msg, 20, gyro_cal_z); // gyro Z calibration
	put_float_by_index(msg, 24, accel_cal_x); // accel X calibration
	put_float_by_index(msg, 28, accel_cal_y); // accel Y calibration
	put_float_by_index(msg, 32, accel_cal_z); // accel Z calibration
	put_int16_t_by_index(msg, 36, mag_ofs_x); // magnetometer X offset
	put_int16_t_by_index(msg, 38, mag_ofs_y); // magnetometer Y offset
	put_int16_t_by_index(msg, 40, mag_ofs_z); // magnetometer Z offset

	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 134);
}

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/**
 * @brief Encode a sensor_offsets 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 sensor_offsets C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_sensor_offsets_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sensor_offsets_t* sensor_offsets)
{
	return mavlink_msg_sensor_offsets_pack(system_id, component_id, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z);
}

/**
 * @brief Send a sensor_offsets message
 * @param chan MAVLink channel to send the message
 *
 * @param mag_ofs_x magnetometer X offset
 * @param mag_ofs_y magnetometer Y offset
 * @param mag_ofs_z magnetometer Z offset
 * @param mag_declination magnetic declination (radians)
 * @param raw_press raw pressure from barometer
 * @param raw_temp raw temperature from barometer
 * @param gyro_cal_x gyro X calibration
 * @param gyro_cal_y gyro Y calibration
 * @param gyro_cal_z gyro Z calibration
 * @param accel_cal_x accel X calibration
 * @param accel_cal_y accel Y calibration
 * @param accel_cal_z accel Z calibration
 */
lm's avatar
lm committed
158 159
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

160 161
static inline void mavlink_msg_sensor_offsets_send(mavlink_channel_t chan, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
{
lm's avatar
lm committed
162
	MAVLINK_ALIGNED_MESSAGE(msg, 42);
LM's avatar
LM committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
	msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;

	put_float_by_index(msg, 0, mag_declination); // magnetic declination (radians)
	put_int32_t_by_index(msg, 4, raw_press); // raw pressure from barometer
	put_int32_t_by_index(msg, 8, raw_temp); // raw temperature from barometer
	put_float_by_index(msg, 12, gyro_cal_x); // gyro X calibration
	put_float_by_index(msg, 16, gyro_cal_y); // gyro Y calibration
	put_float_by_index(msg, 20, gyro_cal_z); // gyro Z calibration
	put_float_by_index(msg, 24, accel_cal_x); // accel X calibration
	put_float_by_index(msg, 28, accel_cal_y); // accel Y calibration
	put_float_by_index(msg, 32, accel_cal_z); // accel Z calibration
	put_int16_t_by_index(msg, 36, mag_ofs_x); // magnetometer X offset
	put_int16_t_by_index(msg, 38, mag_ofs_y); // magnetometer Y offset
	put_int16_t_by_index(msg, 40, mag_ofs_z); // magnetometer Z offset

	mavlink_finalize_message_chan_send(msg, chan, 42, 134);
179 180 181
}

#endif
lm's avatar
lm committed
182

183 184
// MESSAGE SENSOR_OFFSETS UNPACKING

lm's avatar
lm committed
185

186 187 188 189 190 191 192
/**
 * @brief Get field mag_ofs_x from sensor_offsets message
 *
 * @return magnetometer X offset
 */
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_x(const mavlink_message_t* msg)
{
lm's avatar
lm committed
193
	return MAVLINK_MSG_RETURN_int16_t(msg,  36);
194 195 196 197 198 199 200 201 202
}

/**
 * @brief Get field mag_ofs_y from sensor_offsets message
 *
 * @return magnetometer Y offset
 */
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_y(const mavlink_message_t* msg)
{
lm's avatar
lm committed
203
	return MAVLINK_MSG_RETURN_int16_t(msg,  38);
204 205 206 207 208 209 210 211 212
}

/**
 * @brief Get field mag_ofs_z from sensor_offsets message
 *
 * @return magnetometer Z offset
 */
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_z(const mavlink_message_t* msg)
{
lm's avatar
lm committed
213
	return MAVLINK_MSG_RETURN_int16_t(msg,  40);
214 215 216 217 218 219 220 221 222
}

/**
 * @brief Get field mag_declination from sensor_offsets message
 *
 * @return magnetic declination (radians)
 */
static inline float mavlink_msg_sensor_offsets_get_mag_declination(const mavlink_message_t* msg)
{
lm's avatar
lm committed
223
	return MAVLINK_MSG_RETURN_float(msg,  0);
224 225 226 227 228 229 230 231 232
}

/**
 * @brief Get field raw_press from sensor_offsets message
 *
 * @return raw pressure from barometer
 */
static inline int32_t mavlink_msg_sensor_offsets_get_raw_press(const mavlink_message_t* msg)
{
lm's avatar
lm committed
233
	return MAVLINK_MSG_RETURN_int32_t(msg,  4);
234 235 236 237 238 239 240 241 242
}

/**
 * @brief Get field raw_temp from sensor_offsets message
 *
 * @return raw temperature from barometer
 */
static inline int32_t mavlink_msg_sensor_offsets_get_raw_temp(const mavlink_message_t* msg)
{
lm's avatar
lm committed
243
	return MAVLINK_MSG_RETURN_int32_t(msg,  8);
244 245 246 247 248 249 250 251 252
}

/**
 * @brief Get field gyro_cal_x from sensor_offsets message
 *
 * @return gyro X calibration
 */
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_x(const mavlink_message_t* msg)
{
lm's avatar
lm committed
253
	return MAVLINK_MSG_RETURN_float(msg,  12);
254 255 256 257 258 259 260 261 262
}

/**
 * @brief Get field gyro_cal_y from sensor_offsets message
 *
 * @return gyro Y calibration
 */
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_y(const mavlink_message_t* msg)
{
lm's avatar
lm committed
263
	return MAVLINK_MSG_RETURN_float(msg,  16);
264 265 266 267 268 269 270 271 272
}

/**
 * @brief Get field gyro_cal_z from sensor_offsets message
 *
 * @return gyro Z calibration
 */
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_z(const mavlink_message_t* msg)
{
lm's avatar
lm committed
273
	return MAVLINK_MSG_RETURN_float(msg,  20);
274 275 276 277 278 279 280 281 282
}

/**
 * @brief Get field accel_cal_x from sensor_offsets message
 *
 * @return accel X calibration
 */
static inline float mavlink_msg_sensor_offsets_get_accel_cal_x(const mavlink_message_t* msg)
{
lm's avatar
lm committed
283
	return MAVLINK_MSG_RETURN_float(msg,  24);
284 285 286 287 288 289 290 291 292
}

/**
 * @brief Get field accel_cal_y from sensor_offsets message
 *
 * @return accel Y calibration
 */
static inline float mavlink_msg_sensor_offsets_get_accel_cal_y(const mavlink_message_t* msg)
{
lm's avatar
lm committed
293
	return MAVLINK_MSG_RETURN_float(msg,  28);
294 295 296 297 298 299 300 301 302
}

/**
 * @brief Get field accel_cal_z from sensor_offsets message
 *
 * @return accel Z calibration
 */
static inline float mavlink_msg_sensor_offsets_get_accel_cal_z(const mavlink_message_t* msg)
{
lm's avatar
lm committed
303
	return MAVLINK_MSG_RETURN_float(msg,  32);
304 305 306 307 308 309 310 311 312 313
}

/**
 * @brief Decode a sensor_offsets message into a struct
 *
 * @param msg The message to decode
 * @param sensor_offsets C-struct to decode the message contents into
 */
static inline void mavlink_msg_sensor_offsets_decode(const mavlink_message_t* msg, mavlink_sensor_offsets_t* sensor_offsets)
{
lm's avatar
lm committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
#if MAVLINK_NEED_BYTE_SWAP
	sensor_offsets->mag_declination = mavlink_msg_sensor_offsets_get_mag_declination(msg);
	sensor_offsets->raw_press = mavlink_msg_sensor_offsets_get_raw_press(msg);
	sensor_offsets->raw_temp = mavlink_msg_sensor_offsets_get_raw_temp(msg);
	sensor_offsets->gyro_cal_x = mavlink_msg_sensor_offsets_get_gyro_cal_x(msg);
	sensor_offsets->gyro_cal_y = mavlink_msg_sensor_offsets_get_gyro_cal_y(msg);
	sensor_offsets->gyro_cal_z = mavlink_msg_sensor_offsets_get_gyro_cal_z(msg);
	sensor_offsets->accel_cal_x = mavlink_msg_sensor_offsets_get_accel_cal_x(msg);
	sensor_offsets->accel_cal_y = mavlink_msg_sensor_offsets_get_accel_cal_y(msg);
	sensor_offsets->accel_cal_z = mavlink_msg_sensor_offsets_get_accel_cal_z(msg);
	sensor_offsets->mag_ofs_x = mavlink_msg_sensor_offsets_get_mag_ofs_x(msg);
	sensor_offsets->mag_ofs_y = mavlink_msg_sensor_offsets_get_mag_ofs_y(msg);
	sensor_offsets->mag_ofs_z = mavlink_msg_sensor_offsets_get_mag_ofs_z(msg);
#else
	memcpy(sensor_offsets, MAVLINK_PAYLOAD(msg), 42);
#endif
330
}