Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // MESSAGE ATTITUDE PACKING |
2 | |||
3 | #define MAVLINK_MSG_ID_ATTITUDE 30 |
||
4 | |||
5 | typedef struct __mavlink_attitude_t |
||
6 | { |
||
7 | uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) |
||
8 | float roll; ///< Roll angle (rad) |
||
9 | float pitch; ///< Pitch angle (rad) |
||
10 | float yaw; ///< Yaw angle (rad) |
||
11 | float rollspeed; ///< Roll angular speed (rad/s) |
||
12 | float pitchspeed; ///< Pitch angular speed (rad/s) |
||
13 | float yawspeed; ///< Yaw angular speed (rad/s) |
||
14 | } mavlink_attitude_t; |
||
15 | |||
16 | #define MAVLINK_MSG_ID_ATTITUDE_LEN 28 |
||
17 | #define MAVLINK_MSG_ID_30_LEN 28 |
||
18 | |||
19 | |||
20 | |||
21 | #define MAVLINK_MESSAGE_INFO_ATTITUDE { \ |
||
22 | "ATTITUDE", \ |
||
23 | 7, \ |
||
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) }, \ |
||
31 | } \ |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
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 |
||
40 | * |
||
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) |
||
49 | */ |
||
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) |
||
52 | { |
||
53 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
54 | char buf[28]; |
||
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); |
||
62 | |||
63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); |
||
64 | #else |
||
65 | mavlink_attitude_t packet; |
||
66 | packet.time_boot_ms = time_boot_ms; |
||
67 | packet.roll = roll; |
||
68 | packet.pitch = pitch; |
||
69 | packet.yaw = yaw; |
||
70 | packet.rollspeed = rollspeed; |
||
71 | packet.pitchspeed = pitchspeed; |
||
72 | packet.yawspeed = yawspeed; |
||
73 | |||
74 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); |
||
75 | #endif |
||
76 | |||
77 | msg->msgid = MAVLINK_MSG_ID_ATTITUDE; |
||
78 | return mavlink_finalize_message(msg, system_id, component_id, 28, 39); |
||
79 | } |
||
80 | |||
81 | /** |
||
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) |
||
95 | */ |
||
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) |
||
99 | { |
||
100 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
101 | char buf[28]; |
||
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); |
||
109 | |||
110 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); |
||
111 | #else |
||
112 | mavlink_attitude_t packet; |
||
113 | packet.time_boot_ms = time_boot_ms; |
||
114 | packet.roll = roll; |
||
115 | packet.pitch = pitch; |
||
116 | packet.yaw = yaw; |
||
117 | packet.rollspeed = rollspeed; |
||
118 | packet.pitchspeed = pitchspeed; |
||
119 | packet.yawspeed = yawspeed; |
||
120 | |||
121 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); |
||
122 | #endif |
||
123 | |||
124 | msg->msgid = MAVLINK_MSG_ID_ATTITUDE; |
||
125 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28, 39); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * @brief Encode a attitude struct into a message |
||
130 | * |
||
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 |
||
135 | */ |
||
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) |
||
137 | { |
||
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); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @brief Send a attitude message |
||
143 | * @param chan MAVLink channel to send the message |
||
144 | * |
||
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) |
||
152 | */ |
||
153 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
||
154 | |||
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) |
||
156 | { |
||
157 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
158 | char buf[28]; |
||
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); |
||
166 | |||
167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE, buf, 28, 39); |
||
168 | #else |
||
169 | mavlink_attitude_t packet; |
||
170 | packet.time_boot_ms = time_boot_ms; |
||
171 | packet.roll = roll; |
||
172 | packet.pitch = pitch; |
||
173 | packet.yaw = yaw; |
||
174 | packet.rollspeed = rollspeed; |
||
175 | packet.pitchspeed = pitchspeed; |
||
176 | packet.yawspeed = yawspeed; |
||
177 | |||
178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE, (const char *)&packet, 28, 39); |
||
179 | #endif |
||
180 | } |
||
181 | |||
182 | #endif |
||
183 | |||
184 | // MESSAGE ATTITUDE UNPACKING |
||
185 | |||
186 | |||
187 | /** |
||
188 | * @brief Get field time_boot_ms from attitude message |
||
189 | * |
||
190 | * @return Timestamp (milliseconds since system boot) |
||
191 | */ |
||
192 | static inline uint32_t mavlink_msg_attitude_get_time_boot_ms(const mavlink_message_t* msg) |
||
193 | { |
||
194 | return _MAV_RETURN_uint32_t(msg, 0); |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @brief Get field roll from attitude message |
||
199 | * |
||
200 | * @return Roll angle (rad) |
||
201 | */ |
||
202 | static inline float mavlink_msg_attitude_get_roll(const mavlink_message_t* msg) |
||
203 | { |
||
204 | return _MAV_RETURN_float(msg, 4); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @brief Get field pitch from attitude message |
||
209 | * |
||
210 | * @return Pitch angle (rad) |
||
211 | */ |
||
212 | static inline float mavlink_msg_attitude_get_pitch(const mavlink_message_t* msg) |
||
213 | { |
||
214 | return _MAV_RETURN_float(msg, 8); |
||
215 | } |
||
216 | |||
217 | /** |
||
218 | * @brief Get field yaw from attitude message |
||
219 | * |
||
220 | * @return Yaw angle (rad) |
||
221 | */ |
||
222 | static inline float mavlink_msg_attitude_get_yaw(const mavlink_message_t* msg) |
||
223 | { |
||
224 | return _MAV_RETURN_float(msg, 12); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @brief Get field rollspeed from attitude message |
||
229 | * |
||
230 | * @return Roll angular speed (rad/s) |
||
231 | */ |
||
232 | static inline float mavlink_msg_attitude_get_rollspeed(const mavlink_message_t* msg) |
||
233 | { |
||
234 | return _MAV_RETURN_float(msg, 16); |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * @brief Get field pitchspeed from attitude message |
||
239 | * |
||
240 | * @return Pitch angular speed (rad/s) |
||
241 | */ |
||
242 | static inline float mavlink_msg_attitude_get_pitchspeed(const mavlink_message_t* msg) |
||
243 | { |
||
244 | return _MAV_RETURN_float(msg, 20); |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @brief Get field yawspeed from attitude message |
||
249 | * |
||
250 | * @return Yaw angular speed (rad/s) |
||
251 | */ |
||
252 | static inline float mavlink_msg_attitude_get_yawspeed(const mavlink_message_t* msg) |
||
253 | { |
||
254 | return _MAV_RETURN_float(msg, 24); |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * @brief Decode a attitude message into a struct |
||
259 | * |
||
260 | * @param msg The message to decode |
||
261 | * @param attitude C-struct to decode the message contents into |
||
262 | */ |
||
263 | static inline void mavlink_msg_attitude_decode(const mavlink_message_t* msg, mavlink_attitude_t* attitude) |
||
264 | { |
||
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); |
||
273 | #else |
||
274 | memcpy(attitude, _MAV_PAYLOAD(msg), 28); |
||
275 | #endif |
||
276 | } |