Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // MESSAGE SIMSTATE PACKING |
2 | |||
3 | #define MAVLINK_MSG_ID_SIMSTATE 164 |
||
4 | |||
5 | typedef struct __mavlink_simstate_t |
||
6 | { |
||
7 | float roll; ///< Roll angle (rad) |
||
8 | float pitch; ///< Pitch angle (rad) |
||
9 | float yaw; ///< Yaw angle (rad) |
||
10 | float xacc; ///< X acceleration m/s/s |
||
11 | float yacc; ///< Y acceleration m/s/s |
||
12 | float zacc; ///< Z acceleration m/s/s |
||
13 | float xgyro; ///< Angular speed around X axis rad/s |
||
14 | float ygyro; ///< Angular speed around Y axis rad/s |
||
15 | float zgyro; ///< Angular speed around Z axis rad/s |
||
16 | } mavlink_simstate_t; |
||
17 | |||
18 | #define MAVLINK_MSG_ID_SIMSTATE_LEN 36 |
||
19 | #define MAVLINK_MSG_ID_164_LEN 36 |
||
20 | |||
21 | |||
22 | |||
23 | #define MAVLINK_MESSAGE_INFO_SIMSTATE { \ |
||
24 | "SIMSTATE", \ |
||
25 | 9, \ |
||
26 | { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_simstate_t, roll) }, \ |
||
27 | { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_simstate_t, pitch) }, \ |
||
28 | { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_simstate_t, yaw) }, \ |
||
29 | { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_simstate_t, xacc) }, \ |
||
30 | { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_simstate_t, yacc) }, \ |
||
31 | { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_simstate_t, zacc) }, \ |
||
32 | { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_simstate_t, xgyro) }, \ |
||
33 | { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_simstate_t, ygyro) }, \ |
||
34 | { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_simstate_t, zgyro) }, \ |
||
35 | } \ |
||
36 | } |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @brief Pack a simstate message |
||
41 | * @param system_id ID of this system |
||
42 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
43 | * @param msg The MAVLink message to compress the data into |
||
44 | * |
||
45 | * @param roll Roll angle (rad) |
||
46 | * @param pitch Pitch angle (rad) |
||
47 | * @param yaw Yaw angle (rad) |
||
48 | * @param xacc X acceleration m/s/s |
||
49 | * @param yacc Y acceleration m/s/s |
||
50 | * @param zacc Z acceleration m/s/s |
||
51 | * @param xgyro Angular speed around X axis rad/s |
||
52 | * @param ygyro Angular speed around Y axis rad/s |
||
53 | * @param zgyro Angular speed around Z axis rad/s |
||
54 | * @return length of the message in bytes (excluding serial stream start sign) |
||
55 | */ |
||
56 | static inline uint16_t mavlink_msg_simstate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
||
57 | float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro) |
||
58 | { |
||
59 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
60 | char buf[36]; |
||
61 | _mav_put_float(buf, 0, roll); |
||
62 | _mav_put_float(buf, 4, pitch); |
||
63 | _mav_put_float(buf, 8, yaw); |
||
64 | _mav_put_float(buf, 12, xacc); |
||
65 | _mav_put_float(buf, 16, yacc); |
||
66 | _mav_put_float(buf, 20, zacc); |
||
67 | _mav_put_float(buf, 24, xgyro); |
||
68 | _mav_put_float(buf, 28, ygyro); |
||
69 | _mav_put_float(buf, 32, zgyro); |
||
70 | |||
71 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); |
||
72 | #else |
||
73 | mavlink_simstate_t packet; |
||
74 | packet.roll = roll; |
||
75 | packet.pitch = pitch; |
||
76 | packet.yaw = yaw; |
||
77 | packet.xacc = xacc; |
||
78 | packet.yacc = yacc; |
||
79 | packet.zacc = zacc; |
||
80 | packet.xgyro = xgyro; |
||
81 | packet.ygyro = ygyro; |
||
82 | packet.zgyro = zgyro; |
||
83 | |||
84 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); |
||
85 | #endif |
||
86 | |||
87 | msg->msgid = MAVLINK_MSG_ID_SIMSTATE; |
||
88 | return mavlink_finalize_message(msg, system_id, component_id, 36); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @brief Pack a simstate message on a channel |
||
93 | * @param system_id ID of this system |
||
94 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
95 | * @param chan The MAVLink channel this message was sent over |
||
96 | * @param msg The MAVLink message to compress the data into |
||
97 | * @param roll Roll angle (rad) |
||
98 | * @param pitch Pitch angle (rad) |
||
99 | * @param yaw Yaw angle (rad) |
||
100 | * @param xacc X acceleration m/s/s |
||
101 | * @param yacc Y acceleration m/s/s |
||
102 | * @param zacc Z acceleration m/s/s |
||
103 | * @param xgyro Angular speed around X axis rad/s |
||
104 | * @param ygyro Angular speed around Y axis rad/s |
||
105 | * @param zgyro Angular speed around Z axis rad/s |
||
106 | * @return length of the message in bytes (excluding serial stream start sign) |
||
107 | */ |
||
108 | static inline uint16_t mavlink_msg_simstate_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
||
109 | mavlink_message_t* msg, |
||
110 | float roll,float pitch,float yaw,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro) |
||
111 | { |
||
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
113 | char buf[36]; |
||
114 | _mav_put_float(buf, 0, roll); |
||
115 | _mav_put_float(buf, 4, pitch); |
||
116 | _mav_put_float(buf, 8, yaw); |
||
117 | _mav_put_float(buf, 12, xacc); |
||
118 | _mav_put_float(buf, 16, yacc); |
||
119 | _mav_put_float(buf, 20, zacc); |
||
120 | _mav_put_float(buf, 24, xgyro); |
||
121 | _mav_put_float(buf, 28, ygyro); |
||
122 | _mav_put_float(buf, 32, zgyro); |
||
123 | |||
124 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); |
||
125 | #else |
||
126 | mavlink_simstate_t packet; |
||
127 | packet.roll = roll; |
||
128 | packet.pitch = pitch; |
||
129 | packet.yaw = yaw; |
||
130 | packet.xacc = xacc; |
||
131 | packet.yacc = yacc; |
||
132 | packet.zacc = zacc; |
||
133 | packet.xgyro = xgyro; |
||
134 | packet.ygyro = ygyro; |
||
135 | packet.zgyro = zgyro; |
||
136 | |||
137 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); |
||
138 | #endif |
||
139 | |||
140 | msg->msgid = MAVLINK_MSG_ID_SIMSTATE; |
||
141 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 36); |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @brief Encode a simstate struct into a message |
||
146 | * |
||
147 | * @param system_id ID of this system |
||
148 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
149 | * @param msg The MAVLink message to compress the data into |
||
150 | * @param simstate C-struct to read the message contents from |
||
151 | */ |
||
152 | static inline uint16_t mavlink_msg_simstate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_simstate_t* simstate) |
||
153 | { |
||
154 | return mavlink_msg_simstate_pack(system_id, component_id, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * @brief Send a simstate message |
||
159 | * @param chan MAVLink channel to send the message |
||
160 | * |
||
161 | * @param roll Roll angle (rad) |
||
162 | * @param pitch Pitch angle (rad) |
||
163 | * @param yaw Yaw angle (rad) |
||
164 | * @param xacc X acceleration m/s/s |
||
165 | * @param yacc Y acceleration m/s/s |
||
166 | * @param zacc Z acceleration m/s/s |
||
167 | * @param xgyro Angular speed around X axis rad/s |
||
168 | * @param ygyro Angular speed around Y axis rad/s |
||
169 | * @param zgyro Angular speed around Z axis rad/s |
||
170 | */ |
||
171 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
||
172 | |||
173 | static inline void mavlink_msg_simstate_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro) |
||
174 | { |
||
175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
176 | char buf[36]; |
||
177 | _mav_put_float(buf, 0, roll); |
||
178 | _mav_put_float(buf, 4, pitch); |
||
179 | _mav_put_float(buf, 8, yaw); |
||
180 | _mav_put_float(buf, 12, xacc); |
||
181 | _mav_put_float(buf, 16, yacc); |
||
182 | _mav_put_float(buf, 20, zacc); |
||
183 | _mav_put_float(buf, 24, xgyro); |
||
184 | _mav_put_float(buf, 28, ygyro); |
||
185 | _mav_put_float(buf, 32, zgyro); |
||
186 | |||
187 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, 36); |
||
188 | #else |
||
189 | mavlink_simstate_t packet; |
||
190 | packet.roll = roll; |
||
191 | packet.pitch = pitch; |
||
192 | packet.yaw = yaw; |
||
193 | packet.xacc = xacc; |
||
194 | packet.yacc = yacc; |
||
195 | packet.zacc = zacc; |
||
196 | packet.xgyro = xgyro; |
||
197 | packet.ygyro = ygyro; |
||
198 | packet.zgyro = zgyro; |
||
199 | |||
200 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)&packet, 36); |
||
201 | #endif |
||
202 | } |
||
203 | |||
204 | #endif |
||
205 | |||
206 | // MESSAGE SIMSTATE UNPACKING |
||
207 | |||
208 | |||
209 | /** |
||
210 | * @brief Get field roll from simstate message |
||
211 | * |
||
212 | * @return Roll angle (rad) |
||
213 | */ |
||
214 | static inline float mavlink_msg_simstate_get_roll(const mavlink_message_t* msg) |
||
215 | { |
||
216 | return _MAV_RETURN_float(msg, 0); |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * @brief Get field pitch from simstate message |
||
221 | * |
||
222 | * @return Pitch angle (rad) |
||
223 | */ |
||
224 | static inline float mavlink_msg_simstate_get_pitch(const mavlink_message_t* msg) |
||
225 | { |
||
226 | return _MAV_RETURN_float(msg, 4); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @brief Get field yaw from simstate message |
||
231 | * |
||
232 | * @return Yaw angle (rad) |
||
233 | */ |
||
234 | static inline float mavlink_msg_simstate_get_yaw(const mavlink_message_t* msg) |
||
235 | { |
||
236 | return _MAV_RETURN_float(msg, 8); |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * @brief Get field xacc from simstate message |
||
241 | * |
||
242 | * @return X acceleration m/s/s |
||
243 | */ |
||
244 | static inline float mavlink_msg_simstate_get_xacc(const mavlink_message_t* msg) |
||
245 | { |
||
246 | return _MAV_RETURN_float(msg, 12); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * @brief Get field yacc from simstate message |
||
251 | * |
||
252 | * @return Y acceleration m/s/s |
||
253 | */ |
||
254 | static inline float mavlink_msg_simstate_get_yacc(const mavlink_message_t* msg) |
||
255 | { |
||
256 | return _MAV_RETURN_float(msg, 16); |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @brief Get field zacc from simstate message |
||
261 | * |
||
262 | * @return Z acceleration m/s/s |
||
263 | */ |
||
264 | static inline float mavlink_msg_simstate_get_zacc(const mavlink_message_t* msg) |
||
265 | { |
||
266 | return _MAV_RETURN_float(msg, 20); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @brief Get field xgyro from simstate message |
||
271 | * |
||
272 | * @return Angular speed around X axis rad/s |
||
273 | */ |
||
274 | static inline float mavlink_msg_simstate_get_xgyro(const mavlink_message_t* msg) |
||
275 | { |
||
276 | return _MAV_RETURN_float(msg, 24); |
||
277 | } |
||
278 | |||
279 | /** |
||
280 | * @brief Get field ygyro from simstate message |
||
281 | * |
||
282 | * @return Angular speed around Y axis rad/s |
||
283 | */ |
||
284 | static inline float mavlink_msg_simstate_get_ygyro(const mavlink_message_t* msg) |
||
285 | { |
||
286 | return _MAV_RETURN_float(msg, 28); |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * @brief Get field zgyro from simstate message |
||
291 | * |
||
292 | * @return Angular speed around Z axis rad/s |
||
293 | */ |
||
294 | static inline float mavlink_msg_simstate_get_zgyro(const mavlink_message_t* msg) |
||
295 | { |
||
296 | return _MAV_RETURN_float(msg, 32); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @brief Decode a simstate message into a struct |
||
301 | * |
||
302 | * @param msg The message to decode |
||
303 | * @param simstate C-struct to decode the message contents into |
||
304 | */ |
||
305 | static inline void mavlink_msg_simstate_decode(const mavlink_message_t* msg, mavlink_simstate_t* simstate) |
||
306 | { |
||
307 | #if MAVLINK_NEED_BYTE_SWAP |
||
308 | simstate->roll = mavlink_msg_simstate_get_roll(msg); |
||
309 | simstate->pitch = mavlink_msg_simstate_get_pitch(msg); |
||
310 | simstate->yaw = mavlink_msg_simstate_get_yaw(msg); |
||
311 | simstate->xacc = mavlink_msg_simstate_get_xacc(msg); |
||
312 | simstate->yacc = mavlink_msg_simstate_get_yacc(msg); |
||
313 | simstate->zacc = mavlink_msg_simstate_get_zacc(msg); |
||
314 | simstate->xgyro = mavlink_msg_simstate_get_xgyro(msg); |
||
315 | simstate->ygyro = mavlink_msg_simstate_get_ygyro(msg); |
||
316 | simstate->zgyro = mavlink_msg_simstate_get_zgyro(msg); |
||
317 | #else |
||
318 | memcpy(simstate, _MAV_PAYLOAD(msg), 36); |
||
319 | #endif |
||
320 | } |