Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // MESSAGE POSITION_TARGET PACKING |
2 | |||
3 | #define MAVLINK_MSG_ID_POSITION_TARGET 63 |
||
4 | |||
5 | typedef struct __mavlink_position_target_t |
||
6 | { |
||
7 | float x; ///< x position |
||
8 | float y; ///< y position |
||
9 | float z; ///< z position |
||
10 | float yaw; ///< yaw orientation in radians, 0 = NORTH |
||
11 | } mavlink_position_target_t; |
||
12 | |||
13 | #define MAVLINK_MSG_ID_POSITION_TARGET_LEN 16 |
||
14 | #define MAVLINK_MSG_ID_63_LEN 16 |
||
15 | |||
16 | |||
17 | |||
18 | #define MAVLINK_MESSAGE_INFO_POSITION_TARGET { \ |
||
19 | "POSITION_TARGET", \ |
||
20 | 4, \ |
||
21 | { { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_position_target_t, x) }, \ |
||
22 | { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_position_target_t, y) }, \ |
||
23 | { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_position_target_t, z) }, \ |
||
24 | { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_position_target_t, yaw) }, \ |
||
25 | } \ |
||
26 | } |
||
27 | |||
28 | |||
29 | /** |
||
30 | * @brief Pack a position_target message |
||
31 | * @param system_id ID of this system |
||
32 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
33 | * @param msg The MAVLink message to compress the data into |
||
34 | * |
||
35 | * @param x x position |
||
36 | * @param y y position |
||
37 | * @param z z position |
||
38 | * @param yaw yaw orientation in radians, 0 = NORTH |
||
39 | * @return length of the message in bytes (excluding serial stream start sign) |
||
40 | */ |
||
41 | static inline uint16_t mavlink_msg_position_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
||
42 | float x, float y, float z, float yaw) |
||
43 | { |
||
44 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
45 | char buf[16]; |
||
46 | _mav_put_float(buf, 0, x); |
||
47 | _mav_put_float(buf, 4, y); |
||
48 | _mav_put_float(buf, 8, z); |
||
49 | _mav_put_float(buf, 12, yaw); |
||
50 | |||
51 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); |
||
52 | #else |
||
53 | mavlink_position_target_t packet; |
||
54 | packet.x = x; |
||
55 | packet.y = y; |
||
56 | packet.z = z; |
||
57 | packet.yaw = yaw; |
||
58 | |||
59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); |
||
60 | #endif |
||
61 | |||
62 | msg->msgid = MAVLINK_MSG_ID_POSITION_TARGET; |
||
63 | return mavlink_finalize_message(msg, system_id, component_id, 16); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @brief Pack a position_target message on a channel |
||
68 | * @param system_id ID of this system |
||
69 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
70 | * @param chan The MAVLink channel this message was sent over |
||
71 | * @param msg The MAVLink message to compress the data into |
||
72 | * @param x x position |
||
73 | * @param y y position |
||
74 | * @param z z position |
||
75 | * @param yaw yaw orientation in radians, 0 = NORTH |
||
76 | * @return length of the message in bytes (excluding serial stream start sign) |
||
77 | */ |
||
78 | static inline uint16_t mavlink_msg_position_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
||
79 | mavlink_message_t* msg, |
||
80 | float x,float y,float z,float yaw) |
||
81 | { |
||
82 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
83 | char buf[16]; |
||
84 | _mav_put_float(buf, 0, x); |
||
85 | _mav_put_float(buf, 4, y); |
||
86 | _mav_put_float(buf, 8, z); |
||
87 | _mav_put_float(buf, 12, yaw); |
||
88 | |||
89 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); |
||
90 | #else |
||
91 | mavlink_position_target_t packet; |
||
92 | packet.x = x; |
||
93 | packet.y = y; |
||
94 | packet.z = z; |
||
95 | packet.yaw = yaw; |
||
96 | |||
97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); |
||
98 | #endif |
||
99 | |||
100 | msg->msgid = MAVLINK_MSG_ID_POSITION_TARGET; |
||
101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 16); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @brief Encode a position_target struct into a message |
||
106 | * |
||
107 | * @param system_id ID of this system |
||
108 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
109 | * @param msg The MAVLink message to compress the data into |
||
110 | * @param position_target C-struct to read the message contents from |
||
111 | */ |
||
112 | static inline uint16_t mavlink_msg_position_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_position_target_t* position_target) |
||
113 | { |
||
114 | return mavlink_msg_position_target_pack(system_id, component_id, msg, position_target->x, position_target->y, position_target->z, position_target->yaw); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * @brief Send a position_target message |
||
119 | * @param chan MAVLink channel to send the message |
||
120 | * |
||
121 | * @param x x position |
||
122 | * @param y y position |
||
123 | * @param z z position |
||
124 | * @param yaw yaw orientation in radians, 0 = NORTH |
||
125 | */ |
||
126 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
||
127 | |||
128 | static inline void mavlink_msg_position_target_send(mavlink_channel_t chan, float x, float y, float z, float yaw) |
||
129 | { |
||
130 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
131 | char buf[16]; |
||
132 | _mav_put_float(buf, 0, x); |
||
133 | _mav_put_float(buf, 4, y); |
||
134 | _mav_put_float(buf, 8, z); |
||
135 | _mav_put_float(buf, 12, yaw); |
||
136 | |||
137 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POSITION_TARGET, buf, 16); |
||
138 | #else |
||
139 | mavlink_position_target_t packet; |
||
140 | packet.x = x; |
||
141 | packet.y = y; |
||
142 | packet.z = z; |
||
143 | packet.yaw = yaw; |
||
144 | |||
145 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POSITION_TARGET, (const char *)&packet, 16); |
||
146 | #endif |
||
147 | } |
||
148 | |||
149 | #endif |
||
150 | |||
151 | // MESSAGE POSITION_TARGET UNPACKING |
||
152 | |||
153 | |||
154 | /** |
||
155 | * @brief Get field x from position_target message |
||
156 | * |
||
157 | * @return x position |
||
158 | */ |
||
159 | static inline float mavlink_msg_position_target_get_x(const mavlink_message_t* msg) |
||
160 | { |
||
161 | return _MAV_RETURN_float(msg, 0); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @brief Get field y from position_target message |
||
166 | * |
||
167 | * @return y position |
||
168 | */ |
||
169 | static inline float mavlink_msg_position_target_get_y(const mavlink_message_t* msg) |
||
170 | { |
||
171 | return _MAV_RETURN_float(msg, 4); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @brief Get field z from position_target message |
||
176 | * |
||
177 | * @return z position |
||
178 | */ |
||
179 | static inline float mavlink_msg_position_target_get_z(const mavlink_message_t* msg) |
||
180 | { |
||
181 | return _MAV_RETURN_float(msg, 8); |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * @brief Get field yaw from position_target message |
||
186 | * |
||
187 | * @return yaw orientation in radians, 0 = NORTH |
||
188 | */ |
||
189 | static inline float mavlink_msg_position_target_get_yaw(const mavlink_message_t* msg) |
||
190 | { |
||
191 | return _MAV_RETURN_float(msg, 12); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * @brief Decode a position_target message into a struct |
||
196 | * |
||
197 | * @param msg The message to decode |
||
198 | * @param position_target C-struct to decode the message contents into |
||
199 | */ |
||
200 | static inline void mavlink_msg_position_target_decode(const mavlink_message_t* msg, mavlink_position_target_t* position_target) |
||
201 | { |
||
202 | #if MAVLINK_NEED_BYTE_SWAP |
||
203 | position_target->x = mavlink_msg_position_target_get_x(msg); |
||
204 | position_target->y = mavlink_msg_position_target_get_y(msg); |
||
205 | position_target->z = mavlink_msg_position_target_get_z(msg); |
||
206 | position_target->yaw = mavlink_msg_position_target_get_yaw(msg); |
||
207 | #else |
||
208 | memcpy(position_target, _MAV_PAYLOAD(msg), 16); |
||
209 | #endif |
||
210 | } |