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 POINT_OF_INTEREST PACKING
shimniok 0:826c6171fc1b 2
shimniok 0:826c6171fc1b 3 #define MAVLINK_MSG_ID_POINT_OF_INTEREST 161
shimniok 0:826c6171fc1b 4
shimniok 0:826c6171fc1b 5 typedef struct __mavlink_point_of_interest_t
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 uint8_t type; ///< 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 8 uint8_t color; ///< 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 9 uint8_t coordinate_system; ///< 0: global, 1:local
shimniok 0:826c6171fc1b 10 uint16_t timeout; ///< 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 11 float x; ///< X Position
shimniok 0:826c6171fc1b 12 float y; ///< Y Position
shimniok 0:826c6171fc1b 13 float z; ///< Z Position
shimniok 0:826c6171fc1b 14 int8_t name[25]; ///< POI name
shimniok 0:826c6171fc1b 15
shimniok 0:826c6171fc1b 16 } mavlink_point_of_interest_t;
shimniok 0:826c6171fc1b 17
shimniok 0:826c6171fc1b 18 #define MAVLINK_MSG_POINT_OF_INTEREST_FIELD_NAME_LEN 25
shimniok 0:826c6171fc1b 19
shimniok 0:826c6171fc1b 20
shimniok 0:826c6171fc1b 21 /**
shimniok 0:826c6171fc1b 22 * @brief Pack a point_of_interest 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 type 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 28 * @param color 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 29 * @param coordinate_system 0: global, 1:local
shimniok 0:826c6171fc1b 30 * @param timeout 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 31 * @param x X Position
shimniok 0:826c6171fc1b 32 * @param y Y Position
shimniok 0:826c6171fc1b 33 * @param z Z Position
shimniok 0:826c6171fc1b 34 * @param name POI name
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_point_of_interest_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t type, uint8_t color, uint8_t coordinate_system, uint16_t timeout, float x, float y, float z, const int8_t* name)
shimniok 0:826c6171fc1b 38 {
shimniok 0:826c6171fc1b 39 uint16_t i = 0;
shimniok 0:826c6171fc1b 40 msg->msgid = MAVLINK_MSG_ID_POINT_OF_INTEREST;
shimniok 0:826c6171fc1b 41
shimniok 0:826c6171fc1b 42 i += put_uint8_t_by_index(type, i, msg->payload); // 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 43 i += put_uint8_t_by_index(color, i, msg->payload); // 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 44 i += put_uint8_t_by_index(coordinate_system, i, msg->payload); // 0: global, 1:local
shimniok 0:826c6171fc1b 45 i += put_uint16_t_by_index(timeout, i, msg->payload); // 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 46 i += put_float_by_index(x, i, msg->payload); // X Position
shimniok 0:826c6171fc1b 47 i += put_float_by_index(y, i, msg->payload); // Y Position
shimniok 0:826c6171fc1b 48 i += put_float_by_index(z, i, msg->payload); // Z Position
shimniok 0:826c6171fc1b 49 i += put_array_by_index(name, 25, i, msg->payload); // POI name
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 point_of_interest 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 type 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 61 * @param color 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 62 * @param coordinate_system 0: global, 1:local
shimniok 0:826c6171fc1b 63 * @param timeout 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 64 * @param x X Position
shimniok 0:826c6171fc1b 65 * @param y Y Position
shimniok 0:826c6171fc1b 66 * @param z Z Position
shimniok 0:826c6171fc1b 67 * @param name POI name
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_point_of_interest_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t type, uint8_t color, uint8_t coordinate_system, uint16_t timeout, float x, float y, float z, const int8_t* name)
shimniok 0:826c6171fc1b 71 {
shimniok 0:826c6171fc1b 72 uint16_t i = 0;
shimniok 0:826c6171fc1b 73 msg->msgid = MAVLINK_MSG_ID_POINT_OF_INTEREST;
shimniok 0:826c6171fc1b 74
shimniok 0:826c6171fc1b 75 i += put_uint8_t_by_index(type, i, msg->payload); // 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 76 i += put_uint8_t_by_index(color, i, msg->payload); // 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 77 i += put_uint8_t_by_index(coordinate_system, i, msg->payload); // 0: global, 1:local
shimniok 0:826c6171fc1b 78 i += put_uint16_t_by_index(timeout, i, msg->payload); // 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 79 i += put_float_by_index(x, i, msg->payload); // X Position
shimniok 0:826c6171fc1b 80 i += put_float_by_index(y, i, msg->payload); // Y Position
shimniok 0:826c6171fc1b 81 i += put_float_by_index(z, i, msg->payload); // Z Position
shimniok 0:826c6171fc1b 82 i += put_array_by_index(name, 25, i, msg->payload); // POI name
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 point_of_interest 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 point_of_interest C-struct to read the message contents from
shimniok 0:826c6171fc1b 94 */
shimniok 0:826c6171fc1b 95 static inline uint16_t mavlink_msg_point_of_interest_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_point_of_interest_t* point_of_interest)
shimniok 0:826c6171fc1b 96 {
shimniok 0:826c6171fc1b 97 return mavlink_msg_point_of_interest_pack(system_id, component_id, msg, point_of_interest->type, point_of_interest->color, point_of_interest->coordinate_system, point_of_interest->timeout, point_of_interest->x, point_of_interest->y, point_of_interest->z, point_of_interest->name);
shimniok 0:826c6171fc1b 98 }
shimniok 0:826c6171fc1b 99
shimniok 0:826c6171fc1b 100 /**
shimniok 0:826c6171fc1b 101 * @brief Send a point_of_interest message
shimniok 0:826c6171fc1b 102 * @param chan MAVLink channel to send the message
shimniok 0:826c6171fc1b 103 *
shimniok 0:826c6171fc1b 104 * @param type 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 105 * @param color 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 106 * @param coordinate_system 0: global, 1:local
shimniok 0:826c6171fc1b 107 * @param timeout 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 108 * @param x X Position
shimniok 0:826c6171fc1b 109 * @param y Y Position
shimniok 0:826c6171fc1b 110 * @param z Z Position
shimniok 0:826c6171fc1b 111 * @param name POI name
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_point_of_interest_send(mavlink_channel_t chan, uint8_t type, uint8_t color, uint8_t coordinate_system, uint16_t timeout, float x, float y, float z, const int8_t* name)
shimniok 0:826c6171fc1b 116 {
shimniok 0:826c6171fc1b 117 mavlink_message_t msg;
shimniok 0:826c6171fc1b 118 mavlink_msg_point_of_interest_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, type, color, coordinate_system, timeout, x, y, z, name);
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 POINT_OF_INTEREST UNPACKING
shimniok 0:826c6171fc1b 124
shimniok 0:826c6171fc1b 125 /**
shimniok 0:826c6171fc1b 126 * @brief Get field type from point_of_interest message
shimniok 0:826c6171fc1b 127 *
shimniok 0:826c6171fc1b 128 * @return 0: Notice, 1: Warning, 2: Critical, 3: Emergency, 4: Debug
shimniok 0:826c6171fc1b 129 */
shimniok 0:826c6171fc1b 130 static inline uint8_t mavlink_msg_point_of_interest_get_type(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 131 {
shimniok 0:826c6171fc1b 132 return (uint8_t)(msg->payload)[0];
shimniok 0:826c6171fc1b 133 }
shimniok 0:826c6171fc1b 134
shimniok 0:826c6171fc1b 135 /**
shimniok 0:826c6171fc1b 136 * @brief Get field color from point_of_interest message
shimniok 0:826c6171fc1b 137 *
shimniok 0:826c6171fc1b 138 * @return 0: blue, 1: yellow, 2: red, 3: orange, 4: green, 5: magenta
shimniok 0:826c6171fc1b 139 */
shimniok 0:826c6171fc1b 140 static inline uint8_t mavlink_msg_point_of_interest_get_color(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 141 {
shimniok 0:826c6171fc1b 142 return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 143 }
shimniok 0:826c6171fc1b 144
shimniok 0:826c6171fc1b 145 /**
shimniok 0:826c6171fc1b 146 * @brief Get field coordinate_system from point_of_interest message
shimniok 0:826c6171fc1b 147 *
shimniok 0:826c6171fc1b 148 * @return 0: global, 1:local
shimniok 0:826c6171fc1b 149 */
shimniok 0:826c6171fc1b 150 static inline uint8_t mavlink_msg_point_of_interest_get_coordinate_system(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 151 {
shimniok 0:826c6171fc1b 152 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 153 }
shimniok 0:826c6171fc1b 154
shimniok 0:826c6171fc1b 155 /**
shimniok 0:826c6171fc1b 156 * @brief Get field timeout from point_of_interest message
shimniok 0:826c6171fc1b 157 *
shimniok 0:826c6171fc1b 158 * @return 0: no timeout, >1: timeout in seconds
shimniok 0:826c6171fc1b 159 */
shimniok 0:826c6171fc1b 160 static inline uint16_t mavlink_msg_point_of_interest_get_timeout(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 161 {
shimniok 0:826c6171fc1b 162 generic_16bit r;
shimniok 0:826c6171fc1b 163 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 164 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[1];
shimniok 0:826c6171fc1b 165 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 166 }
shimniok 0:826c6171fc1b 167
shimniok 0:826c6171fc1b 168 /**
shimniok 0:826c6171fc1b 169 * @brief Get field x from point_of_interest message
shimniok 0:826c6171fc1b 170 *
shimniok 0:826c6171fc1b 171 * @return X Position
shimniok 0:826c6171fc1b 172 */
shimniok 0:826c6171fc1b 173 static inline float mavlink_msg_point_of_interest_get_x(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 174 {
shimniok 0:826c6171fc1b 175 generic_32bit r;
shimniok 0:826c6171fc1b 176 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 177 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 178 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t))[2];
shimniok 0:826c6171fc1b 179 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t))[3];
shimniok 0:826c6171fc1b 180 return (float)r.f;
shimniok 0:826c6171fc1b 181 }
shimniok 0:826c6171fc1b 182
shimniok 0:826c6171fc1b 183 /**
shimniok 0:826c6171fc1b 184 * @brief Get field y from point_of_interest message
shimniok 0:826c6171fc1b 185 *
shimniok 0:826c6171fc1b 186 * @return Y Position
shimniok 0:826c6171fc1b 187 */
shimniok 0:826c6171fc1b 188 static inline float mavlink_msg_point_of_interest_get_y(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 189 {
shimniok 0:826c6171fc1b 190 generic_32bit r;
shimniok 0:826c6171fc1b 191 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float))[0];
shimniok 0:826c6171fc1b 192 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float))[1];
shimniok 0:826c6171fc1b 193 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float))[2];
shimniok 0:826c6171fc1b 194 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float))[3];
shimniok 0:826c6171fc1b 195 return (float)r.f;
shimniok 0:826c6171fc1b 196 }
shimniok 0:826c6171fc1b 197
shimniok 0:826c6171fc1b 198 /**
shimniok 0:826c6171fc1b 199 * @brief Get field z from point_of_interest message
shimniok 0:826c6171fc1b 200 *
shimniok 0:826c6171fc1b 201 * @return Z Position
shimniok 0:826c6171fc1b 202 */
shimniok 0:826c6171fc1b 203 static inline float mavlink_msg_point_of_interest_get_z(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 204 {
shimniok 0:826c6171fc1b 205 generic_32bit r;
shimniok 0:826c6171fc1b 206 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 207 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 208 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 209 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 210 return (float)r.f;
shimniok 0:826c6171fc1b 211 }
shimniok 0:826c6171fc1b 212
shimniok 0:826c6171fc1b 213 /**
shimniok 0:826c6171fc1b 214 * @brief Get field name from point_of_interest message
shimniok 0:826c6171fc1b 215 *
shimniok 0:826c6171fc1b 216 * @return POI name
shimniok 0:826c6171fc1b 217 */
shimniok 0:826c6171fc1b 218 static inline uint16_t mavlink_msg_point_of_interest_get_name(const mavlink_message_t* msg, int8_t* r_data)
shimniok 0:826c6171fc1b 219 {
shimniok 0:826c6171fc1b 220
shimniok 0:826c6171fc1b 221 memcpy(r_data, msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(float)+sizeof(float)+sizeof(float), 25);
shimniok 0:826c6171fc1b 222 return 25;
shimniok 0:826c6171fc1b 223 }
shimniok 0:826c6171fc1b 224
shimniok 0:826c6171fc1b 225 /**
shimniok 0:826c6171fc1b 226 * @brief Decode a point_of_interest message into a struct
shimniok 0:826c6171fc1b 227 *
shimniok 0:826c6171fc1b 228 * @param msg The message to decode
shimniok 0:826c6171fc1b 229 * @param point_of_interest C-struct to decode the message contents into
shimniok 0:826c6171fc1b 230 */
shimniok 0:826c6171fc1b 231 static inline void mavlink_msg_point_of_interest_decode(const mavlink_message_t* msg, mavlink_point_of_interest_t* point_of_interest)
shimniok 0:826c6171fc1b 232 {
shimniok 0:826c6171fc1b 233 point_of_interest->type = mavlink_msg_point_of_interest_get_type(msg);
shimniok 0:826c6171fc1b 234 point_of_interest->color = mavlink_msg_point_of_interest_get_color(msg);
shimniok 0:826c6171fc1b 235 point_of_interest->coordinate_system = mavlink_msg_point_of_interest_get_coordinate_system(msg);
shimniok 0:826c6171fc1b 236 point_of_interest->timeout = mavlink_msg_point_of_interest_get_timeout(msg);
shimniok 0:826c6171fc1b 237 point_of_interest->x = mavlink_msg_point_of_interest_get_x(msg);
shimniok 0:826c6171fc1b 238 point_of_interest->y = mavlink_msg_point_of_interest_get_y(msg);
shimniok 0:826c6171fc1b 239 point_of_interest->z = mavlink_msg_point_of_interest_get_z(msg);
shimniok 0:826c6171fc1b 240 mavlink_msg_point_of_interest_get_name(msg, point_of_interest->name);
shimniok 0:826c6171fc1b 241 }