![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
MAVlink/include/common/mavlink_msg_raw_imu.h@25:bb5356402687, 2018-11-30 (annotated)
- Committer:
- shimniok
- Date:
- Fri Nov 30 16:11:53 2018 +0000
- Revision:
- 25:bb5356402687
- Parent:
- 0:a6a169de725f
Initial publish of revised version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE RAW_IMU PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_RAW_IMU 28 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_raw_imu_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint64_t usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 8 | int16_t xacc; ///< X acceleration (raw) |
shimniok | 0:a6a169de725f | 9 | int16_t yacc; ///< Y acceleration (raw) |
shimniok | 0:a6a169de725f | 10 | int16_t zacc; ///< Z acceleration (raw) |
shimniok | 0:a6a169de725f | 11 | int16_t xgyro; ///< Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 12 | int16_t ygyro; ///< Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 13 | int16_t zgyro; ///< Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 14 | int16_t xmag; ///< X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 15 | int16_t ymag; ///< Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 16 | int16_t zmag; ///< Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 17 | |
shimniok | 0:a6a169de725f | 18 | } mavlink_raw_imu_t; |
shimniok | 0:a6a169de725f | 19 | |
shimniok | 0:a6a169de725f | 20 | |
shimniok | 0:a6a169de725f | 21 | |
shimniok | 0:a6a169de725f | 22 | /** |
shimniok | 0:a6a169de725f | 23 | * @brief Pack a raw_imu message |
shimniok | 0:a6a169de725f | 24 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 25 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 26 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 27 | * |
shimniok | 0:a6a169de725f | 28 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 29 | * @param xacc X acceleration (raw) |
shimniok | 0:a6a169de725f | 30 | * @param yacc Y acceleration (raw) |
shimniok | 0:a6a169de725f | 31 | * @param zacc Z acceleration (raw) |
shimniok | 0:a6a169de725f | 32 | * @param xgyro Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 33 | * @param ygyro Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 34 | * @param zgyro Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 35 | * @param xmag X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 36 | * @param ymag Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 37 | * @param zmag Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 38 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 39 | */ |
shimniok | 0:a6a169de725f | 40 | static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag) |
shimniok | 0:a6a169de725f | 41 | { |
shimniok | 0:a6a169de725f | 42 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 43 | msg->msgid = MAVLINK_MSG_ID_RAW_IMU; |
shimniok | 0:a6a169de725f | 44 | |
shimniok | 0:a6a169de725f | 45 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 46 | i += put_int16_t_by_index(xacc, i, msg->payload); // X acceleration (raw) |
shimniok | 0:a6a169de725f | 47 | i += put_int16_t_by_index(yacc, i, msg->payload); // Y acceleration (raw) |
shimniok | 0:a6a169de725f | 48 | i += put_int16_t_by_index(zacc, i, msg->payload); // Z acceleration (raw) |
shimniok | 0:a6a169de725f | 49 | i += put_int16_t_by_index(xgyro, i, msg->payload); // Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 50 | i += put_int16_t_by_index(ygyro, i, msg->payload); // Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 51 | i += put_int16_t_by_index(zgyro, i, msg->payload); // Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 52 | i += put_int16_t_by_index(xmag, i, msg->payload); // X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 53 | i += put_int16_t_by_index(ymag, i, msg->payload); // Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 54 | i += put_int16_t_by_index(zmag, i, msg->payload); // Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 55 | |
shimniok | 0:a6a169de725f | 56 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 57 | } |
shimniok | 0:a6a169de725f | 58 | |
shimniok | 0:a6a169de725f | 59 | /** |
shimniok | 0:a6a169de725f | 60 | * @brief Pack a raw_imu message |
shimniok | 0:a6a169de725f | 61 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 62 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 63 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 64 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 65 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 66 | * @param xacc X acceleration (raw) |
shimniok | 0:a6a169de725f | 67 | * @param yacc Y acceleration (raw) |
shimniok | 0:a6a169de725f | 68 | * @param zacc Z acceleration (raw) |
shimniok | 0:a6a169de725f | 69 | * @param xgyro Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 70 | * @param ygyro Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 71 | * @param zgyro Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 72 | * @param xmag X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 73 | * @param ymag Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 74 | * @param zmag Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 75 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 76 | */ |
shimniok | 0:a6a169de725f | 77 | static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint64_t usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag) |
shimniok | 0:a6a169de725f | 78 | { |
shimniok | 0:a6a169de725f | 79 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 80 | msg->msgid = MAVLINK_MSG_ID_RAW_IMU; |
shimniok | 0:a6a169de725f | 81 | |
shimniok | 0:a6a169de725f | 82 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 83 | i += put_int16_t_by_index(xacc, i, msg->payload); // X acceleration (raw) |
shimniok | 0:a6a169de725f | 84 | i += put_int16_t_by_index(yacc, i, msg->payload); // Y acceleration (raw) |
shimniok | 0:a6a169de725f | 85 | i += put_int16_t_by_index(zacc, i, msg->payload); // Z acceleration (raw) |
shimniok | 0:a6a169de725f | 86 | i += put_int16_t_by_index(xgyro, i, msg->payload); // Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 87 | i += put_int16_t_by_index(ygyro, i, msg->payload); // Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 88 | i += put_int16_t_by_index(zgyro, i, msg->payload); // Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 89 | i += put_int16_t_by_index(xmag, i, msg->payload); // X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 90 | i += put_int16_t_by_index(ymag, i, msg->payload); // Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 91 | i += put_int16_t_by_index(zmag, i, msg->payload); // Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 92 | |
shimniok | 0:a6a169de725f | 93 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 94 | } |
shimniok | 0:a6a169de725f | 95 | |
shimniok | 0:a6a169de725f | 96 | /** |
shimniok | 0:a6a169de725f | 97 | * @brief Encode a raw_imu struct into a message |
shimniok | 0:a6a169de725f | 98 | * |
shimniok | 0:a6a169de725f | 99 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 100 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 101 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 102 | * @param raw_imu C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 103 | */ |
shimniok | 0:a6a169de725f | 104 | static inline uint16_t mavlink_msg_raw_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_imu_t* raw_imu) |
shimniok | 0:a6a169de725f | 105 | { |
shimniok | 0:a6a169de725f | 106 | return mavlink_msg_raw_imu_pack(system_id, component_id, msg, raw_imu->usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag); |
shimniok | 0:a6a169de725f | 107 | } |
shimniok | 0:a6a169de725f | 108 | |
shimniok | 0:a6a169de725f | 109 | /** |
shimniok | 0:a6a169de725f | 110 | * @brief Send a raw_imu message |
shimniok | 0:a6a169de725f | 111 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 112 | * |
shimniok | 0:a6a169de725f | 113 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 114 | * @param xacc X acceleration (raw) |
shimniok | 0:a6a169de725f | 115 | * @param yacc Y acceleration (raw) |
shimniok | 0:a6a169de725f | 116 | * @param zacc Z acceleration (raw) |
shimniok | 0:a6a169de725f | 117 | * @param xgyro Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 118 | * @param ygyro Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 119 | * @param zgyro Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 120 | * @param xmag X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 121 | * @param ymag Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 122 | * @param zmag Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 123 | */ |
shimniok | 0:a6a169de725f | 124 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 125 | |
shimniok | 0:a6a169de725f | 126 | static inline void mavlink_msg_raw_imu_send(mavlink_channel_t chan, uint64_t usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag) |
shimniok | 0:a6a169de725f | 127 | { |
shimniok | 0:a6a169de725f | 128 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 129 | mavlink_msg_raw_imu_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, xacc, yacc, zacc, xgyro, ygyro, zgyro, xmag, ymag, zmag); |
shimniok | 0:a6a169de725f | 130 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 131 | } |
shimniok | 0:a6a169de725f | 132 | |
shimniok | 0:a6a169de725f | 133 | #endif |
shimniok | 0:a6a169de725f | 134 | // MESSAGE RAW_IMU UNPACKING |
shimniok | 0:a6a169de725f | 135 | |
shimniok | 0:a6a169de725f | 136 | /** |
shimniok | 0:a6a169de725f | 137 | * @brief Get field usec from raw_imu message |
shimniok | 0:a6a169de725f | 138 | * |
shimniok | 0:a6a169de725f | 139 | * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:a6a169de725f | 140 | */ |
shimniok | 0:a6a169de725f | 141 | static inline uint64_t mavlink_msg_raw_imu_get_usec(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 142 | { |
shimniok | 0:a6a169de725f | 143 | generic_64bit r; |
shimniok | 0:a6a169de725f | 144 | r.b[7] = (msg->payload)[0]; |
shimniok | 0:a6a169de725f | 145 | r.b[6] = (msg->payload)[1]; |
shimniok | 0:a6a169de725f | 146 | r.b[5] = (msg->payload)[2]; |
shimniok | 0:a6a169de725f | 147 | r.b[4] = (msg->payload)[3]; |
shimniok | 0:a6a169de725f | 148 | r.b[3] = (msg->payload)[4]; |
shimniok | 0:a6a169de725f | 149 | r.b[2] = (msg->payload)[5]; |
shimniok | 0:a6a169de725f | 150 | r.b[1] = (msg->payload)[6]; |
shimniok | 0:a6a169de725f | 151 | r.b[0] = (msg->payload)[7]; |
shimniok | 0:a6a169de725f | 152 | return (uint64_t)r.ll; |
shimniok | 0:a6a169de725f | 153 | } |
shimniok | 0:a6a169de725f | 154 | |
shimniok | 0:a6a169de725f | 155 | /** |
shimniok | 0:a6a169de725f | 156 | * @brief Get field xacc from raw_imu message |
shimniok | 0:a6a169de725f | 157 | * |
shimniok | 0:a6a169de725f | 158 | * @return X acceleration (raw) |
shimniok | 0:a6a169de725f | 159 | */ |
shimniok | 0:a6a169de725f | 160 | static inline int16_t mavlink_msg_raw_imu_get_xacc(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 161 | { |
shimniok | 0:a6a169de725f | 162 | generic_16bit r; |
shimniok | 0:a6a169de725f | 163 | r.b[1] = (msg->payload+sizeof(uint64_t))[0]; |
shimniok | 0:a6a169de725f | 164 | r.b[0] = (msg->payload+sizeof(uint64_t))[1]; |
shimniok | 0:a6a169de725f | 165 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 166 | } |
shimniok | 0:a6a169de725f | 167 | |
shimniok | 0:a6a169de725f | 168 | /** |
shimniok | 0:a6a169de725f | 169 | * @brief Get field yacc from raw_imu message |
shimniok | 0:a6a169de725f | 170 | * |
shimniok | 0:a6a169de725f | 171 | * @return Y acceleration (raw) |
shimniok | 0:a6a169de725f | 172 | */ |
shimniok | 0:a6a169de725f | 173 | static inline int16_t mavlink_msg_raw_imu_get_yacc(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 174 | { |
shimniok | 0:a6a169de725f | 175 | generic_16bit r; |
shimniok | 0:a6a169de725f | 176 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 177 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 178 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 179 | } |
shimniok | 0:a6a169de725f | 180 | |
shimniok | 0:a6a169de725f | 181 | /** |
shimniok | 0:a6a169de725f | 182 | * @brief Get field zacc from raw_imu message |
shimniok | 0:a6a169de725f | 183 | * |
shimniok | 0:a6a169de725f | 184 | * @return Z acceleration (raw) |
shimniok | 0:a6a169de725f | 185 | */ |
shimniok | 0:a6a169de725f | 186 | static inline int16_t mavlink_msg_raw_imu_get_zacc(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 187 | { |
shimniok | 0:a6a169de725f | 188 | generic_16bit r; |
shimniok | 0:a6a169de725f | 189 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 190 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 191 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 192 | } |
shimniok | 0:a6a169de725f | 193 | |
shimniok | 0:a6a169de725f | 194 | /** |
shimniok | 0:a6a169de725f | 195 | * @brief Get field xgyro from raw_imu message |
shimniok | 0:a6a169de725f | 196 | * |
shimniok | 0:a6a169de725f | 197 | * @return Angular speed around X axis (raw) |
shimniok | 0:a6a169de725f | 198 | */ |
shimniok | 0:a6a169de725f | 199 | static inline int16_t mavlink_msg_raw_imu_get_xgyro(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 200 | { |
shimniok | 0:a6a169de725f | 201 | generic_16bit r; |
shimniok | 0:a6a169de725f | 202 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 203 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 204 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 205 | } |
shimniok | 0:a6a169de725f | 206 | |
shimniok | 0:a6a169de725f | 207 | /** |
shimniok | 0:a6a169de725f | 208 | * @brief Get field ygyro from raw_imu message |
shimniok | 0:a6a169de725f | 209 | * |
shimniok | 0:a6a169de725f | 210 | * @return Angular speed around Y axis (raw) |
shimniok | 0:a6a169de725f | 211 | */ |
shimniok | 0:a6a169de725f | 212 | static inline int16_t mavlink_msg_raw_imu_get_ygyro(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 213 | { |
shimniok | 0:a6a169de725f | 214 | generic_16bit r; |
shimniok | 0:a6a169de725f | 215 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 216 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 217 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 218 | } |
shimniok | 0:a6a169de725f | 219 | |
shimniok | 0:a6a169de725f | 220 | /** |
shimniok | 0:a6a169de725f | 221 | * @brief Get field zgyro from raw_imu message |
shimniok | 0:a6a169de725f | 222 | * |
shimniok | 0:a6a169de725f | 223 | * @return Angular speed around Z axis (raw) |
shimniok | 0:a6a169de725f | 224 | */ |
shimniok | 0:a6a169de725f | 225 | static inline int16_t mavlink_msg_raw_imu_get_zgyro(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 226 | { |
shimniok | 0:a6a169de725f | 227 | generic_16bit r; |
shimniok | 0:a6a169de725f | 228 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 229 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 230 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 231 | } |
shimniok | 0:a6a169de725f | 232 | |
shimniok | 0:a6a169de725f | 233 | /** |
shimniok | 0:a6a169de725f | 234 | * @brief Get field xmag from raw_imu message |
shimniok | 0:a6a169de725f | 235 | * |
shimniok | 0:a6a169de725f | 236 | * @return X Magnetic field (raw) |
shimniok | 0:a6a169de725f | 237 | */ |
shimniok | 0:a6a169de725f | 238 | static inline int16_t mavlink_msg_raw_imu_get_xmag(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 239 | { |
shimniok | 0:a6a169de725f | 240 | generic_16bit r; |
shimniok | 0:a6a169de725f | 241 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 242 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 243 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 244 | } |
shimniok | 0:a6a169de725f | 245 | |
shimniok | 0:a6a169de725f | 246 | /** |
shimniok | 0:a6a169de725f | 247 | * @brief Get field ymag from raw_imu message |
shimniok | 0:a6a169de725f | 248 | * |
shimniok | 0:a6a169de725f | 249 | * @return Y Magnetic field (raw) |
shimniok | 0:a6a169de725f | 250 | */ |
shimniok | 0:a6a169de725f | 251 | static inline int16_t mavlink_msg_raw_imu_get_ymag(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 252 | { |
shimniok | 0:a6a169de725f | 253 | generic_16bit r; |
shimniok | 0:a6a169de725f | 254 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 255 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 256 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 257 | } |
shimniok | 0:a6a169de725f | 258 | |
shimniok | 0:a6a169de725f | 259 | /** |
shimniok | 0:a6a169de725f | 260 | * @brief Get field zmag from raw_imu message |
shimniok | 0:a6a169de725f | 261 | * |
shimniok | 0:a6a169de725f | 262 | * @return Z Magnetic field (raw) |
shimniok | 0:a6a169de725f | 263 | */ |
shimniok | 0:a6a169de725f | 264 | static inline int16_t mavlink_msg_raw_imu_get_zmag(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 265 | { |
shimniok | 0:a6a169de725f | 266 | generic_16bit r; |
shimniok | 0:a6a169de725f | 267 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:a6a169de725f | 268 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:a6a169de725f | 269 | return (int16_t)r.s; |
shimniok | 0:a6a169de725f | 270 | } |
shimniok | 0:a6a169de725f | 271 | |
shimniok | 0:a6a169de725f | 272 | /** |
shimniok | 0:a6a169de725f | 273 | * @brief Decode a raw_imu message into a struct |
shimniok | 0:a6a169de725f | 274 | * |
shimniok | 0:a6a169de725f | 275 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 276 | * @param raw_imu C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 277 | */ |
shimniok | 0:a6a169de725f | 278 | static inline void mavlink_msg_raw_imu_decode(const mavlink_message_t* msg, mavlink_raw_imu_t* raw_imu) |
shimniok | 0:a6a169de725f | 279 | { |
shimniok | 0:a6a169de725f | 280 | raw_imu->usec = mavlink_msg_raw_imu_get_usec(msg); |
shimniok | 0:a6a169de725f | 281 | raw_imu->xacc = mavlink_msg_raw_imu_get_xacc(msg); |
shimniok | 0:a6a169de725f | 282 | raw_imu->yacc = mavlink_msg_raw_imu_get_yacc(msg); |
shimniok | 0:a6a169de725f | 283 | raw_imu->zacc = mavlink_msg_raw_imu_get_zacc(msg); |
shimniok | 0:a6a169de725f | 284 | raw_imu->xgyro = mavlink_msg_raw_imu_get_xgyro(msg); |
shimniok | 0:a6a169de725f | 285 | raw_imu->ygyro = mavlink_msg_raw_imu_get_ygyro(msg); |
shimniok | 0:a6a169de725f | 286 | raw_imu->zgyro = mavlink_msg_raw_imu_get_zgyro(msg); |
shimniok | 0:a6a169de725f | 287 | raw_imu->xmag = mavlink_msg_raw_imu_get_xmag(msg); |
shimniok | 0:a6a169de725f | 288 | raw_imu->ymag = mavlink_msg_raw_imu_get_ymag(msg); |
shimniok | 0:a6a169de725f | 289 | raw_imu->zmag = mavlink_msg_raw_imu_get_zmag(msg); |
shimniok | 0:a6a169de725f | 290 | } |