![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
MAVlink/include/pixhawk/mavlink_msg_position_control_setpoint.h@0:a6a169de725f, 2013-05-27 (annotated)
- Committer:
- shimniok
- Date:
- Mon May 27 13:26:03 2013 +0000
- Revision:
- 0:a6a169de725f
Working version with priorities set and update time display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE POSITION_CONTROL_SETPOINT PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_POSITION_CONTROL_SETPOINT 121 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_position_control_setpoint_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint16_t id; ///< ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 8 | float x; ///< x position |
shimniok | 0:a6a169de725f | 9 | float y; ///< y position |
shimniok | 0:a6a169de725f | 10 | float z; ///< z position |
shimniok | 0:a6a169de725f | 11 | float yaw; ///< yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 12 | |
shimniok | 0:a6a169de725f | 13 | } mavlink_position_control_setpoint_t; |
shimniok | 0:a6a169de725f | 14 | |
shimniok | 0:a6a169de725f | 15 | |
shimniok | 0:a6a169de725f | 16 | |
shimniok | 0:a6a169de725f | 17 | /** |
shimniok | 0:a6a169de725f | 18 | * @brief Pack a position_control_setpoint message |
shimniok | 0:a6a169de725f | 19 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 20 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 21 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 22 | * |
shimniok | 0:a6a169de725f | 23 | * @param id ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 24 | * @param x x position |
shimniok | 0:a6a169de725f | 25 | * @param y y position |
shimniok | 0:a6a169de725f | 26 | * @param z z position |
shimniok | 0:a6a169de725f | 27 | * @param yaw yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 28 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 29 | */ |
shimniok | 0:a6a169de725f | 30 | static inline uint16_t mavlink_msg_position_control_setpoint_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint16_t id, float x, float y, float z, float yaw) |
shimniok | 0:a6a169de725f | 31 | { |
shimniok | 0:a6a169de725f | 32 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 33 | msg->msgid = MAVLINK_MSG_ID_POSITION_CONTROL_SETPOINT; |
shimniok | 0:a6a169de725f | 34 | |
shimniok | 0:a6a169de725f | 35 | i += put_uint16_t_by_index(id, i, msg->payload); // ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 36 | i += put_float_by_index(x, i, msg->payload); // x position |
shimniok | 0:a6a169de725f | 37 | i += put_float_by_index(y, i, msg->payload); // y position |
shimniok | 0:a6a169de725f | 38 | i += put_float_by_index(z, i, msg->payload); // z position |
shimniok | 0:a6a169de725f | 39 | i += put_float_by_index(yaw, i, msg->payload); // yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 40 | |
shimniok | 0:a6a169de725f | 41 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 42 | } |
shimniok | 0:a6a169de725f | 43 | |
shimniok | 0:a6a169de725f | 44 | /** |
shimniok | 0:a6a169de725f | 45 | * @brief Pack a position_control_setpoint message |
shimniok | 0:a6a169de725f | 46 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 47 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 48 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 49 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 50 | * @param id ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 51 | * @param x x position |
shimniok | 0:a6a169de725f | 52 | * @param y y position |
shimniok | 0:a6a169de725f | 53 | * @param z z position |
shimniok | 0:a6a169de725f | 54 | * @param yaw yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 55 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 56 | */ |
shimniok | 0:a6a169de725f | 57 | static inline uint16_t mavlink_msg_position_control_setpoint_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint16_t id, float x, float y, float z, float yaw) |
shimniok | 0:a6a169de725f | 58 | { |
shimniok | 0:a6a169de725f | 59 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 60 | msg->msgid = MAVLINK_MSG_ID_POSITION_CONTROL_SETPOINT; |
shimniok | 0:a6a169de725f | 61 | |
shimniok | 0:a6a169de725f | 62 | i += put_uint16_t_by_index(id, i, msg->payload); // ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 63 | i += put_float_by_index(x, i, msg->payload); // x position |
shimniok | 0:a6a169de725f | 64 | i += put_float_by_index(y, i, msg->payload); // y position |
shimniok | 0:a6a169de725f | 65 | i += put_float_by_index(z, i, msg->payload); // z position |
shimniok | 0:a6a169de725f | 66 | i += put_float_by_index(yaw, i, msg->payload); // yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 67 | |
shimniok | 0:a6a169de725f | 68 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 69 | } |
shimniok | 0:a6a169de725f | 70 | |
shimniok | 0:a6a169de725f | 71 | /** |
shimniok | 0:a6a169de725f | 72 | * @brief Encode a position_control_setpoint struct into a message |
shimniok | 0:a6a169de725f | 73 | * |
shimniok | 0:a6a169de725f | 74 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 75 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 76 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 77 | * @param position_control_setpoint C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 78 | */ |
shimniok | 0:a6a169de725f | 79 | static inline uint16_t mavlink_msg_position_control_setpoint_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_position_control_setpoint_t* position_control_setpoint) |
shimniok | 0:a6a169de725f | 80 | { |
shimniok | 0:a6a169de725f | 81 | return mavlink_msg_position_control_setpoint_pack(system_id, component_id, msg, position_control_setpoint->id, position_control_setpoint->x, position_control_setpoint->y, position_control_setpoint->z, position_control_setpoint->yaw); |
shimniok | 0:a6a169de725f | 82 | } |
shimniok | 0:a6a169de725f | 83 | |
shimniok | 0:a6a169de725f | 84 | /** |
shimniok | 0:a6a169de725f | 85 | * @brief Send a position_control_setpoint message |
shimniok | 0:a6a169de725f | 86 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 87 | * |
shimniok | 0:a6a169de725f | 88 | * @param id ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 89 | * @param x x position |
shimniok | 0:a6a169de725f | 90 | * @param y y position |
shimniok | 0:a6a169de725f | 91 | * @param z z position |
shimniok | 0:a6a169de725f | 92 | * @param yaw yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 93 | */ |
shimniok | 0:a6a169de725f | 94 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 95 | |
shimniok | 0:a6a169de725f | 96 | static inline void mavlink_msg_position_control_setpoint_send(mavlink_channel_t chan, uint16_t id, float x, float y, float z, float yaw) |
shimniok | 0:a6a169de725f | 97 | { |
shimniok | 0:a6a169de725f | 98 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 99 | mavlink_msg_position_control_setpoint_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, id, x, y, z, yaw); |
shimniok | 0:a6a169de725f | 100 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 101 | } |
shimniok | 0:a6a169de725f | 102 | |
shimniok | 0:a6a169de725f | 103 | #endif |
shimniok | 0:a6a169de725f | 104 | // MESSAGE POSITION_CONTROL_SETPOINT UNPACKING |
shimniok | 0:a6a169de725f | 105 | |
shimniok | 0:a6a169de725f | 106 | /** |
shimniok | 0:a6a169de725f | 107 | * @brief Get field id from position_control_setpoint message |
shimniok | 0:a6a169de725f | 108 | * |
shimniok | 0:a6a169de725f | 109 | * @return ID of waypoint, 0 for plain position |
shimniok | 0:a6a169de725f | 110 | */ |
shimniok | 0:a6a169de725f | 111 | static inline uint16_t mavlink_msg_position_control_setpoint_get_id(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 112 | { |
shimniok | 0:a6a169de725f | 113 | generic_16bit r; |
shimniok | 0:a6a169de725f | 114 | r.b[1] = (msg->payload)[0]; |
shimniok | 0:a6a169de725f | 115 | r.b[0] = (msg->payload)[1]; |
shimniok | 0:a6a169de725f | 116 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 117 | } |
shimniok | 0:a6a169de725f | 118 | |
shimniok | 0:a6a169de725f | 119 | /** |
shimniok | 0:a6a169de725f | 120 | * @brief Get field x from position_control_setpoint message |
shimniok | 0:a6a169de725f | 121 | * |
shimniok | 0:a6a169de725f | 122 | * @return x position |
shimniok | 0:a6a169de725f | 123 | */ |
shimniok | 0:a6a169de725f | 124 | static inline float mavlink_msg_position_control_setpoint_get_x(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 125 | { |
shimniok | 0:a6a169de725f | 126 | generic_32bit r; |
shimniok | 0:a6a169de725f | 127 | r.b[3] = (msg->payload+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 128 | r.b[2] = (msg->payload+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 129 | r.b[1] = (msg->payload+sizeof(uint16_t))[2]; |
shimniok | 0:a6a169de725f | 130 | r.b[0] = (msg->payload+sizeof(uint16_t))[3]; |
shimniok | 0:a6a169de725f | 131 | return (float)r.f; |
shimniok | 0:a6a169de725f | 132 | } |
shimniok | 0:a6a169de725f | 133 | |
shimniok | 0:a6a169de725f | 134 | /** |
shimniok | 0:a6a169de725f | 135 | * @brief Get field y from position_control_setpoint message |
shimniok | 0:a6a169de725f | 136 | * |
shimniok | 0:a6a169de725f | 137 | * @return y position |
shimniok | 0:a6a169de725f | 138 | */ |
shimniok | 0:a6a169de725f | 139 | static inline float mavlink_msg_position_control_setpoint_get_y(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 140 | { |
shimniok | 0:a6a169de725f | 141 | generic_32bit r; |
shimniok | 0:a6a169de725f | 142 | r.b[3] = (msg->payload+sizeof(uint16_t)+sizeof(float))[0]; |
shimniok | 0:a6a169de725f | 143 | r.b[2] = (msg->payload+sizeof(uint16_t)+sizeof(float))[1]; |
shimniok | 0:a6a169de725f | 144 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(float))[2]; |
shimniok | 0:a6a169de725f | 145 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(float))[3]; |
shimniok | 0:a6a169de725f | 146 | return (float)r.f; |
shimniok | 0:a6a169de725f | 147 | } |
shimniok | 0:a6a169de725f | 148 | |
shimniok | 0:a6a169de725f | 149 | /** |
shimniok | 0:a6a169de725f | 150 | * @brief Get field z from position_control_setpoint message |
shimniok | 0:a6a169de725f | 151 | * |
shimniok | 0:a6a169de725f | 152 | * @return z position |
shimniok | 0:a6a169de725f | 153 | */ |
shimniok | 0:a6a169de725f | 154 | static inline float mavlink_msg_position_control_setpoint_get_z(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 155 | { |
shimniok | 0:a6a169de725f | 156 | generic_32bit r; |
shimniok | 0:a6a169de725f | 157 | r.b[3] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float))[0]; |
shimniok | 0:a6a169de725f | 158 | r.b[2] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float))[1]; |
shimniok | 0:a6a169de725f | 159 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float))[2]; |
shimniok | 0:a6a169de725f | 160 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float))[3]; |
shimniok | 0:a6a169de725f | 161 | return (float)r.f; |
shimniok | 0:a6a169de725f | 162 | } |
shimniok | 0:a6a169de725f | 163 | |
shimniok | 0:a6a169de725f | 164 | /** |
shimniok | 0:a6a169de725f | 165 | * @brief Get field yaw from position_control_setpoint message |
shimniok | 0:a6a169de725f | 166 | * |
shimniok | 0:a6a169de725f | 167 | * @return yaw orientation in radians, 0 = NORTH |
shimniok | 0:a6a169de725f | 168 | */ |
shimniok | 0:a6a169de725f | 169 | static inline float mavlink_msg_position_control_setpoint_get_yaw(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 170 | { |
shimniok | 0:a6a169de725f | 171 | generic_32bit r; |
shimniok | 0:a6a169de725f | 172 | r.b[3] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float)+sizeof(float))[0]; |
shimniok | 0:a6a169de725f | 173 | r.b[2] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float)+sizeof(float))[1]; |
shimniok | 0:a6a169de725f | 174 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float)+sizeof(float))[2]; |
shimniok | 0:a6a169de725f | 175 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(float)+sizeof(float)+sizeof(float))[3]; |
shimniok | 0:a6a169de725f | 176 | return (float)r.f; |
shimniok | 0:a6a169de725f | 177 | } |
shimniok | 0:a6a169de725f | 178 | |
shimniok | 0:a6a169de725f | 179 | /** |
shimniok | 0:a6a169de725f | 180 | * @brief Decode a position_control_setpoint message into a struct |
shimniok | 0:a6a169de725f | 181 | * |
shimniok | 0:a6a169de725f | 182 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 183 | * @param position_control_setpoint C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 184 | */ |
shimniok | 0:a6a169de725f | 185 | static inline void mavlink_msg_position_control_setpoint_decode(const mavlink_message_t* msg, mavlink_position_control_setpoint_t* position_control_setpoint) |
shimniok | 0:a6a169de725f | 186 | { |
shimniok | 0:a6a169de725f | 187 | position_control_setpoint->id = mavlink_msg_position_control_setpoint_get_id(msg); |
shimniok | 0:a6a169de725f | 188 | position_control_setpoint->x = mavlink_msg_position_control_setpoint_get_x(msg); |
shimniok | 0:a6a169de725f | 189 | position_control_setpoint->y = mavlink_msg_position_control_setpoint_get_y(msg); |
shimniok | 0:a6a169de725f | 190 | position_control_setpoint->z = mavlink_msg_position_control_setpoint_get_z(msg); |
shimniok | 0:a6a169de725f | 191 | position_control_setpoint->yaw = mavlink_msg_position_control_setpoint_get_yaw(msg); |
shimniok | 0:a6a169de725f | 192 | } |