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