Mavlink Messages for Emaxx Nav Board
Dependents: Madpulse_Speed_Control_temp Madpulse_Speed_Control_Students
emaxx_board/mavlink_msg_attitude_quaternion.h@0:bb2cacd02294, 2017-01-20 (annotated)
- Committer:
- jdawkins
- Date:
- Fri Jan 20 13:20:58 2017 +0000
- Revision:
- 0:bb2cacd02294
Initial Commit of Mavlink Messages for Emaxx Board custom messages for decawave ranging and bno055;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jdawkins | 0:bb2cacd02294 | 1 | #pragma once |
jdawkins | 0:bb2cacd02294 | 2 | // MESSAGE ATTITUDE_QUATERNION PACKING |
jdawkins | 0:bb2cacd02294 | 3 | |
jdawkins | 0:bb2cacd02294 | 4 | #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION 31 |
jdawkins | 0:bb2cacd02294 | 5 | |
jdawkins | 0:bb2cacd02294 | 6 | MAVPACKED( |
jdawkins | 0:bb2cacd02294 | 7 | typedef struct __mavlink_attitude_quaternion_t { |
jdawkins | 0:bb2cacd02294 | 8 | uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/ |
jdawkins | 0:bb2cacd02294 | 9 | float q1; /*< Quaternion component 1, w (1 in null-rotation)*/ |
jdawkins | 0:bb2cacd02294 | 10 | float q2; /*< Quaternion component 2, x (0 in null-rotation)*/ |
jdawkins | 0:bb2cacd02294 | 11 | float q3; /*< Quaternion component 3, y (0 in null-rotation)*/ |
jdawkins | 0:bb2cacd02294 | 12 | float q4; /*< Quaternion component 4, z (0 in null-rotation)*/ |
jdawkins | 0:bb2cacd02294 | 13 | float rollspeed; /*< Roll angular speed (rad/s)*/ |
jdawkins | 0:bb2cacd02294 | 14 | float pitchspeed; /*< Pitch angular speed (rad/s)*/ |
jdawkins | 0:bb2cacd02294 | 15 | float yawspeed; /*< Yaw angular speed (rad/s)*/ |
jdawkins | 0:bb2cacd02294 | 16 | }) mavlink_attitude_quaternion_t; |
jdawkins | 0:bb2cacd02294 | 17 | |
jdawkins | 0:bb2cacd02294 | 18 | #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN 32 |
jdawkins | 0:bb2cacd02294 | 19 | #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN 32 |
jdawkins | 0:bb2cacd02294 | 20 | #define MAVLINK_MSG_ID_31_LEN 32 |
jdawkins | 0:bb2cacd02294 | 21 | #define MAVLINK_MSG_ID_31_MIN_LEN 32 |
jdawkins | 0:bb2cacd02294 | 22 | |
jdawkins | 0:bb2cacd02294 | 23 | #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC 246 |
jdawkins | 0:bb2cacd02294 | 24 | #define MAVLINK_MSG_ID_31_CRC 246 |
jdawkins | 0:bb2cacd02294 | 25 | |
jdawkins | 0:bb2cacd02294 | 26 | |
jdawkins | 0:bb2cacd02294 | 27 | |
jdawkins | 0:bb2cacd02294 | 28 | #if MAVLINK_COMMAND_24BIT |
jdawkins | 0:bb2cacd02294 | 29 | #define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \ |
jdawkins | 0:bb2cacd02294 | 30 | 31, \ |
jdawkins | 0:bb2cacd02294 | 31 | "ATTITUDE_QUATERNION", \ |
jdawkins | 0:bb2cacd02294 | 32 | 8, \ |
jdawkins | 0:bb2cacd02294 | 33 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \ |
jdawkins | 0:bb2cacd02294 | 34 | { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \ |
jdawkins | 0:bb2cacd02294 | 35 | { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \ |
jdawkins | 0:bb2cacd02294 | 36 | { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \ |
jdawkins | 0:bb2cacd02294 | 37 | { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \ |
jdawkins | 0:bb2cacd02294 | 38 | { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 39 | { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 40 | { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 41 | } \ |
jdawkins | 0:bb2cacd02294 | 42 | } |
jdawkins | 0:bb2cacd02294 | 43 | #else |
jdawkins | 0:bb2cacd02294 | 44 | #define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \ |
jdawkins | 0:bb2cacd02294 | 45 | "ATTITUDE_QUATERNION", \ |
jdawkins | 0:bb2cacd02294 | 46 | 8, \ |
jdawkins | 0:bb2cacd02294 | 47 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \ |
jdawkins | 0:bb2cacd02294 | 48 | { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \ |
jdawkins | 0:bb2cacd02294 | 49 | { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \ |
jdawkins | 0:bb2cacd02294 | 50 | { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \ |
jdawkins | 0:bb2cacd02294 | 51 | { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \ |
jdawkins | 0:bb2cacd02294 | 52 | { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 53 | { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 54 | { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \ |
jdawkins | 0:bb2cacd02294 | 55 | } \ |
jdawkins | 0:bb2cacd02294 | 56 | } |
jdawkins | 0:bb2cacd02294 | 57 | #endif |
jdawkins | 0:bb2cacd02294 | 58 | |
jdawkins | 0:bb2cacd02294 | 59 | /** |
jdawkins | 0:bb2cacd02294 | 60 | * @brief Pack a attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 61 | * @param system_id ID of this system |
jdawkins | 0:bb2cacd02294 | 62 | * @param component_id ID of this component (e.g. 200 for IMU) |
jdawkins | 0:bb2cacd02294 | 63 | * @param msg The MAVLink message to compress the data into |
jdawkins | 0:bb2cacd02294 | 64 | * |
jdawkins | 0:bb2cacd02294 | 65 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
jdawkins | 0:bb2cacd02294 | 66 | * @param q1 Quaternion component 1, w (1 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 67 | * @param q2 Quaternion component 2, x (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 68 | * @param q3 Quaternion component 3, y (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 69 | * @param q4 Quaternion component 4, z (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 70 | * @param rollspeed Roll angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 71 | * @param pitchspeed Pitch angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 72 | * @param yawspeed Yaw angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 73 | * @return length of the message in bytes (excluding serial stream start sign) |
jdawkins | 0:bb2cacd02294 | 74 | */ |
jdawkins | 0:bb2cacd02294 | 75 | static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
jdawkins | 0:bb2cacd02294 | 76 | uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed) |
jdawkins | 0:bb2cacd02294 | 77 | { |
jdawkins | 0:bb2cacd02294 | 78 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 79 | char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN]; |
jdawkins | 0:bb2cacd02294 | 80 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
jdawkins | 0:bb2cacd02294 | 81 | _mav_put_float(buf, 4, q1); |
jdawkins | 0:bb2cacd02294 | 82 | _mav_put_float(buf, 8, q2); |
jdawkins | 0:bb2cacd02294 | 83 | _mav_put_float(buf, 12, q3); |
jdawkins | 0:bb2cacd02294 | 84 | _mav_put_float(buf, 16, q4); |
jdawkins | 0:bb2cacd02294 | 85 | _mav_put_float(buf, 20, rollspeed); |
jdawkins | 0:bb2cacd02294 | 86 | _mav_put_float(buf, 24, pitchspeed); |
jdawkins | 0:bb2cacd02294 | 87 | _mav_put_float(buf, 28, yawspeed); |
jdawkins | 0:bb2cacd02294 | 88 | |
jdawkins | 0:bb2cacd02294 | 89 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); |
jdawkins | 0:bb2cacd02294 | 90 | #else |
jdawkins | 0:bb2cacd02294 | 91 | mavlink_attitude_quaternion_t packet; |
jdawkins | 0:bb2cacd02294 | 92 | packet.time_boot_ms = time_boot_ms; |
jdawkins | 0:bb2cacd02294 | 93 | packet.q1 = q1; |
jdawkins | 0:bb2cacd02294 | 94 | packet.q2 = q2; |
jdawkins | 0:bb2cacd02294 | 95 | packet.q3 = q3; |
jdawkins | 0:bb2cacd02294 | 96 | packet.q4 = q4; |
jdawkins | 0:bb2cacd02294 | 97 | packet.rollspeed = rollspeed; |
jdawkins | 0:bb2cacd02294 | 98 | packet.pitchspeed = pitchspeed; |
jdawkins | 0:bb2cacd02294 | 99 | packet.yawspeed = yawspeed; |
jdawkins | 0:bb2cacd02294 | 100 | |
jdawkins | 0:bb2cacd02294 | 101 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); |
jdawkins | 0:bb2cacd02294 | 102 | #endif |
jdawkins | 0:bb2cacd02294 | 103 | |
jdawkins | 0:bb2cacd02294 | 104 | msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION; |
jdawkins | 0:bb2cacd02294 | 105 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 106 | } |
jdawkins | 0:bb2cacd02294 | 107 | |
jdawkins | 0:bb2cacd02294 | 108 | /** |
jdawkins | 0:bb2cacd02294 | 109 | * @brief Pack a attitude_quaternion message on a channel |
jdawkins | 0:bb2cacd02294 | 110 | * @param system_id ID of this system |
jdawkins | 0:bb2cacd02294 | 111 | * @param component_id ID of this component (e.g. 200 for IMU) |
jdawkins | 0:bb2cacd02294 | 112 | * @param chan The MAVLink channel this message will be sent over |
jdawkins | 0:bb2cacd02294 | 113 | * @param msg The MAVLink message to compress the data into |
jdawkins | 0:bb2cacd02294 | 114 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
jdawkins | 0:bb2cacd02294 | 115 | * @param q1 Quaternion component 1, w (1 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 116 | * @param q2 Quaternion component 2, x (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 117 | * @param q3 Quaternion component 3, y (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 118 | * @param q4 Quaternion component 4, z (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 119 | * @param rollspeed Roll angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 120 | * @param pitchspeed Pitch angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 121 | * @param yawspeed Yaw angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 122 | * @return length of the message in bytes (excluding serial stream start sign) |
jdawkins | 0:bb2cacd02294 | 123 | */ |
jdawkins | 0:bb2cacd02294 | 124 | static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
jdawkins | 0:bb2cacd02294 | 125 | mavlink_message_t* msg, |
jdawkins | 0:bb2cacd02294 | 126 | uint32_t time_boot_ms,float q1,float q2,float q3,float q4,float rollspeed,float pitchspeed,float yawspeed) |
jdawkins | 0:bb2cacd02294 | 127 | { |
jdawkins | 0:bb2cacd02294 | 128 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 129 | char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN]; |
jdawkins | 0:bb2cacd02294 | 130 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
jdawkins | 0:bb2cacd02294 | 131 | _mav_put_float(buf, 4, q1); |
jdawkins | 0:bb2cacd02294 | 132 | _mav_put_float(buf, 8, q2); |
jdawkins | 0:bb2cacd02294 | 133 | _mav_put_float(buf, 12, q3); |
jdawkins | 0:bb2cacd02294 | 134 | _mav_put_float(buf, 16, q4); |
jdawkins | 0:bb2cacd02294 | 135 | _mav_put_float(buf, 20, rollspeed); |
jdawkins | 0:bb2cacd02294 | 136 | _mav_put_float(buf, 24, pitchspeed); |
jdawkins | 0:bb2cacd02294 | 137 | _mav_put_float(buf, 28, yawspeed); |
jdawkins | 0:bb2cacd02294 | 138 | |
jdawkins | 0:bb2cacd02294 | 139 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); |
jdawkins | 0:bb2cacd02294 | 140 | #else |
jdawkins | 0:bb2cacd02294 | 141 | mavlink_attitude_quaternion_t packet; |
jdawkins | 0:bb2cacd02294 | 142 | packet.time_boot_ms = time_boot_ms; |
jdawkins | 0:bb2cacd02294 | 143 | packet.q1 = q1; |
jdawkins | 0:bb2cacd02294 | 144 | packet.q2 = q2; |
jdawkins | 0:bb2cacd02294 | 145 | packet.q3 = q3; |
jdawkins | 0:bb2cacd02294 | 146 | packet.q4 = q4; |
jdawkins | 0:bb2cacd02294 | 147 | packet.rollspeed = rollspeed; |
jdawkins | 0:bb2cacd02294 | 148 | packet.pitchspeed = pitchspeed; |
jdawkins | 0:bb2cacd02294 | 149 | packet.yawspeed = yawspeed; |
jdawkins | 0:bb2cacd02294 | 150 | |
jdawkins | 0:bb2cacd02294 | 151 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); |
jdawkins | 0:bb2cacd02294 | 152 | #endif |
jdawkins | 0:bb2cacd02294 | 153 | |
jdawkins | 0:bb2cacd02294 | 154 | msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION; |
jdawkins | 0:bb2cacd02294 | 155 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 156 | } |
jdawkins | 0:bb2cacd02294 | 157 | |
jdawkins | 0:bb2cacd02294 | 158 | /** |
jdawkins | 0:bb2cacd02294 | 159 | * @brief Encode a attitude_quaternion struct |
jdawkins | 0:bb2cacd02294 | 160 | * |
jdawkins | 0:bb2cacd02294 | 161 | * @param system_id ID of this system |
jdawkins | 0:bb2cacd02294 | 162 | * @param component_id ID of this component (e.g. 200 for IMU) |
jdawkins | 0:bb2cacd02294 | 163 | * @param msg The MAVLink message to compress the data into |
jdawkins | 0:bb2cacd02294 | 164 | * @param attitude_quaternion C-struct to read the message contents from |
jdawkins | 0:bb2cacd02294 | 165 | */ |
jdawkins | 0:bb2cacd02294 | 166 | static inline uint16_t mavlink_msg_attitude_quaternion_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion) |
jdawkins | 0:bb2cacd02294 | 167 | { |
jdawkins | 0:bb2cacd02294 | 168 | return mavlink_msg_attitude_quaternion_pack(system_id, component_id, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed); |
jdawkins | 0:bb2cacd02294 | 169 | } |
jdawkins | 0:bb2cacd02294 | 170 | |
jdawkins | 0:bb2cacd02294 | 171 | /** |
jdawkins | 0:bb2cacd02294 | 172 | * @brief Encode a attitude_quaternion struct on a channel |
jdawkins | 0:bb2cacd02294 | 173 | * |
jdawkins | 0:bb2cacd02294 | 174 | * @param system_id ID of this system |
jdawkins | 0:bb2cacd02294 | 175 | * @param component_id ID of this component (e.g. 200 for IMU) |
jdawkins | 0:bb2cacd02294 | 176 | * @param chan The MAVLink channel this message will be sent over |
jdawkins | 0:bb2cacd02294 | 177 | * @param msg The MAVLink message to compress the data into |
jdawkins | 0:bb2cacd02294 | 178 | * @param attitude_quaternion C-struct to read the message contents from |
jdawkins | 0:bb2cacd02294 | 179 | */ |
jdawkins | 0:bb2cacd02294 | 180 | static inline uint16_t mavlink_msg_attitude_quaternion_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion) |
jdawkins | 0:bb2cacd02294 | 181 | { |
jdawkins | 0:bb2cacd02294 | 182 | return mavlink_msg_attitude_quaternion_pack_chan(system_id, component_id, chan, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed); |
jdawkins | 0:bb2cacd02294 | 183 | } |
jdawkins | 0:bb2cacd02294 | 184 | |
jdawkins | 0:bb2cacd02294 | 185 | /** |
jdawkins | 0:bb2cacd02294 | 186 | * @brief Send a attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 187 | * @param chan MAVLink channel to send the message |
jdawkins | 0:bb2cacd02294 | 188 | * |
jdawkins | 0:bb2cacd02294 | 189 | * @param time_boot_ms Timestamp (milliseconds since system boot) |
jdawkins | 0:bb2cacd02294 | 190 | * @param q1 Quaternion component 1, w (1 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 191 | * @param q2 Quaternion component 2, x (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 192 | * @param q3 Quaternion component 3, y (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 193 | * @param q4 Quaternion component 4, z (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 194 | * @param rollspeed Roll angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 195 | * @param pitchspeed Pitch angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 196 | * @param yawspeed Yaw angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 197 | */ |
jdawkins | 0:bb2cacd02294 | 198 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
jdawkins | 0:bb2cacd02294 | 199 | |
jdawkins | 0:bb2cacd02294 | 200 | static inline void mavlink_msg_attitude_quaternion_send(mavlink_channel_t chan, uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed) |
jdawkins | 0:bb2cacd02294 | 201 | { |
jdawkins | 0:bb2cacd02294 | 202 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 203 | char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN]; |
jdawkins | 0:bb2cacd02294 | 204 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
jdawkins | 0:bb2cacd02294 | 205 | _mav_put_float(buf, 4, q1); |
jdawkins | 0:bb2cacd02294 | 206 | _mav_put_float(buf, 8, q2); |
jdawkins | 0:bb2cacd02294 | 207 | _mav_put_float(buf, 12, q3); |
jdawkins | 0:bb2cacd02294 | 208 | _mav_put_float(buf, 16, q4); |
jdawkins | 0:bb2cacd02294 | 209 | _mav_put_float(buf, 20, rollspeed); |
jdawkins | 0:bb2cacd02294 | 210 | _mav_put_float(buf, 24, pitchspeed); |
jdawkins | 0:bb2cacd02294 | 211 | _mav_put_float(buf, 28, yawspeed); |
jdawkins | 0:bb2cacd02294 | 212 | |
jdawkins | 0:bb2cacd02294 | 213 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 214 | #else |
jdawkins | 0:bb2cacd02294 | 215 | mavlink_attitude_quaternion_t packet; |
jdawkins | 0:bb2cacd02294 | 216 | packet.time_boot_ms = time_boot_ms; |
jdawkins | 0:bb2cacd02294 | 217 | packet.q1 = q1; |
jdawkins | 0:bb2cacd02294 | 218 | packet.q2 = q2; |
jdawkins | 0:bb2cacd02294 | 219 | packet.q3 = q3; |
jdawkins | 0:bb2cacd02294 | 220 | packet.q4 = q4; |
jdawkins | 0:bb2cacd02294 | 221 | packet.rollspeed = rollspeed; |
jdawkins | 0:bb2cacd02294 | 222 | packet.pitchspeed = pitchspeed; |
jdawkins | 0:bb2cacd02294 | 223 | packet.yawspeed = yawspeed; |
jdawkins | 0:bb2cacd02294 | 224 | |
jdawkins | 0:bb2cacd02294 | 225 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)&packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 226 | #endif |
jdawkins | 0:bb2cacd02294 | 227 | } |
jdawkins | 0:bb2cacd02294 | 228 | |
jdawkins | 0:bb2cacd02294 | 229 | /** |
jdawkins | 0:bb2cacd02294 | 230 | * @brief Send a attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 231 | * @param chan MAVLink channel to send the message |
jdawkins | 0:bb2cacd02294 | 232 | * @param struct The MAVLink struct to serialize |
jdawkins | 0:bb2cacd02294 | 233 | */ |
jdawkins | 0:bb2cacd02294 | 234 | static inline void mavlink_msg_attitude_quaternion_send_struct(mavlink_channel_t chan, const mavlink_attitude_quaternion_t* attitude_quaternion) |
jdawkins | 0:bb2cacd02294 | 235 | { |
jdawkins | 0:bb2cacd02294 | 236 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 237 | mavlink_msg_attitude_quaternion_send(chan, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed); |
jdawkins | 0:bb2cacd02294 | 238 | #else |
jdawkins | 0:bb2cacd02294 | 239 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)attitude_quaternion, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 240 | #endif |
jdawkins | 0:bb2cacd02294 | 241 | } |
jdawkins | 0:bb2cacd02294 | 242 | |
jdawkins | 0:bb2cacd02294 | 243 | #if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN |
jdawkins | 0:bb2cacd02294 | 244 | /* |
jdawkins | 0:bb2cacd02294 | 245 | This varient of _send() can be used to save stack space by re-using |
jdawkins | 0:bb2cacd02294 | 246 | memory from the receive buffer. The caller provides a |
jdawkins | 0:bb2cacd02294 | 247 | mavlink_message_t which is the size of a full mavlink message. This |
jdawkins | 0:bb2cacd02294 | 248 | is usually the receive buffer for the channel, and allows a reply to an |
jdawkins | 0:bb2cacd02294 | 249 | incoming message with minimum stack space usage. |
jdawkins | 0:bb2cacd02294 | 250 | */ |
jdawkins | 0:bb2cacd02294 | 251 | static inline void mavlink_msg_attitude_quaternion_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed) |
jdawkins | 0:bb2cacd02294 | 252 | { |
jdawkins | 0:bb2cacd02294 | 253 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 254 | char *buf = (char *)msgbuf; |
jdawkins | 0:bb2cacd02294 | 255 | _mav_put_uint32_t(buf, 0, time_boot_ms); |
jdawkins | 0:bb2cacd02294 | 256 | _mav_put_float(buf, 4, q1); |
jdawkins | 0:bb2cacd02294 | 257 | _mav_put_float(buf, 8, q2); |
jdawkins | 0:bb2cacd02294 | 258 | _mav_put_float(buf, 12, q3); |
jdawkins | 0:bb2cacd02294 | 259 | _mav_put_float(buf, 16, q4); |
jdawkins | 0:bb2cacd02294 | 260 | _mav_put_float(buf, 20, rollspeed); |
jdawkins | 0:bb2cacd02294 | 261 | _mav_put_float(buf, 24, pitchspeed); |
jdawkins | 0:bb2cacd02294 | 262 | _mav_put_float(buf, 28, yawspeed); |
jdawkins | 0:bb2cacd02294 | 263 | |
jdawkins | 0:bb2cacd02294 | 264 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 265 | #else |
jdawkins | 0:bb2cacd02294 | 266 | mavlink_attitude_quaternion_t *packet = (mavlink_attitude_quaternion_t *)msgbuf; |
jdawkins | 0:bb2cacd02294 | 267 | packet->time_boot_ms = time_boot_ms; |
jdawkins | 0:bb2cacd02294 | 268 | packet->q1 = q1; |
jdawkins | 0:bb2cacd02294 | 269 | packet->q2 = q2; |
jdawkins | 0:bb2cacd02294 | 270 | packet->q3 = q3; |
jdawkins | 0:bb2cacd02294 | 271 | packet->q4 = q4; |
jdawkins | 0:bb2cacd02294 | 272 | packet->rollspeed = rollspeed; |
jdawkins | 0:bb2cacd02294 | 273 | packet->pitchspeed = pitchspeed; |
jdawkins | 0:bb2cacd02294 | 274 | packet->yawspeed = yawspeed; |
jdawkins | 0:bb2cacd02294 | 275 | |
jdawkins | 0:bb2cacd02294 | 276 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); |
jdawkins | 0:bb2cacd02294 | 277 | #endif |
jdawkins | 0:bb2cacd02294 | 278 | } |
jdawkins | 0:bb2cacd02294 | 279 | #endif |
jdawkins | 0:bb2cacd02294 | 280 | |
jdawkins | 0:bb2cacd02294 | 281 | #endif |
jdawkins | 0:bb2cacd02294 | 282 | |
jdawkins | 0:bb2cacd02294 | 283 | // MESSAGE ATTITUDE_QUATERNION UNPACKING |
jdawkins | 0:bb2cacd02294 | 284 | |
jdawkins | 0:bb2cacd02294 | 285 | |
jdawkins | 0:bb2cacd02294 | 286 | /** |
jdawkins | 0:bb2cacd02294 | 287 | * @brief Get field time_boot_ms from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 288 | * |
jdawkins | 0:bb2cacd02294 | 289 | * @return Timestamp (milliseconds since system boot) |
jdawkins | 0:bb2cacd02294 | 290 | */ |
jdawkins | 0:bb2cacd02294 | 291 | static inline uint32_t mavlink_msg_attitude_quaternion_get_time_boot_ms(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 292 | { |
jdawkins | 0:bb2cacd02294 | 293 | return _MAV_RETURN_uint32_t(msg, 0); |
jdawkins | 0:bb2cacd02294 | 294 | } |
jdawkins | 0:bb2cacd02294 | 295 | |
jdawkins | 0:bb2cacd02294 | 296 | /** |
jdawkins | 0:bb2cacd02294 | 297 | * @brief Get field q1 from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 298 | * |
jdawkins | 0:bb2cacd02294 | 299 | * @return Quaternion component 1, w (1 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 300 | */ |
jdawkins | 0:bb2cacd02294 | 301 | static inline float mavlink_msg_attitude_quaternion_get_q1(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 302 | { |
jdawkins | 0:bb2cacd02294 | 303 | return _MAV_RETURN_float(msg, 4); |
jdawkins | 0:bb2cacd02294 | 304 | } |
jdawkins | 0:bb2cacd02294 | 305 | |
jdawkins | 0:bb2cacd02294 | 306 | /** |
jdawkins | 0:bb2cacd02294 | 307 | * @brief Get field q2 from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 308 | * |
jdawkins | 0:bb2cacd02294 | 309 | * @return Quaternion component 2, x (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 310 | */ |
jdawkins | 0:bb2cacd02294 | 311 | static inline float mavlink_msg_attitude_quaternion_get_q2(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 312 | { |
jdawkins | 0:bb2cacd02294 | 313 | return _MAV_RETURN_float(msg, 8); |
jdawkins | 0:bb2cacd02294 | 314 | } |
jdawkins | 0:bb2cacd02294 | 315 | |
jdawkins | 0:bb2cacd02294 | 316 | /** |
jdawkins | 0:bb2cacd02294 | 317 | * @brief Get field q3 from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 318 | * |
jdawkins | 0:bb2cacd02294 | 319 | * @return Quaternion component 3, y (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 320 | */ |
jdawkins | 0:bb2cacd02294 | 321 | static inline float mavlink_msg_attitude_quaternion_get_q3(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 322 | { |
jdawkins | 0:bb2cacd02294 | 323 | return _MAV_RETURN_float(msg, 12); |
jdawkins | 0:bb2cacd02294 | 324 | } |
jdawkins | 0:bb2cacd02294 | 325 | |
jdawkins | 0:bb2cacd02294 | 326 | /** |
jdawkins | 0:bb2cacd02294 | 327 | * @brief Get field q4 from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 328 | * |
jdawkins | 0:bb2cacd02294 | 329 | * @return Quaternion component 4, z (0 in null-rotation) |
jdawkins | 0:bb2cacd02294 | 330 | */ |
jdawkins | 0:bb2cacd02294 | 331 | static inline float mavlink_msg_attitude_quaternion_get_q4(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 332 | { |
jdawkins | 0:bb2cacd02294 | 333 | return _MAV_RETURN_float(msg, 16); |
jdawkins | 0:bb2cacd02294 | 334 | } |
jdawkins | 0:bb2cacd02294 | 335 | |
jdawkins | 0:bb2cacd02294 | 336 | /** |
jdawkins | 0:bb2cacd02294 | 337 | * @brief Get field rollspeed from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 338 | * |
jdawkins | 0:bb2cacd02294 | 339 | * @return Roll angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 340 | */ |
jdawkins | 0:bb2cacd02294 | 341 | static inline float mavlink_msg_attitude_quaternion_get_rollspeed(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 342 | { |
jdawkins | 0:bb2cacd02294 | 343 | return _MAV_RETURN_float(msg, 20); |
jdawkins | 0:bb2cacd02294 | 344 | } |
jdawkins | 0:bb2cacd02294 | 345 | |
jdawkins | 0:bb2cacd02294 | 346 | /** |
jdawkins | 0:bb2cacd02294 | 347 | * @brief Get field pitchspeed from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 348 | * |
jdawkins | 0:bb2cacd02294 | 349 | * @return Pitch angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 350 | */ |
jdawkins | 0:bb2cacd02294 | 351 | static inline float mavlink_msg_attitude_quaternion_get_pitchspeed(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 352 | { |
jdawkins | 0:bb2cacd02294 | 353 | return _MAV_RETURN_float(msg, 24); |
jdawkins | 0:bb2cacd02294 | 354 | } |
jdawkins | 0:bb2cacd02294 | 355 | |
jdawkins | 0:bb2cacd02294 | 356 | /** |
jdawkins | 0:bb2cacd02294 | 357 | * @brief Get field yawspeed from attitude_quaternion message |
jdawkins | 0:bb2cacd02294 | 358 | * |
jdawkins | 0:bb2cacd02294 | 359 | * @return Yaw angular speed (rad/s) |
jdawkins | 0:bb2cacd02294 | 360 | */ |
jdawkins | 0:bb2cacd02294 | 361 | static inline float mavlink_msg_attitude_quaternion_get_yawspeed(const mavlink_message_t* msg) |
jdawkins | 0:bb2cacd02294 | 362 | { |
jdawkins | 0:bb2cacd02294 | 363 | return _MAV_RETURN_float(msg, 28); |
jdawkins | 0:bb2cacd02294 | 364 | } |
jdawkins | 0:bb2cacd02294 | 365 | |
jdawkins | 0:bb2cacd02294 | 366 | /** |
jdawkins | 0:bb2cacd02294 | 367 | * @brief Decode a attitude_quaternion message into a struct |
jdawkins | 0:bb2cacd02294 | 368 | * |
jdawkins | 0:bb2cacd02294 | 369 | * @param msg The message to decode |
jdawkins | 0:bb2cacd02294 | 370 | * @param attitude_quaternion C-struct to decode the message contents into |
jdawkins | 0:bb2cacd02294 | 371 | */ |
jdawkins | 0:bb2cacd02294 | 372 | static inline void mavlink_msg_attitude_quaternion_decode(const mavlink_message_t* msg, mavlink_attitude_quaternion_t* attitude_quaternion) |
jdawkins | 0:bb2cacd02294 | 373 | { |
jdawkins | 0:bb2cacd02294 | 374 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
jdawkins | 0:bb2cacd02294 | 375 | attitude_quaternion->time_boot_ms = mavlink_msg_attitude_quaternion_get_time_boot_ms(msg); |
jdawkins | 0:bb2cacd02294 | 376 | attitude_quaternion->q1 = mavlink_msg_attitude_quaternion_get_q1(msg); |
jdawkins | 0:bb2cacd02294 | 377 | attitude_quaternion->q2 = mavlink_msg_attitude_quaternion_get_q2(msg); |
jdawkins | 0:bb2cacd02294 | 378 | attitude_quaternion->q3 = mavlink_msg_attitude_quaternion_get_q3(msg); |
jdawkins | 0:bb2cacd02294 | 379 | attitude_quaternion->q4 = mavlink_msg_attitude_quaternion_get_q4(msg); |
jdawkins | 0:bb2cacd02294 | 380 | attitude_quaternion->rollspeed = mavlink_msg_attitude_quaternion_get_rollspeed(msg); |
jdawkins | 0:bb2cacd02294 | 381 | attitude_quaternion->pitchspeed = mavlink_msg_attitude_quaternion_get_pitchspeed(msg); |
jdawkins | 0:bb2cacd02294 | 382 | attitude_quaternion->yawspeed = mavlink_msg_attitude_quaternion_get_yawspeed(msg); |
jdawkins | 0:bb2cacd02294 | 383 | #else |
jdawkins | 0:bb2cacd02294 | 384 | uint8_t len = msg->len < MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN? msg->len : MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN; |
jdawkins | 0:bb2cacd02294 | 385 | memset(attitude_quaternion, 0, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); |
jdawkins | 0:bb2cacd02294 | 386 | memcpy(attitude_quaternion, _MAV_PAYLOAD(msg), len); |
jdawkins | 0:bb2cacd02294 | 387 | #endif |
jdawkins | 0:bb2cacd02294 | 388 | } |
jdawkins | 0:bb2cacd02294 | 389 |