Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Committer:
shimniok
Date:
Wed Jun 20 14:57:48 2012 +0000
Revision:
0:826c6171fc1b
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:826c6171fc1b 1 // MESSAGE BRIEF_FEATURE PACKING
shimniok 0:826c6171fc1b 2
shimniok 0:826c6171fc1b 3 #define MAVLINK_MSG_ID_BRIEF_FEATURE 172
shimniok 0:826c6171fc1b 4
shimniok 0:826c6171fc1b 5 typedef struct __mavlink_brief_feature_t
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 float x; ///< x position in m
shimniok 0:826c6171fc1b 8 float y; ///< y position in m
shimniok 0:826c6171fc1b 9 float z; ///< z position in m
shimniok 0:826c6171fc1b 10 uint8_t orientation_assignment; ///< Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 11 uint16_t size; ///< Size in pixels
shimniok 0:826c6171fc1b 12 uint16_t orientation; ///< Orientation
shimniok 0:826c6171fc1b 13 uint8_t descriptor[32]; ///< Descriptor
shimniok 0:826c6171fc1b 14 float response; ///< Harris operator response at this location
shimniok 0:826c6171fc1b 15
shimniok 0:826c6171fc1b 16 } mavlink_brief_feature_t;
shimniok 0:826c6171fc1b 17
shimniok 0:826c6171fc1b 18 #define MAVLINK_MSG_BRIEF_FEATURE_FIELD_DESCRIPTOR_LEN 32
shimniok 0:826c6171fc1b 19
shimniok 0:826c6171fc1b 20
shimniok 0:826c6171fc1b 21 /**
shimniok 0:826c6171fc1b 22 * @brief Pack a brief_feature message
shimniok 0:826c6171fc1b 23 * @param system_id ID of this system
shimniok 0:826c6171fc1b 24 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 25 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 26 *
shimniok 0:826c6171fc1b 27 * @param x x position in m
shimniok 0:826c6171fc1b 28 * @param y y position in m
shimniok 0:826c6171fc1b 29 * @param z z position in m
shimniok 0:826c6171fc1b 30 * @param orientation_assignment Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 31 * @param size Size in pixels
shimniok 0:826c6171fc1b 32 * @param orientation Orientation
shimniok 0:826c6171fc1b 33 * @param descriptor Descriptor
shimniok 0:826c6171fc1b 34 * @param response Harris operator response at this location
shimniok 0:826c6171fc1b 35 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 36 */
shimniok 0:826c6171fc1b 37 static inline uint16_t mavlink_msg_brief_feature_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, float x, float y, float z, uint8_t orientation_assignment, uint16_t size, uint16_t orientation, const uint8_t* descriptor, float response)
shimniok 0:826c6171fc1b 38 {
shimniok 0:826c6171fc1b 39 uint16_t i = 0;
shimniok 0:826c6171fc1b 40 msg->msgid = MAVLINK_MSG_ID_BRIEF_FEATURE;
shimniok 0:826c6171fc1b 41
shimniok 0:826c6171fc1b 42 i += put_float_by_index(x, i, msg->payload); // x position in m
shimniok 0:826c6171fc1b 43 i += put_float_by_index(y, i, msg->payload); // y position in m
shimniok 0:826c6171fc1b 44 i += put_float_by_index(z, i, msg->payload); // z position in m
shimniok 0:826c6171fc1b 45 i += put_uint8_t_by_index(orientation_assignment, i, msg->payload); // Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 46 i += put_uint16_t_by_index(size, i, msg->payload); // Size in pixels
shimniok 0:826c6171fc1b 47 i += put_uint16_t_by_index(orientation, i, msg->payload); // Orientation
shimniok 0:826c6171fc1b 48 i += put_array_by_index((const int8_t*)descriptor, sizeof(uint8_t)*32, i, msg->payload); // Descriptor
shimniok 0:826c6171fc1b 49 i += put_float_by_index(response, i, msg->payload); // Harris operator response at this location
shimniok 0:826c6171fc1b 50
shimniok 0:826c6171fc1b 51 return mavlink_finalize_message(msg, system_id, component_id, i);
shimniok 0:826c6171fc1b 52 }
shimniok 0:826c6171fc1b 53
shimniok 0:826c6171fc1b 54 /**
shimniok 0:826c6171fc1b 55 * @brief Pack a brief_feature message
shimniok 0:826c6171fc1b 56 * @param system_id ID of this system
shimniok 0:826c6171fc1b 57 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 58 * @param chan The MAVLink channel this message was sent over
shimniok 0:826c6171fc1b 59 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 60 * @param x x position in m
shimniok 0:826c6171fc1b 61 * @param y y position in m
shimniok 0:826c6171fc1b 62 * @param z z position in m
shimniok 0:826c6171fc1b 63 * @param orientation_assignment Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 64 * @param size Size in pixels
shimniok 0:826c6171fc1b 65 * @param orientation Orientation
shimniok 0:826c6171fc1b 66 * @param descriptor Descriptor
shimniok 0:826c6171fc1b 67 * @param response Harris operator response at this location
shimniok 0:826c6171fc1b 68 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 69 */
shimniok 0:826c6171fc1b 70 static inline uint16_t mavlink_msg_brief_feature_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, float x, float y, float z, uint8_t orientation_assignment, uint16_t size, uint16_t orientation, const uint8_t* descriptor, float response)
shimniok 0:826c6171fc1b 71 {
shimniok 0:826c6171fc1b 72 uint16_t i = 0;
shimniok 0:826c6171fc1b 73 msg->msgid = MAVLINK_MSG_ID_BRIEF_FEATURE;
shimniok 0:826c6171fc1b 74
shimniok 0:826c6171fc1b 75 i += put_float_by_index(x, i, msg->payload); // x position in m
shimniok 0:826c6171fc1b 76 i += put_float_by_index(y, i, msg->payload); // y position in m
shimniok 0:826c6171fc1b 77 i += put_float_by_index(z, i, msg->payload); // z position in m
shimniok 0:826c6171fc1b 78 i += put_uint8_t_by_index(orientation_assignment, i, msg->payload); // Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 79 i += put_uint16_t_by_index(size, i, msg->payload); // Size in pixels
shimniok 0:826c6171fc1b 80 i += put_uint16_t_by_index(orientation, i, msg->payload); // Orientation
shimniok 0:826c6171fc1b 81 i += put_array_by_index((const int8_t*)descriptor, sizeof(uint8_t)*32, i, msg->payload); // Descriptor
shimniok 0:826c6171fc1b 82 i += put_float_by_index(response, i, msg->payload); // Harris operator response at this location
shimniok 0:826c6171fc1b 83
shimniok 0:826c6171fc1b 84 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
shimniok 0:826c6171fc1b 85 }
shimniok 0:826c6171fc1b 86
shimniok 0:826c6171fc1b 87 /**
shimniok 0:826c6171fc1b 88 * @brief Encode a brief_feature struct into a message
shimniok 0:826c6171fc1b 89 *
shimniok 0:826c6171fc1b 90 * @param system_id ID of this system
shimniok 0:826c6171fc1b 91 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 92 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 93 * @param brief_feature C-struct to read the message contents from
shimniok 0:826c6171fc1b 94 */
shimniok 0:826c6171fc1b 95 static inline uint16_t mavlink_msg_brief_feature_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_brief_feature_t* brief_feature)
shimniok 0:826c6171fc1b 96 {
shimniok 0:826c6171fc1b 97 return mavlink_msg_brief_feature_pack(system_id, component_id, msg, brief_feature->x, brief_feature->y, brief_feature->z, brief_feature->orientation_assignment, brief_feature->size, brief_feature->orientation, brief_feature->descriptor, brief_feature->response);
shimniok 0:826c6171fc1b 98 }
shimniok 0:826c6171fc1b 99
shimniok 0:826c6171fc1b 100 /**
shimniok 0:826c6171fc1b 101 * @brief Send a brief_feature message
shimniok 0:826c6171fc1b 102 * @param chan MAVLink channel to send the message
shimniok 0:826c6171fc1b 103 *
shimniok 0:826c6171fc1b 104 * @param x x position in m
shimniok 0:826c6171fc1b 105 * @param y y position in m
shimniok 0:826c6171fc1b 106 * @param z z position in m
shimniok 0:826c6171fc1b 107 * @param orientation_assignment Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 108 * @param size Size in pixels
shimniok 0:826c6171fc1b 109 * @param orientation Orientation
shimniok 0:826c6171fc1b 110 * @param descriptor Descriptor
shimniok 0:826c6171fc1b 111 * @param response Harris operator response at this location
shimniok 0:826c6171fc1b 112 */
shimniok 0:826c6171fc1b 113 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
shimniok 0:826c6171fc1b 114
shimniok 0:826c6171fc1b 115 static inline void mavlink_msg_brief_feature_send(mavlink_channel_t chan, float x, float y, float z, uint8_t orientation_assignment, uint16_t size, uint16_t orientation, const uint8_t* descriptor, float response)
shimniok 0:826c6171fc1b 116 {
shimniok 0:826c6171fc1b 117 mavlink_message_t msg;
shimniok 0:826c6171fc1b 118 mavlink_msg_brief_feature_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, x, y, z, orientation_assignment, size, orientation, descriptor, response);
shimniok 0:826c6171fc1b 119 mavlink_send_uart(chan, &msg);
shimniok 0:826c6171fc1b 120 }
shimniok 0:826c6171fc1b 121
shimniok 0:826c6171fc1b 122 #endif
shimniok 0:826c6171fc1b 123 // MESSAGE BRIEF_FEATURE UNPACKING
shimniok 0:826c6171fc1b 124
shimniok 0:826c6171fc1b 125 /**
shimniok 0:826c6171fc1b 126 * @brief Get field x from brief_feature message
shimniok 0:826c6171fc1b 127 *
shimniok 0:826c6171fc1b 128 * @return x position in m
shimniok 0:826c6171fc1b 129 */
shimniok 0:826c6171fc1b 130 static inline float mavlink_msg_brief_feature_get_x(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 131 {
shimniok 0:826c6171fc1b 132 generic_32bit r;
shimniok 0:826c6171fc1b 133 r.b[3] = (msg->payload)[0];
shimniok 0:826c6171fc1b 134 r.b[2] = (msg->payload)[1];
shimniok 0:826c6171fc1b 135 r.b[1] = (msg->payload)[2];
shimniok 0:826c6171fc1b 136 r.b[0] = (msg->payload)[3];
shimniok 0:826c6171fc1b 137 return (float)r.f;
shimniok 0:826c6171fc1b 138 }
shimniok 0:826c6171fc1b 139
shimniok 0:826c6171fc1b 140 /**
shimniok 0:826c6171fc1b 141 * @brief Get field y from brief_feature message
shimniok 0:826c6171fc1b 142 *
shimniok 0:826c6171fc1b 143 * @return y position in m
shimniok 0:826c6171fc1b 144 */
shimniok 0:826c6171fc1b 145 static inline float mavlink_msg_brief_feature_get_y(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 146 {
shimniok 0:826c6171fc1b 147 generic_32bit r;
shimniok 0:826c6171fc1b 148 r.b[3] = (msg->payload+sizeof(float))[0];
shimniok 0:826c6171fc1b 149 r.b[2] = (msg->payload+sizeof(float))[1];
shimniok 0:826c6171fc1b 150 r.b[1] = (msg->payload+sizeof(float))[2];
shimniok 0:826c6171fc1b 151 r.b[0] = (msg->payload+sizeof(float))[3];
shimniok 0:826c6171fc1b 152 return (float)r.f;
shimniok 0:826c6171fc1b 153 }
shimniok 0:826c6171fc1b 154
shimniok 0:826c6171fc1b 155 /**
shimniok 0:826c6171fc1b 156 * @brief Get field z from brief_feature message
shimniok 0:826c6171fc1b 157 *
shimniok 0:826c6171fc1b 158 * @return z position in m
shimniok 0:826c6171fc1b 159 */
shimniok 0:826c6171fc1b 160 static inline float mavlink_msg_brief_feature_get_z(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 161 {
shimniok 0:826c6171fc1b 162 generic_32bit r;
shimniok 0:826c6171fc1b 163 r.b[3] = (msg->payload+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 164 r.b[2] = (msg->payload+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 165 r.b[1] = (msg->payload+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 166 r.b[0] = (msg->payload+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 167 return (float)r.f;
shimniok 0:826c6171fc1b 168 }
shimniok 0:826c6171fc1b 169
shimniok 0:826c6171fc1b 170 /**
shimniok 0:826c6171fc1b 171 * @brief Get field orientation_assignment from brief_feature message
shimniok 0:826c6171fc1b 172 *
shimniok 0:826c6171fc1b 173 * @return Orientation assignment 0: false, 1:true
shimniok 0:826c6171fc1b 174 */
shimniok 0:826c6171fc1b 175 static inline uint8_t mavlink_msg_brief_feature_get_orientation_assignment(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 176 {
shimniok 0:826c6171fc1b 177 return (uint8_t)(msg->payload+sizeof(float)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 178 }
shimniok 0:826c6171fc1b 179
shimniok 0:826c6171fc1b 180 /**
shimniok 0:826c6171fc1b 181 * @brief Get field size from brief_feature message
shimniok 0:826c6171fc1b 182 *
shimniok 0:826c6171fc1b 183 * @return Size in pixels
shimniok 0:826c6171fc1b 184 */
shimniok 0:826c6171fc1b 185 static inline uint16_t mavlink_msg_brief_feature_get_size(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 186 {
shimniok 0:826c6171fc1b 187 generic_16bit r;
shimniok 0:826c6171fc1b 188 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 189 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t))[1];
shimniok 0:826c6171fc1b 190 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 191 }
shimniok 0:826c6171fc1b 192
shimniok 0:826c6171fc1b 193 /**
shimniok 0:826c6171fc1b 194 * @brief Get field orientation from brief_feature message
shimniok 0:826c6171fc1b 195 *
shimniok 0:826c6171fc1b 196 * @return Orientation
shimniok 0:826c6171fc1b 197 */
shimniok 0:826c6171fc1b 198 static inline uint16_t mavlink_msg_brief_feature_get_orientation(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 199 {
shimniok 0:826c6171fc1b 200 generic_16bit r;
shimniok 0:826c6171fc1b 201 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 202 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 203 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 204 }
shimniok 0:826c6171fc1b 205
shimniok 0:826c6171fc1b 206 /**
shimniok 0:826c6171fc1b 207 * @brief Get field descriptor from brief_feature message
shimniok 0:826c6171fc1b 208 *
shimniok 0:826c6171fc1b 209 * @return Descriptor
shimniok 0:826c6171fc1b 210 */
shimniok 0:826c6171fc1b 211 static inline uint16_t mavlink_msg_brief_feature_get_descriptor(const mavlink_message_t* msg, uint8_t* r_data)
shimniok 0:826c6171fc1b 212 {
shimniok 0:826c6171fc1b 213
shimniok 0:826c6171fc1b 214 memcpy(r_data, msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t), sizeof(uint8_t)*32);
shimniok 0:826c6171fc1b 215 return sizeof(uint8_t)*32;
shimniok 0:826c6171fc1b 216 }
shimniok 0:826c6171fc1b 217
shimniok 0:826c6171fc1b 218 /**
shimniok 0:826c6171fc1b 219 * @brief Get field response from brief_feature message
shimniok 0:826c6171fc1b 220 *
shimniok 0:826c6171fc1b 221 * @return Harris operator response at this location
shimniok 0:826c6171fc1b 222 */
shimniok 0:826c6171fc1b 223 static inline float mavlink_msg_brief_feature_get_response(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 224 {
shimniok 0:826c6171fc1b 225 generic_32bit r;
shimniok 0:826c6171fc1b 226 r.b[3] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint8_t)*32)[0];
shimniok 0:826c6171fc1b 227 r.b[2] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint8_t)*32)[1];
shimniok 0:826c6171fc1b 228 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint8_t)*32)[2];
shimniok 0:826c6171fc1b 229 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint8_t)*32)[3];
shimniok 0:826c6171fc1b 230 return (float)r.f;
shimniok 0:826c6171fc1b 231 }
shimniok 0:826c6171fc1b 232
shimniok 0:826c6171fc1b 233 /**
shimniok 0:826c6171fc1b 234 * @brief Decode a brief_feature message into a struct
shimniok 0:826c6171fc1b 235 *
shimniok 0:826c6171fc1b 236 * @param msg The message to decode
shimniok 0:826c6171fc1b 237 * @param brief_feature C-struct to decode the message contents into
shimniok 0:826c6171fc1b 238 */
shimniok 0:826c6171fc1b 239 static inline void mavlink_msg_brief_feature_decode(const mavlink_message_t* msg, mavlink_brief_feature_t* brief_feature)
shimniok 0:826c6171fc1b 240 {
shimniok 0:826c6171fc1b 241 brief_feature->x = mavlink_msg_brief_feature_get_x(msg);
shimniok 0:826c6171fc1b 242 brief_feature->y = mavlink_msg_brief_feature_get_y(msg);
shimniok 0:826c6171fc1b 243 brief_feature->z = mavlink_msg_brief_feature_get_z(msg);
shimniok 0:826c6171fc1b 244 brief_feature->orientation_assignment = mavlink_msg_brief_feature_get_orientation_assignment(msg);
shimniok 0:826c6171fc1b 245 brief_feature->size = mavlink_msg_brief_feature_get_size(msg);
shimniok 0:826c6171fc1b 246 brief_feature->orientation = mavlink_msg_brief_feature_get_orientation(msg);
shimniok 0:826c6171fc1b 247 mavlink_msg_brief_feature_get_descriptor(msg, brief_feature->descriptor);
shimniok 0:826c6171fc1b 248 brief_feature->response = mavlink_msg_brief_feature_get_response(msg);
shimniok 0:826c6171fc1b 249 }