Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/common/mavlink_msg_scaled_imu.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE SCALED_IMU PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_SCALED_IMU 26 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_scaled_imu_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint64_t usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 8 | int16_t xacc; ///< X acceleration (mg) |
shimniok | 0:826c6171fc1b | 9 | int16_t yacc; ///< Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 10 | int16_t zacc; ///< Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 11 | int16_t xgyro; ///< Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 12 | int16_t ygyro; ///< Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 13 | int16_t zgyro; ///< Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 14 | int16_t xmag; ///< X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 15 | int16_t ymag; ///< Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 16 | int16_t zmag; ///< Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 17 | |
shimniok | 0:826c6171fc1b | 18 | } mavlink_scaled_imu_t; |
shimniok | 0:826c6171fc1b | 19 | |
shimniok | 0:826c6171fc1b | 20 | |
shimniok | 0:826c6171fc1b | 21 | |
shimniok | 0:826c6171fc1b | 22 | /** |
shimniok | 0:826c6171fc1b | 23 | * @brief Pack a scaled_imu message |
shimniok | 0:826c6171fc1b | 24 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 25 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 26 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 27 | * |
shimniok | 0:826c6171fc1b | 28 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 29 | * @param xacc X acceleration (mg) |
shimniok | 0:826c6171fc1b | 30 | * @param yacc Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 31 | * @param zacc Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 32 | * @param xgyro Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 33 | * @param ygyro Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 34 | * @param zgyro Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 35 | * @param xmag X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 36 | * @param ymag Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 37 | * @param zmag Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 38 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 39 | */ |
shimniok | 0:826c6171fc1b | 40 | static inline uint16_t mavlink_msg_scaled_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:826c6171fc1b | 41 | { |
shimniok | 0:826c6171fc1b | 42 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 43 | msg->msgid = MAVLINK_MSG_ID_SCALED_IMU; |
shimniok | 0:826c6171fc1b | 44 | |
shimniok | 0:826c6171fc1b | 45 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 46 | i += put_int16_t_by_index(xacc, i, msg->payload); // X acceleration (mg) |
shimniok | 0:826c6171fc1b | 47 | i += put_int16_t_by_index(yacc, i, msg->payload); // Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 48 | i += put_int16_t_by_index(zacc, i, msg->payload); // Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 49 | i += put_int16_t_by_index(xgyro, i, msg->payload); // Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 50 | i += put_int16_t_by_index(ygyro, i, msg->payload); // Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 51 | i += put_int16_t_by_index(zgyro, i, msg->payload); // Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 52 | i += put_int16_t_by_index(xmag, i, msg->payload); // X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 53 | i += put_int16_t_by_index(ymag, i, msg->payload); // Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 54 | i += put_int16_t_by_index(zmag, i, msg->payload); // Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 55 | |
shimniok | 0:826c6171fc1b | 56 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 57 | } |
shimniok | 0:826c6171fc1b | 58 | |
shimniok | 0:826c6171fc1b | 59 | /** |
shimniok | 0:826c6171fc1b | 60 | * @brief Pack a scaled_imu message |
shimniok | 0:826c6171fc1b | 61 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 62 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 63 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 64 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 65 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 66 | * @param xacc X acceleration (mg) |
shimniok | 0:826c6171fc1b | 67 | * @param yacc Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 68 | * @param zacc Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 69 | * @param xgyro Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 70 | * @param ygyro Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 71 | * @param zgyro Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 72 | * @param xmag X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 73 | * @param ymag Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 74 | * @param zmag Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 75 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 76 | */ |
shimniok | 0:826c6171fc1b | 77 | static inline uint16_t mavlink_msg_scaled_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:826c6171fc1b | 78 | { |
shimniok | 0:826c6171fc1b | 79 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 80 | msg->msgid = MAVLINK_MSG_ID_SCALED_IMU; |
shimniok | 0:826c6171fc1b | 81 | |
shimniok | 0:826c6171fc1b | 82 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 83 | i += put_int16_t_by_index(xacc, i, msg->payload); // X acceleration (mg) |
shimniok | 0:826c6171fc1b | 84 | i += put_int16_t_by_index(yacc, i, msg->payload); // Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 85 | i += put_int16_t_by_index(zacc, i, msg->payload); // Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 86 | i += put_int16_t_by_index(xgyro, i, msg->payload); // Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 87 | i += put_int16_t_by_index(ygyro, i, msg->payload); // Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 88 | i += put_int16_t_by_index(zgyro, i, msg->payload); // Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 89 | i += put_int16_t_by_index(xmag, i, msg->payload); // X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 90 | i += put_int16_t_by_index(ymag, i, msg->payload); // Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 91 | i += put_int16_t_by_index(zmag, i, msg->payload); // Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 92 | |
shimniok | 0:826c6171fc1b | 93 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 94 | } |
shimniok | 0:826c6171fc1b | 95 | |
shimniok | 0:826c6171fc1b | 96 | /** |
shimniok | 0:826c6171fc1b | 97 | * @brief Encode a scaled_imu struct into a message |
shimniok | 0:826c6171fc1b | 98 | * |
shimniok | 0:826c6171fc1b | 99 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 100 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 101 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 102 | * @param scaled_imu C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 103 | */ |
shimniok | 0:826c6171fc1b | 104 | static inline uint16_t mavlink_msg_scaled_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_scaled_imu_t* scaled_imu) |
shimniok | 0:826c6171fc1b | 105 | { |
shimniok | 0:826c6171fc1b | 106 | return mavlink_msg_scaled_imu_pack(system_id, component_id, msg, scaled_imu->usec, scaled_imu->xacc, scaled_imu->yacc, scaled_imu->zacc, scaled_imu->xgyro, scaled_imu->ygyro, scaled_imu->zgyro, scaled_imu->xmag, scaled_imu->ymag, scaled_imu->zmag); |
shimniok | 0:826c6171fc1b | 107 | } |
shimniok | 0:826c6171fc1b | 108 | |
shimniok | 0:826c6171fc1b | 109 | /** |
shimniok | 0:826c6171fc1b | 110 | * @brief Send a scaled_imu message |
shimniok | 0:826c6171fc1b | 111 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 112 | * |
shimniok | 0:826c6171fc1b | 113 | * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 114 | * @param xacc X acceleration (mg) |
shimniok | 0:826c6171fc1b | 115 | * @param yacc Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 116 | * @param zacc Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 117 | * @param xgyro Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 118 | * @param ygyro Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 119 | * @param zgyro Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 120 | * @param xmag X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 121 | * @param ymag Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 122 | * @param zmag Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 123 | */ |
shimniok | 0:826c6171fc1b | 124 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 125 | |
shimniok | 0:826c6171fc1b | 126 | static inline void mavlink_msg_scaled_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:826c6171fc1b | 127 | { |
shimniok | 0:826c6171fc1b | 128 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 129 | mavlink_msg_scaled_imu_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, xacc, yacc, zacc, xgyro, ygyro, zgyro, xmag, ymag, zmag); |
shimniok | 0:826c6171fc1b | 130 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 131 | } |
shimniok | 0:826c6171fc1b | 132 | |
shimniok | 0:826c6171fc1b | 133 | #endif |
shimniok | 0:826c6171fc1b | 134 | // MESSAGE SCALED_IMU UNPACKING |
shimniok | 0:826c6171fc1b | 135 | |
shimniok | 0:826c6171fc1b | 136 | /** |
shimniok | 0:826c6171fc1b | 137 | * @brief Get field usec from scaled_imu message |
shimniok | 0:826c6171fc1b | 138 | * |
shimniok | 0:826c6171fc1b | 139 | * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot) |
shimniok | 0:826c6171fc1b | 140 | */ |
shimniok | 0:826c6171fc1b | 141 | static inline uint64_t mavlink_msg_scaled_imu_get_usec(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 142 | { |
shimniok | 0:826c6171fc1b | 143 | generic_64bit r; |
shimniok | 0:826c6171fc1b | 144 | r.b[7] = (msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 145 | r.b[6] = (msg->payload)[1]; |
shimniok | 0:826c6171fc1b | 146 | r.b[5] = (msg->payload)[2]; |
shimniok | 0:826c6171fc1b | 147 | r.b[4] = (msg->payload)[3]; |
shimniok | 0:826c6171fc1b | 148 | r.b[3] = (msg->payload)[4]; |
shimniok | 0:826c6171fc1b | 149 | r.b[2] = (msg->payload)[5]; |
shimniok | 0:826c6171fc1b | 150 | r.b[1] = (msg->payload)[6]; |
shimniok | 0:826c6171fc1b | 151 | r.b[0] = (msg->payload)[7]; |
shimniok | 0:826c6171fc1b | 152 | return (uint64_t)r.ll; |
shimniok | 0:826c6171fc1b | 153 | } |
shimniok | 0:826c6171fc1b | 154 | |
shimniok | 0:826c6171fc1b | 155 | /** |
shimniok | 0:826c6171fc1b | 156 | * @brief Get field xacc from scaled_imu message |
shimniok | 0:826c6171fc1b | 157 | * |
shimniok | 0:826c6171fc1b | 158 | * @return X acceleration (mg) |
shimniok | 0:826c6171fc1b | 159 | */ |
shimniok | 0:826c6171fc1b | 160 | static inline int16_t mavlink_msg_scaled_imu_get_xacc(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 161 | { |
shimniok | 0:826c6171fc1b | 162 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 163 | r.b[1] = (msg->payload+sizeof(uint64_t))[0]; |
shimniok | 0:826c6171fc1b | 164 | r.b[0] = (msg->payload+sizeof(uint64_t))[1]; |
shimniok | 0:826c6171fc1b | 165 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 166 | } |
shimniok | 0:826c6171fc1b | 167 | |
shimniok | 0:826c6171fc1b | 168 | /** |
shimniok | 0:826c6171fc1b | 169 | * @brief Get field yacc from scaled_imu message |
shimniok | 0:826c6171fc1b | 170 | * |
shimniok | 0:826c6171fc1b | 171 | * @return Y acceleration (mg) |
shimniok | 0:826c6171fc1b | 172 | */ |
shimniok | 0:826c6171fc1b | 173 | static inline int16_t mavlink_msg_scaled_imu_get_yacc(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 174 | { |
shimniok | 0:826c6171fc1b | 175 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 176 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 177 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 178 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 179 | } |
shimniok | 0:826c6171fc1b | 180 | |
shimniok | 0:826c6171fc1b | 181 | /** |
shimniok | 0:826c6171fc1b | 182 | * @brief Get field zacc from scaled_imu message |
shimniok | 0:826c6171fc1b | 183 | * |
shimniok | 0:826c6171fc1b | 184 | * @return Z acceleration (mg) |
shimniok | 0:826c6171fc1b | 185 | */ |
shimniok | 0:826c6171fc1b | 186 | static inline int16_t mavlink_msg_scaled_imu_get_zacc(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 187 | { |
shimniok | 0:826c6171fc1b | 188 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 189 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 190 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 191 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 192 | } |
shimniok | 0:826c6171fc1b | 193 | |
shimniok | 0:826c6171fc1b | 194 | /** |
shimniok | 0:826c6171fc1b | 195 | * @brief Get field xgyro from scaled_imu message |
shimniok | 0:826c6171fc1b | 196 | * |
shimniok | 0:826c6171fc1b | 197 | * @return Angular speed around X axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 198 | */ |
shimniok | 0:826c6171fc1b | 199 | static inline int16_t mavlink_msg_scaled_imu_get_xgyro(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 200 | { |
shimniok | 0:826c6171fc1b | 201 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 202 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 203 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 204 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 205 | } |
shimniok | 0:826c6171fc1b | 206 | |
shimniok | 0:826c6171fc1b | 207 | /** |
shimniok | 0:826c6171fc1b | 208 | * @brief Get field ygyro from scaled_imu message |
shimniok | 0:826c6171fc1b | 209 | * |
shimniok | 0:826c6171fc1b | 210 | * @return Angular speed around Y axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 211 | */ |
shimniok | 0:826c6171fc1b | 212 | static inline int16_t mavlink_msg_scaled_imu_get_ygyro(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 213 | { |
shimniok | 0:826c6171fc1b | 214 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 215 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 216 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 217 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 218 | } |
shimniok | 0:826c6171fc1b | 219 | |
shimniok | 0:826c6171fc1b | 220 | /** |
shimniok | 0:826c6171fc1b | 221 | * @brief Get field zgyro from scaled_imu message |
shimniok | 0:826c6171fc1b | 222 | * |
shimniok | 0:826c6171fc1b | 223 | * @return Angular speed around Z axis (millirad /sec) |
shimniok | 0:826c6171fc1b | 224 | */ |
shimniok | 0:826c6171fc1b | 225 | static inline int16_t mavlink_msg_scaled_imu_get_zgyro(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 226 | { |
shimniok | 0:826c6171fc1b | 227 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 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:826c6171fc1b | 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:826c6171fc1b | 230 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 231 | } |
shimniok | 0:826c6171fc1b | 232 | |
shimniok | 0:826c6171fc1b | 233 | /** |
shimniok | 0:826c6171fc1b | 234 | * @brief Get field xmag from scaled_imu message |
shimniok | 0:826c6171fc1b | 235 | * |
shimniok | 0:826c6171fc1b | 236 | * @return X Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 237 | */ |
shimniok | 0:826c6171fc1b | 238 | static inline int16_t mavlink_msg_scaled_imu_get_xmag(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 239 | { |
shimniok | 0:826c6171fc1b | 240 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 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:826c6171fc1b | 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:826c6171fc1b | 243 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 244 | } |
shimniok | 0:826c6171fc1b | 245 | |
shimniok | 0:826c6171fc1b | 246 | /** |
shimniok | 0:826c6171fc1b | 247 | * @brief Get field ymag from scaled_imu message |
shimniok | 0:826c6171fc1b | 248 | * |
shimniok | 0:826c6171fc1b | 249 | * @return Y Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 250 | */ |
shimniok | 0:826c6171fc1b | 251 | static inline int16_t mavlink_msg_scaled_imu_get_ymag(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 252 | { |
shimniok | 0:826c6171fc1b | 253 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 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:826c6171fc1b | 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:826c6171fc1b | 256 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 257 | } |
shimniok | 0:826c6171fc1b | 258 | |
shimniok | 0:826c6171fc1b | 259 | /** |
shimniok | 0:826c6171fc1b | 260 | * @brief Get field zmag from scaled_imu message |
shimniok | 0:826c6171fc1b | 261 | * |
shimniok | 0:826c6171fc1b | 262 | * @return Z Magnetic field (milli tesla) |
shimniok | 0:826c6171fc1b | 263 | */ |
shimniok | 0:826c6171fc1b | 264 | static inline int16_t mavlink_msg_scaled_imu_get_zmag(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 265 | { |
shimniok | 0:826c6171fc1b | 266 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 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:826c6171fc1b | 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:826c6171fc1b | 269 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 270 | } |
shimniok | 0:826c6171fc1b | 271 | |
shimniok | 0:826c6171fc1b | 272 | /** |
shimniok | 0:826c6171fc1b | 273 | * @brief Decode a scaled_imu message into a struct |
shimniok | 0:826c6171fc1b | 274 | * |
shimniok | 0:826c6171fc1b | 275 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 276 | * @param scaled_imu C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 277 | */ |
shimniok | 0:826c6171fc1b | 278 | static inline void mavlink_msg_scaled_imu_decode(const mavlink_message_t* msg, mavlink_scaled_imu_t* scaled_imu) |
shimniok | 0:826c6171fc1b | 279 | { |
shimniok | 0:826c6171fc1b | 280 | scaled_imu->usec = mavlink_msg_scaled_imu_get_usec(msg); |
shimniok | 0:826c6171fc1b | 281 | scaled_imu->xacc = mavlink_msg_scaled_imu_get_xacc(msg); |
shimniok | 0:826c6171fc1b | 282 | scaled_imu->yacc = mavlink_msg_scaled_imu_get_yacc(msg); |
shimniok | 0:826c6171fc1b | 283 | scaled_imu->zacc = mavlink_msg_scaled_imu_get_zacc(msg); |
shimniok | 0:826c6171fc1b | 284 | scaled_imu->xgyro = mavlink_msg_scaled_imu_get_xgyro(msg); |
shimniok | 0:826c6171fc1b | 285 | scaled_imu->ygyro = mavlink_msg_scaled_imu_get_ygyro(msg); |
shimniok | 0:826c6171fc1b | 286 | scaled_imu->zgyro = mavlink_msg_scaled_imu_get_zgyro(msg); |
shimniok | 0:826c6171fc1b | 287 | scaled_imu->xmag = mavlink_msg_scaled_imu_get_xmag(msg); |
shimniok | 0:826c6171fc1b | 288 | scaled_imu->ymag = mavlink_msg_scaled_imu_get_ymag(msg); |
shimniok | 0:826c6171fc1b | 289 | scaled_imu->zmag = mavlink_msg_scaled_imu_get_zmag(msg); |
shimniok | 0:826c6171fc1b | 290 | } |