Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
// MESSAGE SENSOR_OFFSETS PACKING
2
 
3
#define MAVLINK_MSG_ID_SENSOR_OFFSETS 150
4
 
5
typedef struct __mavlink_sensor_offsets_t
6
{
7
 float mag_declination; ///< magnetic declination (radians)
8
 int32_t raw_press; ///< raw pressure from barometer
9
 int32_t raw_temp; ///< raw temperature from barometer
10
 float gyro_cal_x; ///< gyro X calibration
11
 float gyro_cal_y; ///< gyro Y calibration
12
 float gyro_cal_z; ///< gyro Z calibration
13
 float accel_cal_x; ///< accel X calibration
14
 float accel_cal_y; ///< accel Y calibration
15
 float accel_cal_z; ///< accel Z calibration
16
 int16_t mag_ofs_x; ///< magnetometer X offset
17
 int16_t mag_ofs_y; ///< magnetometer Y offset
18
 int16_t mag_ofs_z; ///< magnetometer Z offset
19
} mavlink_sensor_offsets_t;
20
 
21
#define MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN 42
22
#define MAVLINK_MSG_ID_150_LEN 42
23
 
24
 
25
 
26
#define MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS { \
27
        "SENSOR_OFFSETS", \
28
        12, \
29
        {  { "mag_declination", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sensor_offsets_t, mag_declination) }, \
30
         { "raw_press", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_sensor_offsets_t, raw_press) }, \
31
         { "raw_temp", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_sensor_offsets_t, raw_temp) }, \
32
         { "gyro_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sensor_offsets_t, gyro_cal_x) }, \
33
         { "gyro_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_sensor_offsets_t, gyro_cal_y) }, \
34
         { "gyro_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_sensor_offsets_t, gyro_cal_z) }, \
35
         { "accel_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_sensor_offsets_t, accel_cal_x) }, \
36
         { "accel_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_sensor_offsets_t, accel_cal_y) }, \
37
         { "accel_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_sensor_offsets_t, accel_cal_z) }, \
38
         { "mag_ofs_x", NULL, MAVLINK_TYPE_INT16_T, 0, 36, offsetof(mavlink_sensor_offsets_t, mag_ofs_x) }, \
39
         { "mag_ofs_y", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_sensor_offsets_t, mag_ofs_y) }, \
40
         { "mag_ofs_z", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_sensor_offsets_t, mag_ofs_z) }, \
41
         } \
42
}
43
 
44
 
45
/**
46
 * @brief Pack a sensor_offsets message
47
 * @param system_id ID of this system
48
 * @param component_id ID of this component (e.g. 200 for IMU)
49
 * @param msg The MAVLink message to compress the data into
50
 *
51
 * @param mag_ofs_x magnetometer X offset
52
 * @param mag_ofs_y magnetometer Y offset
53
 * @param mag_ofs_z magnetometer Z offset
54
 * @param mag_declination magnetic declination (radians)
55
 * @param raw_press raw pressure from barometer
56
 * @param raw_temp raw temperature from barometer
57
 * @param gyro_cal_x gyro X calibration
58
 * @param gyro_cal_y gyro Y calibration
59
 * @param gyro_cal_z gyro Z calibration
60
 * @param accel_cal_x accel X calibration
61
 * @param accel_cal_y accel Y calibration
62
 * @param accel_cal_z accel Z calibration
63
 * @return length of the message in bytes (excluding serial stream start sign)
64
 */
65
static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
66
                                                       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
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
69
        char buf[42];
70
        _mav_put_float(buf, 0, mag_declination);
71
        _mav_put_int32_t(buf, 4, raw_press);
72
        _mav_put_int32_t(buf, 8, raw_temp);
73
        _mav_put_float(buf, 12, gyro_cal_x);
74
        _mav_put_float(buf, 16, gyro_cal_y);
75
        _mav_put_float(buf, 20, gyro_cal_z);
76
        _mav_put_float(buf, 24, accel_cal_x);
77
        _mav_put_float(buf, 28, accel_cal_y);
78
        _mav_put_float(buf, 32, accel_cal_z);
79
        _mav_put_int16_t(buf, 36, mag_ofs_x);
80
        _mav_put_int16_t(buf, 38, mag_ofs_y);
81
        _mav_put_int16_t(buf, 40, mag_ofs_z);
82
 
83
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
84
#else
85
        mavlink_sensor_offsets_t packet;
86
        packet.mag_declination = mag_declination;
87
        packet.raw_press = raw_press;
88
        packet.raw_temp = raw_temp;
89
        packet.gyro_cal_x = gyro_cal_x;
90
        packet.gyro_cal_y = gyro_cal_y;
91
        packet.gyro_cal_z = gyro_cal_z;
92
        packet.accel_cal_x = accel_cal_x;
93
        packet.accel_cal_y = accel_cal_y;
94
        packet.accel_cal_z = accel_cal_z;
95
        packet.mag_ofs_x = mag_ofs_x;
96
        packet.mag_ofs_y = mag_ofs_y;
97
        packet.mag_ofs_z = mag_ofs_z;
98
 
99
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
100
#endif
101
 
102
        msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
103
        return mavlink_finalize_message(msg, system_id, component_id, 42, 134);
104
}
105
 
106
/**
107
 * @brief Pack a sensor_offsets message on a channel
108
 * @param system_id ID of this system
109
 * @param component_id ID of this component (e.g. 200 for IMU)
110
 * @param chan The MAVLink channel this message was sent over
111
 * @param msg The MAVLink message to compress the data into
112
 * @param mag_ofs_x magnetometer X offset
113
 * @param mag_ofs_y magnetometer Y offset
114
 * @param mag_ofs_z magnetometer Z offset
115
 * @param mag_declination magnetic declination (radians)
116
 * @param raw_press raw pressure from barometer
117
 * @param raw_temp raw temperature from barometer
118
 * @param gyro_cal_x gyro X calibration
119
 * @param gyro_cal_y gyro Y calibration
120
 * @param gyro_cal_z gyro Z calibration
121
 * @param accel_cal_x accel X calibration
122
 * @param accel_cal_y accel Y calibration
123
 * @param accel_cal_z accel Z calibration
124
 * @return length of the message in bytes (excluding serial stream start sign)
125
 */
126
static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
127
                                                           mavlink_message_t* msg,
128
                                                           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)
129
{
130
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
131
        char buf[42];
132
        _mav_put_float(buf, 0, mag_declination);
133
        _mav_put_int32_t(buf, 4, raw_press);
134
        _mav_put_int32_t(buf, 8, raw_temp);
135
        _mav_put_float(buf, 12, gyro_cal_x);
136
        _mav_put_float(buf, 16, gyro_cal_y);
137
        _mav_put_float(buf, 20, gyro_cal_z);
138
        _mav_put_float(buf, 24, accel_cal_x);
139
        _mav_put_float(buf, 28, accel_cal_y);
140
        _mav_put_float(buf, 32, accel_cal_z);
141
        _mav_put_int16_t(buf, 36, mag_ofs_x);
142
        _mav_put_int16_t(buf, 38, mag_ofs_y);
143
        _mav_put_int16_t(buf, 40, mag_ofs_z);
144
 
145
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
146
#else
147
        mavlink_sensor_offsets_t packet;
148
        packet.mag_declination = mag_declination;
149
        packet.raw_press = raw_press;
150
        packet.raw_temp = raw_temp;
151
        packet.gyro_cal_x = gyro_cal_x;
152
        packet.gyro_cal_y = gyro_cal_y;
153
        packet.gyro_cal_z = gyro_cal_z;
154
        packet.accel_cal_x = accel_cal_x;
155
        packet.accel_cal_y = accel_cal_y;
156
        packet.accel_cal_z = accel_cal_z;
157
        packet.mag_ofs_x = mag_ofs_x;
158
        packet.mag_ofs_y = mag_ofs_y;
159
        packet.mag_ofs_z = mag_ofs_z;
160
 
161
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
162
#endif
163
 
164
        msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
165
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 134);
166
}
167
 
168
/**
169
 * @brief Encode a sensor_offsets struct into a message
170
 *
171
 * @param system_id ID of this system
172
 * @param component_id ID of this component (e.g. 200 for IMU)
173
 * @param msg The MAVLink message to compress the data into
174
 * @param sensor_offsets C-struct to read the message contents from
175
 */
176
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)
177
{
178
        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);
179
}
180
 
181
/**
182
 * @brief Send a sensor_offsets message
183
 * @param chan MAVLink channel to send the message
184
 *
185
 * @param mag_ofs_x magnetometer X offset
186
 * @param mag_ofs_y magnetometer Y offset
187
 * @param mag_ofs_z magnetometer Z offset
188
 * @param mag_declination magnetic declination (radians)
189
 * @param raw_press raw pressure from barometer
190
 * @param raw_temp raw temperature from barometer
191
 * @param gyro_cal_x gyro X calibration
192
 * @param gyro_cal_y gyro Y calibration
193
 * @param gyro_cal_z gyro Z calibration
194
 * @param accel_cal_x accel X calibration
195
 * @param accel_cal_y accel Y calibration
196
 * @param accel_cal_z accel Z calibration
197
 */
198
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
199
 
200
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)
201
{
202
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
203
        char buf[42];
204
        _mav_put_float(buf, 0, mag_declination);
205
        _mav_put_int32_t(buf, 4, raw_press);
206
        _mav_put_int32_t(buf, 8, raw_temp);
207
        _mav_put_float(buf, 12, gyro_cal_x);
208
        _mav_put_float(buf, 16, gyro_cal_y);
209
        _mav_put_float(buf, 20, gyro_cal_z);
210
        _mav_put_float(buf, 24, accel_cal_x);
211
        _mav_put_float(buf, 28, accel_cal_y);
212
        _mav_put_float(buf, 32, accel_cal_z);
213
        _mav_put_int16_t(buf, 36, mag_ofs_x);
214
        _mav_put_int16_t(buf, 38, mag_ofs_y);
215
        _mav_put_int16_t(buf, 40, mag_ofs_z);
216
 
217
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, buf, 42, 134);
218
#else
219
        mavlink_sensor_offsets_t packet;
220
        packet.mag_declination = mag_declination;
221
        packet.raw_press = raw_press;
222
        packet.raw_temp = raw_temp;
223
        packet.gyro_cal_x = gyro_cal_x;
224
        packet.gyro_cal_y = gyro_cal_y;
225
        packet.gyro_cal_z = gyro_cal_z;
226
        packet.accel_cal_x = accel_cal_x;
227
        packet.accel_cal_y = accel_cal_y;
228
        packet.accel_cal_z = accel_cal_z;
229
        packet.mag_ofs_x = mag_ofs_x;
230
        packet.mag_ofs_y = mag_ofs_y;
231
        packet.mag_ofs_z = mag_ofs_z;
232
 
233
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)&packet, 42, 134);
234
#endif
235
}
236
 
237
#endif
238
 
239
// MESSAGE SENSOR_OFFSETS UNPACKING
240
 
241
 
242
/**
243
 * @brief Get field mag_ofs_x from sensor_offsets message
244
 *
245
 * @return magnetometer X offset
246
 */
247
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_x(const mavlink_message_t* msg)
248
{
249
        return _MAV_RETURN_int16_t(msg,  36);
250
}
251
 
252
/**
253
 * @brief Get field mag_ofs_y from sensor_offsets message
254
 *
255
 * @return magnetometer Y offset
256
 */
257
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_y(const mavlink_message_t* msg)
258
{
259
        return _MAV_RETURN_int16_t(msg,  38);
260
}
261
 
262
/**
263
 * @brief Get field mag_ofs_z from sensor_offsets message
264
 *
265
 * @return magnetometer Z offset
266
 */
267
static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_z(const mavlink_message_t* msg)
268
{
269
        return _MAV_RETURN_int16_t(msg,  40);
270
}
271
 
272
/**
273
 * @brief Get field mag_declination from sensor_offsets message
274
 *
275
 * @return magnetic declination (radians)
276
 */
277
static inline float mavlink_msg_sensor_offsets_get_mag_declination(const mavlink_message_t* msg)
278
{
279
        return _MAV_RETURN_float(msg,  0);
280
}
281
 
282
/**
283
 * @brief Get field raw_press from sensor_offsets message
284
 *
285
 * @return raw pressure from barometer
286
 */
287
static inline int32_t mavlink_msg_sensor_offsets_get_raw_press(const mavlink_message_t* msg)
288
{
289
        return _MAV_RETURN_int32_t(msg,  4);
290
}
291
 
292
/**
293
 * @brief Get field raw_temp from sensor_offsets message
294
 *
295
 * @return raw temperature from barometer
296
 */
297
static inline int32_t mavlink_msg_sensor_offsets_get_raw_temp(const mavlink_message_t* msg)
298
{
299
        return _MAV_RETURN_int32_t(msg,  8);
300
}
301
 
302
/**
303
 * @brief Get field gyro_cal_x from sensor_offsets message
304
 *
305
 * @return gyro X calibration
306
 */
307
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_x(const mavlink_message_t* msg)
308
{
309
        return _MAV_RETURN_float(msg,  12);
310
}
311
 
312
/**
313
 * @brief Get field gyro_cal_y from sensor_offsets message
314
 *
315
 * @return gyro Y calibration
316
 */
317
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_y(const mavlink_message_t* msg)
318
{
319
        return _MAV_RETURN_float(msg,  16);
320
}
321
 
322
/**
323
 * @brief Get field gyro_cal_z from sensor_offsets message
324
 *
325
 * @return gyro Z calibration
326
 */
327
static inline float mavlink_msg_sensor_offsets_get_gyro_cal_z(const mavlink_message_t* msg)
328
{
329
        return _MAV_RETURN_float(msg,  20);
330
}
331
 
332
/**
333
 * @brief Get field accel_cal_x from sensor_offsets message
334
 *
335
 * @return accel X calibration
336
 */
337
static inline float mavlink_msg_sensor_offsets_get_accel_cal_x(const mavlink_message_t* msg)
338
{
339
        return _MAV_RETURN_float(msg,  24);
340
}
341
 
342
/**
343
 * @brief Get field accel_cal_y from sensor_offsets message
344
 *
345
 * @return accel Y calibration
346
 */
347
static inline float mavlink_msg_sensor_offsets_get_accel_cal_y(const mavlink_message_t* msg)
348
{
349
        return _MAV_RETURN_float(msg,  28);
350
}
351
 
352
/**
353
 * @brief Get field accel_cal_z from sensor_offsets message
354
 *
355
 * @return accel Z calibration
356
 */
357
static inline float mavlink_msg_sensor_offsets_get_accel_cal_z(const mavlink_message_t* msg)
358
{
359
        return _MAV_RETURN_float(msg,  32);
360
}
361
 
362
/**
363
 * @brief Decode a sensor_offsets message into a struct
364
 *
365
 * @param msg The message to decode
366
 * @param sensor_offsets C-struct to decode the message contents into
367
 */
368
static inline void mavlink_msg_sensor_offsets_decode(const mavlink_message_t* msg, mavlink_sensor_offsets_t* sensor_offsets)
369
{
370
#if MAVLINK_NEED_BYTE_SWAP
371
        sensor_offsets->mag_declination = mavlink_msg_sensor_offsets_get_mag_declination(msg);
372
        sensor_offsets->raw_press = mavlink_msg_sensor_offsets_get_raw_press(msg);
373
        sensor_offsets->raw_temp = mavlink_msg_sensor_offsets_get_raw_temp(msg);
374
        sensor_offsets->gyro_cal_x = mavlink_msg_sensor_offsets_get_gyro_cal_x(msg);
375
        sensor_offsets->gyro_cal_y = mavlink_msg_sensor_offsets_get_gyro_cal_y(msg);
376
        sensor_offsets->gyro_cal_z = mavlink_msg_sensor_offsets_get_gyro_cal_z(msg);
377
        sensor_offsets->accel_cal_x = mavlink_msg_sensor_offsets_get_accel_cal_x(msg);
378
        sensor_offsets->accel_cal_y = mavlink_msg_sensor_offsets_get_accel_cal_y(msg);
379
        sensor_offsets->accel_cal_z = mavlink_msg_sensor_offsets_get_accel_cal_z(msg);
380
        sensor_offsets->mag_ofs_x = mavlink_msg_sensor_offsets_get_mag_ofs_x(msg);
381
        sensor_offsets->mag_ofs_y = mavlink_msg_sensor_offsets_get_mag_ofs_y(msg);
382
        sensor_offsets->mag_ofs_z = mavlink_msg_sensor_offsets_get_mag_ofs_z(msg);
383
#else
384
        memcpy(sensor_offsets, _MAV_PAYLOAD(msg), 42);
385
#endif
386
}