1 // MESSAGE ATTITUDE PACKING
3 #define MAVLINK_MSG_ID_ATTITUDE 30
5 typedef struct __mavlink_attitude_t
{
6 uint32_t time_boot_ms
; ///< Timestamp (milliseconds since system boot)
7 float roll
; ///< Roll angle (rad)
8 float pitch
; ///< Pitch angle (rad)
9 float yaw
; ///< Yaw angle (rad)
10 float rollspeed
; ///< Roll angular speed (rad/s)
11 float pitchspeed
; ///< Pitch angular speed (rad/s)
12 float yawspeed
; ///< Yaw angular speed (rad/s)
15 #define MAVLINK_MSG_ID_ATTITUDE_LEN 28
16 #define MAVLINK_MSG_ID_30_LEN 28
19 #define MAVLINK_MESSAGE_INFO_ATTITUDE \
24 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_t, time_boot_ms) }, \
25 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_t, roll) }, \
26 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_t, pitch) }, \
27 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_t, yaw) }, \
28 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_t, rollspeed) }, \
29 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_t, pitchspeed) }, \
30 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_t, yawspeed) }, \
36 * @brief Pack a attitude message
37 * @param system_id ID of this system
38 * @param component_id ID of this component (e.g. 200 for IMU)
39 * @param msg The MAVLink message to compress the data into
41 * @param time_boot_ms Timestamp (milliseconds since system boot)
42 * @param roll Roll angle (rad)
43 * @param pitch Pitch angle (rad)
44 * @param yaw Yaw angle (rad)
45 * @param rollspeed Roll angular speed (rad/s)
46 * @param pitchspeed Pitch angular speed (rad/s)
47 * @param yawspeed Yaw angular speed (rad/s)
48 * @return length of the message in bytes (excluding serial stream start sign)
50 static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
*msg
,
51 uint32_t time_boot_ms
, float roll
, float pitch
, float yaw
, float rollspeed
, float pitchspeed
, float yawspeed
)
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
56 _mav_put_float(buf
, 4, roll
);
57 _mav_put_float(buf
, 8, pitch
);
58 _mav_put_float(buf
, 12, yaw
);
59 _mav_put_float(buf
, 16, rollspeed
);
60 _mav_put_float(buf
, 20, pitchspeed
);
61 _mav_put_float(buf
, 24, yawspeed
);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 28);
65 mavlink_attitude_t packet
;
66 packet
.time_boot_ms
= time_boot_ms
;
70 packet
.rollspeed
= rollspeed
;
71 packet
.pitchspeed
= pitchspeed
;
72 packet
.yawspeed
= yawspeed
;
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 28);
75 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
77 msg
->msgid
= MAVLINK_MSG_ID_ATTITUDE
;
78 return mavlink_finalize_message(msg
, system_id
, component_id
, 28, 39);
82 * @brief Pack a attitude message on a channel
83 * @param system_id ID of this system
84 * @param component_id ID of this component (e.g. 200 for IMU)
85 * @param chan The MAVLink channel this message was sent over
86 * @param msg The MAVLink message to compress the data into
87 * @param time_boot_ms Timestamp (milliseconds since system boot)
88 * @param roll Roll angle (rad)
89 * @param pitch Pitch angle (rad)
90 * @param yaw Yaw angle (rad)
91 * @param rollspeed Roll angular speed (rad/s)
92 * @param pitchspeed Pitch angular speed (rad/s)
93 * @param yawspeed Yaw angular speed (rad/s)
94 * @return length of the message in bytes (excluding serial stream start sign)
96 static inline uint16_t mavlink_msg_attitude_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
97 mavlink_message_t
*msg
,
98 uint32_t time_boot_ms
, float roll
, float pitch
, float yaw
, float rollspeed
, float pitchspeed
, float yawspeed
)
100 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
102 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
103 _mav_put_float(buf
, 4, roll
);
104 _mav_put_float(buf
, 8, pitch
);
105 _mav_put_float(buf
, 12, yaw
);
106 _mav_put_float(buf
, 16, rollspeed
);
107 _mav_put_float(buf
, 20, pitchspeed
);
108 _mav_put_float(buf
, 24, yawspeed
);
110 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 28);
112 mavlink_attitude_t packet
;
113 packet
.time_boot_ms
= time_boot_ms
;
115 packet
.pitch
= pitch
;
117 packet
.rollspeed
= rollspeed
;
118 packet
.pitchspeed
= pitchspeed
;
119 packet
.yawspeed
= yawspeed
;
121 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 28);
122 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
124 msg
->msgid
= MAVLINK_MSG_ID_ATTITUDE
;
125 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, 28, 39);
129 * @brief Encode a attitude struct into a message
131 * @param system_id ID of this system
132 * @param component_id ID of this component (e.g. 200 for IMU)
133 * @param msg The MAVLink message to compress the data into
134 * @param attitude C-struct to read the message contents from
136 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
)
138 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
);
142 * @brief Send a attitude message
143 * @param chan MAVLink channel to send the message
145 * @param time_boot_ms Timestamp (milliseconds since system boot)
146 * @param roll Roll angle (rad)
147 * @param pitch Pitch angle (rad)
148 * @param yaw Yaw angle (rad)
149 * @param rollspeed Roll angular speed (rad/s)
150 * @param pitchspeed Pitch angular speed (rad/s)
151 * @param yawspeed Yaw angular speed (rad/s)
153 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
155 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
)
157 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
160 _mav_put_float(buf
, 4, roll
);
161 _mav_put_float(buf
, 8, pitch
);
162 _mav_put_float(buf
, 12, yaw
);
163 _mav_put_float(buf
, 16, rollspeed
);
164 _mav_put_float(buf
, 20, pitchspeed
);
165 _mav_put_float(buf
, 24, yawspeed
);
167 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE
, buf
, 28, 39);
169 mavlink_attitude_t packet
;
170 packet
.time_boot_ms
= time_boot_ms
;
172 packet
.pitch
= pitch
;
174 packet
.rollspeed
= rollspeed
;
175 packet
.pitchspeed
= pitchspeed
;
176 packet
.yawspeed
= yawspeed
;
178 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE
, (const char *)&packet
, 28, 39);
179 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
184 // MESSAGE ATTITUDE UNPACKING
188 * @brief Get field time_boot_ms from attitude message
190 * @return Timestamp (milliseconds since system boot)
192 static inline uint32_t mavlink_msg_attitude_get_time_boot_ms(const mavlink_message_t
*msg
)
194 return _MAV_RETURN_uint32_t(msg
, 0);
198 * @brief Get field roll from attitude message
200 * @return Roll angle (rad)
202 static inline float mavlink_msg_attitude_get_roll(const mavlink_message_t
*msg
)
204 return _MAV_RETURN_float(msg
, 4);
208 * @brief Get field pitch from attitude message
210 * @return Pitch angle (rad)
212 static inline float mavlink_msg_attitude_get_pitch(const mavlink_message_t
*msg
)
214 return _MAV_RETURN_float(msg
, 8);
218 * @brief Get field yaw from attitude message
220 * @return Yaw angle (rad)
222 static inline float mavlink_msg_attitude_get_yaw(const mavlink_message_t
*msg
)
224 return _MAV_RETURN_float(msg
, 12);
228 * @brief Get field rollspeed from attitude message
230 * @return Roll angular speed (rad/s)
232 static inline float mavlink_msg_attitude_get_rollspeed(const mavlink_message_t
*msg
)
234 return _MAV_RETURN_float(msg
, 16);
238 * @brief Get field pitchspeed from attitude message
240 * @return Pitch angular speed (rad/s)
242 static inline float mavlink_msg_attitude_get_pitchspeed(const mavlink_message_t
*msg
)
244 return _MAV_RETURN_float(msg
, 20);
248 * @brief Get field yawspeed from attitude message
250 * @return Yaw angular speed (rad/s)
252 static inline float mavlink_msg_attitude_get_yawspeed(const mavlink_message_t
*msg
)
254 return _MAV_RETURN_float(msg
, 24);
258 * @brief Decode a attitude message into a struct
260 * @param msg The message to decode
261 * @param attitude C-struct to decode the message contents into
263 static inline void mavlink_msg_attitude_decode(const mavlink_message_t
*msg
, mavlink_attitude_t
*attitude
)
265 #if MAVLINK_NEED_BYTE_SWAP
266 attitude
->time_boot_ms
= mavlink_msg_attitude_get_time_boot_ms(msg
);
267 attitude
->roll
= mavlink_msg_attitude_get_roll(msg
);
268 attitude
->pitch
= mavlink_msg_attitude_get_pitch(msg
);
269 attitude
->yaw
= mavlink_msg_attitude_get_yaw(msg
);
270 attitude
->rollspeed
= mavlink_msg_attitude_get_rollspeed(msg
);
271 attitude
->pitchspeed
= mavlink_msg_attitude_get_pitchspeed(msg
);
272 attitude
->yawspeed
= mavlink_msg_attitude_get_yawspeed(msg
);
274 memcpy(attitude
, _MAV_PAYLOAD(msg
), 28);