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 SAFETY_ALLOWED_AREA PACKING
shimniok 0:826c6171fc1b 2
shimniok 0:826c6171fc1b 3 #define MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA 54
shimniok 0:826c6171fc1b 4
shimniok 0:826c6171fc1b 5 typedef struct __mavlink_safety_allowed_area_t
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 uint8_t frame; ///< Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 8 float p1x; ///< x position 1 / Latitude 1
shimniok 0:826c6171fc1b 9 float p1y; ///< y position 1 / Longitude 1
shimniok 0:826c6171fc1b 10 float p1z; ///< z position 1 / Altitude 1
shimniok 0:826c6171fc1b 11 float p2x; ///< x position 2 / Latitude 2
shimniok 0:826c6171fc1b 12 float p2y; ///< y position 2 / Longitude 2
shimniok 0:826c6171fc1b 13 float p2z; ///< z position 2 / Altitude 2
shimniok 0:826c6171fc1b 14
shimniok 0:826c6171fc1b 15 } mavlink_safety_allowed_area_t;
shimniok 0:826c6171fc1b 16
shimniok 0:826c6171fc1b 17
shimniok 0:826c6171fc1b 18
shimniok 0:826c6171fc1b 19 /**
shimniok 0:826c6171fc1b 20 * @brief Pack a safety_allowed_area message
shimniok 0:826c6171fc1b 21 * @param system_id ID of this system
shimniok 0:826c6171fc1b 22 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 23 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 24 *
shimniok 0:826c6171fc1b 25 * @param frame Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 26 * @param p1x x position 1 / Latitude 1
shimniok 0:826c6171fc1b 27 * @param p1y y position 1 / Longitude 1
shimniok 0:826c6171fc1b 28 * @param p1z z position 1 / Altitude 1
shimniok 0:826c6171fc1b 29 * @param p2x x position 2 / Latitude 2
shimniok 0:826c6171fc1b 30 * @param p2y y position 2 / Longitude 2
shimniok 0:826c6171fc1b 31 * @param p2z z position 2 / Altitude 2
shimniok 0:826c6171fc1b 32 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 33 */
shimniok 0:826c6171fc1b 34 static inline uint16_t mavlink_msg_safety_allowed_area_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t frame, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z)
shimniok 0:826c6171fc1b 35 {
shimniok 0:826c6171fc1b 36 uint16_t i = 0;
shimniok 0:826c6171fc1b 37 msg->msgid = MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA;
shimniok 0:826c6171fc1b 38
shimniok 0:826c6171fc1b 39 i += put_uint8_t_by_index(frame, i, msg->payload); // Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 40 i += put_float_by_index(p1x, i, msg->payload); // x position 1 / Latitude 1
shimniok 0:826c6171fc1b 41 i += put_float_by_index(p1y, i, msg->payload); // y position 1 / Longitude 1
shimniok 0:826c6171fc1b 42 i += put_float_by_index(p1z, i, msg->payload); // z position 1 / Altitude 1
shimniok 0:826c6171fc1b 43 i += put_float_by_index(p2x, i, msg->payload); // x position 2 / Latitude 2
shimniok 0:826c6171fc1b 44 i += put_float_by_index(p2y, i, msg->payload); // y position 2 / Longitude 2
shimniok 0:826c6171fc1b 45 i += put_float_by_index(p2z, i, msg->payload); // z position 2 / Altitude 2
shimniok 0:826c6171fc1b 46
shimniok 0:826c6171fc1b 47 return mavlink_finalize_message(msg, system_id, component_id, i);
shimniok 0:826c6171fc1b 48 }
shimniok 0:826c6171fc1b 49
shimniok 0:826c6171fc1b 50 /**
shimniok 0:826c6171fc1b 51 * @brief Pack a safety_allowed_area message
shimniok 0:826c6171fc1b 52 * @param system_id ID of this system
shimniok 0:826c6171fc1b 53 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 54 * @param chan The MAVLink channel this message was sent over
shimniok 0:826c6171fc1b 55 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 56 * @param frame Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 57 * @param p1x x position 1 / Latitude 1
shimniok 0:826c6171fc1b 58 * @param p1y y position 1 / Longitude 1
shimniok 0:826c6171fc1b 59 * @param p1z z position 1 / Altitude 1
shimniok 0:826c6171fc1b 60 * @param p2x x position 2 / Latitude 2
shimniok 0:826c6171fc1b 61 * @param p2y y position 2 / Longitude 2
shimniok 0:826c6171fc1b 62 * @param p2z z position 2 / Altitude 2
shimniok 0:826c6171fc1b 63 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 64 */
shimniok 0:826c6171fc1b 65 static inline uint16_t mavlink_msg_safety_allowed_area_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t frame, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z)
shimniok 0:826c6171fc1b 66 {
shimniok 0:826c6171fc1b 67 uint16_t i = 0;
shimniok 0:826c6171fc1b 68 msg->msgid = MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA;
shimniok 0:826c6171fc1b 69
shimniok 0:826c6171fc1b 70 i += put_uint8_t_by_index(frame, i, msg->payload); // Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 71 i += put_float_by_index(p1x, i, msg->payload); // x position 1 / Latitude 1
shimniok 0:826c6171fc1b 72 i += put_float_by_index(p1y, i, msg->payload); // y position 1 / Longitude 1
shimniok 0:826c6171fc1b 73 i += put_float_by_index(p1z, i, msg->payload); // z position 1 / Altitude 1
shimniok 0:826c6171fc1b 74 i += put_float_by_index(p2x, i, msg->payload); // x position 2 / Latitude 2
shimniok 0:826c6171fc1b 75 i += put_float_by_index(p2y, i, msg->payload); // y position 2 / Longitude 2
shimniok 0:826c6171fc1b 76 i += put_float_by_index(p2z, i, msg->payload); // z position 2 / Altitude 2
shimniok 0:826c6171fc1b 77
shimniok 0:826c6171fc1b 78 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
shimniok 0:826c6171fc1b 79 }
shimniok 0:826c6171fc1b 80
shimniok 0:826c6171fc1b 81 /**
shimniok 0:826c6171fc1b 82 * @brief Encode a safety_allowed_area struct into a message
shimniok 0:826c6171fc1b 83 *
shimniok 0:826c6171fc1b 84 * @param system_id ID of this system
shimniok 0:826c6171fc1b 85 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 86 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 87 * @param safety_allowed_area C-struct to read the message contents from
shimniok 0:826c6171fc1b 88 */
shimniok 0:826c6171fc1b 89 static inline uint16_t mavlink_msg_safety_allowed_area_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_safety_allowed_area_t* safety_allowed_area)
shimniok 0:826c6171fc1b 90 {
shimniok 0:826c6171fc1b 91 return mavlink_msg_safety_allowed_area_pack(system_id, component_id, msg, safety_allowed_area->frame, safety_allowed_area->p1x, safety_allowed_area->p1y, safety_allowed_area->p1z, safety_allowed_area->p2x, safety_allowed_area->p2y, safety_allowed_area->p2z);
shimniok 0:826c6171fc1b 92 }
shimniok 0:826c6171fc1b 93
shimniok 0:826c6171fc1b 94 /**
shimniok 0:826c6171fc1b 95 * @brief Send a safety_allowed_area message
shimniok 0:826c6171fc1b 96 * @param chan MAVLink channel to send the message
shimniok 0:826c6171fc1b 97 *
shimniok 0:826c6171fc1b 98 * @param frame Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 99 * @param p1x x position 1 / Latitude 1
shimniok 0:826c6171fc1b 100 * @param p1y y position 1 / Longitude 1
shimniok 0:826c6171fc1b 101 * @param p1z z position 1 / Altitude 1
shimniok 0:826c6171fc1b 102 * @param p2x x position 2 / Latitude 2
shimniok 0:826c6171fc1b 103 * @param p2y y position 2 / Longitude 2
shimniok 0:826c6171fc1b 104 * @param p2z z position 2 / Altitude 2
shimniok 0:826c6171fc1b 105 */
shimniok 0:826c6171fc1b 106 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
shimniok 0:826c6171fc1b 107
shimniok 0:826c6171fc1b 108 static inline void mavlink_msg_safety_allowed_area_send(mavlink_channel_t chan, uint8_t frame, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z)
shimniok 0:826c6171fc1b 109 {
shimniok 0:826c6171fc1b 110 mavlink_message_t msg;
shimniok 0:826c6171fc1b 111 mavlink_msg_safety_allowed_area_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, frame, p1x, p1y, p1z, p2x, p2y, p2z);
shimniok 0:826c6171fc1b 112 mavlink_send_uart(chan, &msg);
shimniok 0:826c6171fc1b 113 }
shimniok 0:826c6171fc1b 114
shimniok 0:826c6171fc1b 115 #endif
shimniok 0:826c6171fc1b 116 // MESSAGE SAFETY_ALLOWED_AREA UNPACKING
shimniok 0:826c6171fc1b 117
shimniok 0:826c6171fc1b 118 /**
shimniok 0:826c6171fc1b 119 * @brief Get field frame from safety_allowed_area message
shimniok 0:826c6171fc1b 120 *
shimniok 0:826c6171fc1b 121 * @return Coordinate frame, as defined by MAV_FRAME enum in mavlink_types.h. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down.
shimniok 0:826c6171fc1b 122 */
shimniok 0:826c6171fc1b 123 static inline uint8_t mavlink_msg_safety_allowed_area_get_frame(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 124 {
shimniok 0:826c6171fc1b 125 return (uint8_t)(msg->payload)[0];
shimniok 0:826c6171fc1b 126 }
shimniok 0:826c6171fc1b 127
shimniok 0:826c6171fc1b 128 /**
shimniok 0:826c6171fc1b 129 * @brief Get field p1x from safety_allowed_area message
shimniok 0:826c6171fc1b 130 *
shimniok 0:826c6171fc1b 131 * @return x position 1 / Latitude 1
shimniok 0:826c6171fc1b 132 */
shimniok 0:826c6171fc1b 133 static inline float mavlink_msg_safety_allowed_area_get_p1x(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 134 {
shimniok 0:826c6171fc1b 135 generic_32bit r;
shimniok 0:826c6171fc1b 136 r.b[3] = (msg->payload+sizeof(uint8_t))[0];
shimniok 0:826c6171fc1b 137 r.b[2] = (msg->payload+sizeof(uint8_t))[1];
shimniok 0:826c6171fc1b 138 r.b[1] = (msg->payload+sizeof(uint8_t))[2];
shimniok 0:826c6171fc1b 139 r.b[0] = (msg->payload+sizeof(uint8_t))[3];
shimniok 0:826c6171fc1b 140 return (float)r.f;
shimniok 0:826c6171fc1b 141 }
shimniok 0:826c6171fc1b 142
shimniok 0:826c6171fc1b 143 /**
shimniok 0:826c6171fc1b 144 * @brief Get field p1y from safety_allowed_area message
shimniok 0:826c6171fc1b 145 *
shimniok 0:826c6171fc1b 146 * @return y position 1 / Longitude 1
shimniok 0:826c6171fc1b 147 */
shimniok 0:826c6171fc1b 148 static inline float mavlink_msg_safety_allowed_area_get_p1y(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 149 {
shimniok 0:826c6171fc1b 150 generic_32bit r;
shimniok 0:826c6171fc1b 151 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float))[0];
shimniok 0:826c6171fc1b 152 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float))[1];
shimniok 0:826c6171fc1b 153 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float))[2];
shimniok 0:826c6171fc1b 154 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float))[3];
shimniok 0:826c6171fc1b 155 return (float)r.f;
shimniok 0:826c6171fc1b 156 }
shimniok 0:826c6171fc1b 157
shimniok 0:826c6171fc1b 158 /**
shimniok 0:826c6171fc1b 159 * @brief Get field p1z from safety_allowed_area message
shimniok 0:826c6171fc1b 160 *
shimniok 0:826c6171fc1b 161 * @return z position 1 / Altitude 1
shimniok 0:826c6171fc1b 162 */
shimniok 0:826c6171fc1b 163 static inline float mavlink_msg_safety_allowed_area_get_p1z(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 164 {
shimniok 0:826c6171fc1b 165 generic_32bit r;
shimniok 0:826c6171fc1b 166 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 167 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 168 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 169 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 170 return (float)r.f;
shimniok 0:826c6171fc1b 171 }
shimniok 0:826c6171fc1b 172
shimniok 0:826c6171fc1b 173 /**
shimniok 0:826c6171fc1b 174 * @brief Get field p2x from safety_allowed_area message
shimniok 0:826c6171fc1b 175 *
shimniok 0:826c6171fc1b 176 * @return x position 2 / Latitude 2
shimniok 0:826c6171fc1b 177 */
shimniok 0:826c6171fc1b 178 static inline float mavlink_msg_safety_allowed_area_get_p2x(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 179 {
shimniok 0:826c6171fc1b 180 generic_32bit r;
shimniok 0:826c6171fc1b 181 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 182 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 183 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 184 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 185 return (float)r.f;
shimniok 0:826c6171fc1b 186 }
shimniok 0:826c6171fc1b 187
shimniok 0:826c6171fc1b 188 /**
shimniok 0:826c6171fc1b 189 * @brief Get field p2y from safety_allowed_area message
shimniok 0:826c6171fc1b 190 *
shimniok 0:826c6171fc1b 191 * @return y position 2 / Longitude 2
shimniok 0:826c6171fc1b 192 */
shimniok 0:826c6171fc1b 193 static inline float mavlink_msg_safety_allowed_area_get_p2y(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 194 {
shimniok 0:826c6171fc1b 195 generic_32bit r;
shimniok 0:826c6171fc1b 196 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 197 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 198 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 199 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 200 return (float)r.f;
shimniok 0:826c6171fc1b 201 }
shimniok 0:826c6171fc1b 202
shimniok 0:826c6171fc1b 203 /**
shimniok 0:826c6171fc1b 204 * @brief Get field p2z from safety_allowed_area message
shimniok 0:826c6171fc1b 205 *
shimniok 0:826c6171fc1b 206 * @return z position 2 / Altitude 2
shimniok 0:826c6171fc1b 207 */
shimniok 0:826c6171fc1b 208 static inline float mavlink_msg_safety_allowed_area_get_p2z(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 209 {
shimniok 0:826c6171fc1b 210 generic_32bit r;
shimniok 0:826c6171fc1b 211 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
shimniok 0:826c6171fc1b 212 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
shimniok 0:826c6171fc1b 213 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
shimniok 0:826c6171fc1b 214 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
shimniok 0:826c6171fc1b 215 return (float)r.f;
shimniok 0:826c6171fc1b 216 }
shimniok 0:826c6171fc1b 217
shimniok 0:826c6171fc1b 218 /**
shimniok 0:826c6171fc1b 219 * @brief Decode a safety_allowed_area message into a struct
shimniok 0:826c6171fc1b 220 *
shimniok 0:826c6171fc1b 221 * @param msg The message to decode
shimniok 0:826c6171fc1b 222 * @param safety_allowed_area C-struct to decode the message contents into
shimniok 0:826c6171fc1b 223 */
shimniok 0:826c6171fc1b 224 static inline void mavlink_msg_safety_allowed_area_decode(const mavlink_message_t* msg, mavlink_safety_allowed_area_t* safety_allowed_area)
shimniok 0:826c6171fc1b 225 {
shimniok 0:826c6171fc1b 226 safety_allowed_area->frame = mavlink_msg_safety_allowed_area_get_frame(msg);
shimniok 0:826c6171fc1b 227 safety_allowed_area->p1x = mavlink_msg_safety_allowed_area_get_p1x(msg);
shimniok 0:826c6171fc1b 228 safety_allowed_area->p1y = mavlink_msg_safety_allowed_area_get_p1y(msg);
shimniok 0:826c6171fc1b 229 safety_allowed_area->p1z = mavlink_msg_safety_allowed_area_get_p1z(msg);
shimniok 0:826c6171fc1b 230 safety_allowed_area->p2x = mavlink_msg_safety_allowed_area_get_p2x(msg);
shimniok 0:826c6171fc1b 231 safety_allowed_area->p2y = mavlink_msg_safety_allowed_area_get_p2y(msg);
shimniok 0:826c6171fc1b 232 safety_allowed_area->p2z = mavlink_msg_safety_allowed_area_get_p2z(msg);
shimniok 0:826c6171fc1b 233 }