Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/common/mavlink_msg_object_detection_event.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE OBJECT_DETECTION_EVENT PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT 140 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_object_detection_event_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint32_t time; ///< Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 8 | uint16_t object_id; ///< Object ID |
shimniok | 0:826c6171fc1b | 9 | uint8_t type; ///< Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 10 | char name[20]; ///< Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 11 | uint8_t quality; ///< Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 12 | float bearing; ///< Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 13 | float distance; ///< Ground distance in meters |
shimniok | 0:826c6171fc1b | 14 | |
shimniok | 0:826c6171fc1b | 15 | } mavlink_object_detection_event_t; |
shimniok | 0:826c6171fc1b | 16 | |
shimniok | 0:826c6171fc1b | 17 | #define MAVLINK_MSG_OBJECT_DETECTION_EVENT_FIELD_NAME_LEN 20 |
shimniok | 0:826c6171fc1b | 18 | |
shimniok | 0:826c6171fc1b | 19 | |
shimniok | 0:826c6171fc1b | 20 | /** |
shimniok | 0:826c6171fc1b | 21 | * @brief Pack a object_detection_event message |
shimniok | 0:826c6171fc1b | 22 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 23 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 24 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 25 | * |
shimniok | 0:826c6171fc1b | 26 | * @param time Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 27 | * @param object_id Object ID |
shimniok | 0:826c6171fc1b | 28 | * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 29 | * @param name Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 30 | * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 31 | * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 32 | * @param distance Ground distance in meters |
shimniok | 0:826c6171fc1b | 33 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 34 | */ |
shimniok | 0:826c6171fc1b | 35 | static inline uint16_t mavlink_msg_object_detection_event_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t time, uint16_t object_id, uint8_t type, const char* name, uint8_t quality, float bearing, float distance) |
shimniok | 0:826c6171fc1b | 36 | { |
shimniok | 0:826c6171fc1b | 37 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 38 | msg->msgid = MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT; |
shimniok | 0:826c6171fc1b | 39 | |
shimniok | 0:826c6171fc1b | 40 | i += put_uint32_t_by_index(time, i, msg->payload); // Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 41 | i += put_uint16_t_by_index(object_id, i, msg->payload); // Object ID |
shimniok | 0:826c6171fc1b | 42 | i += put_uint8_t_by_index(type, i, msg->payload); // Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 43 | i += put_array_by_index((const int8_t*)name, sizeof(char)*20, i, msg->payload); // Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 44 | i += put_uint8_t_by_index(quality, i, msg->payload); // Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 45 | i += put_float_by_index(bearing, i, msg->payload); // Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 46 | i += put_float_by_index(distance, i, msg->payload); // Ground distance in meters |
shimniok | 0:826c6171fc1b | 47 | |
shimniok | 0:826c6171fc1b | 48 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 49 | } |
shimniok | 0:826c6171fc1b | 50 | |
shimniok | 0:826c6171fc1b | 51 | /** |
shimniok | 0:826c6171fc1b | 52 | * @brief Pack a object_detection_event message |
shimniok | 0:826c6171fc1b | 53 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 54 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 55 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 56 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 57 | * @param time Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 58 | * @param object_id Object ID |
shimniok | 0:826c6171fc1b | 59 | * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 60 | * @param name Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 61 | * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 62 | * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 63 | * @param distance Ground distance in meters |
shimniok | 0:826c6171fc1b | 64 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 65 | */ |
shimniok | 0:826c6171fc1b | 66 | static inline uint16_t mavlink_msg_object_detection_event_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint32_t time, uint16_t object_id, uint8_t type, const char* name, uint8_t quality, float bearing, float distance) |
shimniok | 0:826c6171fc1b | 67 | { |
shimniok | 0:826c6171fc1b | 68 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 69 | msg->msgid = MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT; |
shimniok | 0:826c6171fc1b | 70 | |
shimniok | 0:826c6171fc1b | 71 | i += put_uint32_t_by_index(time, i, msg->payload); // Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 72 | i += put_uint16_t_by_index(object_id, i, msg->payload); // Object ID |
shimniok | 0:826c6171fc1b | 73 | i += put_uint8_t_by_index(type, i, msg->payload); // Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 74 | i += put_array_by_index((const int8_t*)name, sizeof(char)*20, i, msg->payload); // Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 75 | i += put_uint8_t_by_index(quality, i, msg->payload); // Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 76 | i += put_float_by_index(bearing, i, msg->payload); // Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 77 | i += put_float_by_index(distance, i, msg->payload); // Ground distance in meters |
shimniok | 0:826c6171fc1b | 78 | |
shimniok | 0:826c6171fc1b | 79 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 80 | } |
shimniok | 0:826c6171fc1b | 81 | |
shimniok | 0:826c6171fc1b | 82 | /** |
shimniok | 0:826c6171fc1b | 83 | * @brief Encode a object_detection_event struct into a message |
shimniok | 0:826c6171fc1b | 84 | * |
shimniok | 0:826c6171fc1b | 85 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 86 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 87 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 88 | * @param object_detection_event C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 89 | */ |
shimniok | 0:826c6171fc1b | 90 | static inline uint16_t mavlink_msg_object_detection_event_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_object_detection_event_t* object_detection_event) |
shimniok | 0:826c6171fc1b | 91 | { |
shimniok | 0:826c6171fc1b | 92 | return mavlink_msg_object_detection_event_pack(system_id, component_id, msg, object_detection_event->time, object_detection_event->object_id, object_detection_event->type, object_detection_event->name, object_detection_event->quality, object_detection_event->bearing, object_detection_event->distance); |
shimniok | 0:826c6171fc1b | 93 | } |
shimniok | 0:826c6171fc1b | 94 | |
shimniok | 0:826c6171fc1b | 95 | /** |
shimniok | 0:826c6171fc1b | 96 | * @brief Send a object_detection_event message |
shimniok | 0:826c6171fc1b | 97 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 98 | * |
shimniok | 0:826c6171fc1b | 99 | * @param time Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 100 | * @param object_id Object ID |
shimniok | 0:826c6171fc1b | 101 | * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 102 | * @param name Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 103 | * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 104 | * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 105 | * @param distance Ground distance in meters |
shimniok | 0:826c6171fc1b | 106 | */ |
shimniok | 0:826c6171fc1b | 107 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 108 | |
shimniok | 0:826c6171fc1b | 109 | static inline void mavlink_msg_object_detection_event_send(mavlink_channel_t chan, uint32_t time, uint16_t object_id, uint8_t type, const char* name, uint8_t quality, float bearing, float distance) |
shimniok | 0:826c6171fc1b | 110 | { |
shimniok | 0:826c6171fc1b | 111 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 112 | mavlink_msg_object_detection_event_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, time, object_id, type, name, quality, bearing, distance); |
shimniok | 0:826c6171fc1b | 113 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 114 | } |
shimniok | 0:826c6171fc1b | 115 | |
shimniok | 0:826c6171fc1b | 116 | #endif |
shimniok | 0:826c6171fc1b | 117 | // MESSAGE OBJECT_DETECTION_EVENT UNPACKING |
shimniok | 0:826c6171fc1b | 118 | |
shimniok | 0:826c6171fc1b | 119 | /** |
shimniok | 0:826c6171fc1b | 120 | * @brief Get field time from object_detection_event message |
shimniok | 0:826c6171fc1b | 121 | * |
shimniok | 0:826c6171fc1b | 122 | * @return Timestamp in milliseconds since system boot |
shimniok | 0:826c6171fc1b | 123 | */ |
shimniok | 0:826c6171fc1b | 124 | static inline uint32_t mavlink_msg_object_detection_event_get_time(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 125 | { |
shimniok | 0:826c6171fc1b | 126 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 127 | r.b[3] = (msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 128 | r.b[2] = (msg->payload)[1]; |
shimniok | 0:826c6171fc1b | 129 | r.b[1] = (msg->payload)[2]; |
shimniok | 0:826c6171fc1b | 130 | r.b[0] = (msg->payload)[3]; |
shimniok | 0:826c6171fc1b | 131 | return (uint32_t)r.i; |
shimniok | 0:826c6171fc1b | 132 | } |
shimniok | 0:826c6171fc1b | 133 | |
shimniok | 0:826c6171fc1b | 134 | /** |
shimniok | 0:826c6171fc1b | 135 | * @brief Get field object_id from object_detection_event message |
shimniok | 0:826c6171fc1b | 136 | * |
shimniok | 0:826c6171fc1b | 137 | * @return Object ID |
shimniok | 0:826c6171fc1b | 138 | */ |
shimniok | 0:826c6171fc1b | 139 | static inline uint16_t mavlink_msg_object_detection_event_get_object_id(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 140 | { |
shimniok | 0:826c6171fc1b | 141 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 142 | r.b[1] = (msg->payload+sizeof(uint32_t))[0]; |
shimniok | 0:826c6171fc1b | 143 | r.b[0] = (msg->payload+sizeof(uint32_t))[1]; |
shimniok | 0:826c6171fc1b | 144 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 145 | } |
shimniok | 0:826c6171fc1b | 146 | |
shimniok | 0:826c6171fc1b | 147 | /** |
shimniok | 0:826c6171fc1b | 148 | * @brief Get field type from object_detection_event message |
shimniok | 0:826c6171fc1b | 149 | * |
shimniok | 0:826c6171fc1b | 150 | * @return Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal |
shimniok | 0:826c6171fc1b | 151 | */ |
shimniok | 0:826c6171fc1b | 152 | static inline uint8_t mavlink_msg_object_detection_event_get_type(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 153 | { |
shimniok | 0:826c6171fc1b | 154 | return (uint8_t)(msg->payload+sizeof(uint32_t)+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 155 | } |
shimniok | 0:826c6171fc1b | 156 | |
shimniok | 0:826c6171fc1b | 157 | /** |
shimniok | 0:826c6171fc1b | 158 | * @brief Get field name from object_detection_event message |
shimniok | 0:826c6171fc1b | 159 | * |
shimniok | 0:826c6171fc1b | 160 | * @return Name of the object as defined by the detector |
shimniok | 0:826c6171fc1b | 161 | */ |
shimniok | 0:826c6171fc1b | 162 | static inline uint16_t mavlink_msg_object_detection_event_get_name(const mavlink_message_t* msg, char* r_data) |
shimniok | 0:826c6171fc1b | 163 | { |
shimniok | 0:826c6171fc1b | 164 | |
shimniok | 0:826c6171fc1b | 165 | memcpy(r_data, msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t), sizeof(char)*20); |
shimniok | 0:826c6171fc1b | 166 | return sizeof(char)*20; |
shimniok | 0:826c6171fc1b | 167 | } |
shimniok | 0:826c6171fc1b | 168 | |
shimniok | 0:826c6171fc1b | 169 | /** |
shimniok | 0:826c6171fc1b | 170 | * @brief Get field quality from object_detection_event message |
shimniok | 0:826c6171fc1b | 171 | * |
shimniok | 0:826c6171fc1b | 172 | * @return Detection quality / confidence. 0: bad, 255: maximum confidence |
shimniok | 0:826c6171fc1b | 173 | */ |
shimniok | 0:826c6171fc1b | 174 | static inline uint8_t mavlink_msg_object_detection_event_get_quality(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 175 | { |
shimniok | 0:826c6171fc1b | 176 | return (uint8_t)(msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20)[0]; |
shimniok | 0:826c6171fc1b | 177 | } |
shimniok | 0:826c6171fc1b | 178 | |
shimniok | 0:826c6171fc1b | 179 | /** |
shimniok | 0:826c6171fc1b | 180 | * @brief Get field bearing from object_detection_event message |
shimniok | 0:826c6171fc1b | 181 | * |
shimniok | 0:826c6171fc1b | 182 | * @return Angle of the object with respect to the body frame in NED coordinates in radians. 0: front |
shimniok | 0:826c6171fc1b | 183 | */ |
shimniok | 0:826c6171fc1b | 184 | static inline float mavlink_msg_object_detection_event_get_bearing(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 185 | { |
shimniok | 0:826c6171fc1b | 186 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 187 | r.b[3] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 188 | r.b[2] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t))[1]; |
shimniok | 0:826c6171fc1b | 189 | r.b[1] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t))[2]; |
shimniok | 0:826c6171fc1b | 190 | r.b[0] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t))[3]; |
shimniok | 0:826c6171fc1b | 191 | return (float)r.f; |
shimniok | 0:826c6171fc1b | 192 | } |
shimniok | 0:826c6171fc1b | 193 | |
shimniok | 0:826c6171fc1b | 194 | /** |
shimniok | 0:826c6171fc1b | 195 | * @brief Get field distance from object_detection_event message |
shimniok | 0:826c6171fc1b | 196 | * |
shimniok | 0:826c6171fc1b | 197 | * @return Ground distance in meters |
shimniok | 0:826c6171fc1b | 198 | */ |
shimniok | 0:826c6171fc1b | 199 | static inline float mavlink_msg_object_detection_event_get_distance(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 200 | { |
shimniok | 0:826c6171fc1b | 201 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 202 | r.b[3] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t)+sizeof(float))[0]; |
shimniok | 0:826c6171fc1b | 203 | r.b[2] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t)+sizeof(float))[1]; |
shimniok | 0:826c6171fc1b | 204 | r.b[1] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t)+sizeof(float))[2]; |
shimniok | 0:826c6171fc1b | 205 | r.b[0] = (msg->payload+sizeof(uint32_t)+sizeof(uint16_t)+sizeof(uint8_t)+sizeof(char)*20+sizeof(uint8_t)+sizeof(float))[3]; |
shimniok | 0:826c6171fc1b | 206 | return (float)r.f; |
shimniok | 0:826c6171fc1b | 207 | } |
shimniok | 0:826c6171fc1b | 208 | |
shimniok | 0:826c6171fc1b | 209 | /** |
shimniok | 0:826c6171fc1b | 210 | * @brief Decode a object_detection_event message into a struct |
shimniok | 0:826c6171fc1b | 211 | * |
shimniok | 0:826c6171fc1b | 212 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 213 | * @param object_detection_event C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 214 | */ |
shimniok | 0:826c6171fc1b | 215 | static inline void mavlink_msg_object_detection_event_decode(const mavlink_message_t* msg, mavlink_object_detection_event_t* object_detection_event) |
shimniok | 0:826c6171fc1b | 216 | { |
shimniok | 0:826c6171fc1b | 217 | object_detection_event->time = mavlink_msg_object_detection_event_get_time(msg); |
shimniok | 0:826c6171fc1b | 218 | object_detection_event->object_id = mavlink_msg_object_detection_event_get_object_id(msg); |
shimniok | 0:826c6171fc1b | 219 | object_detection_event->type = mavlink_msg_object_detection_event_get_type(msg); |
shimniok | 0:826c6171fc1b | 220 | mavlink_msg_object_detection_event_get_name(msg, object_detection_event->name); |
shimniok | 0:826c6171fc1b | 221 | object_detection_event->quality = mavlink_msg_object_detection_event_get_quality(msg); |
shimniok | 0:826c6171fc1b | 222 | object_detection_event->bearing = mavlink_msg_object_detection_event_get_bearing(msg); |
shimniok | 0:826c6171fc1b | 223 | object_detection_event->distance = mavlink_msg_object_detection_event_get_distance(msg); |
shimniok | 0:826c6171fc1b | 224 | } |