Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
mavlink_msg_pattern_detected.h
00001 // MESSAGE PATTERN_DETECTED PACKING 00002 00003 #define MAVLINK_MSG_ID_PATTERN_DETECTED 160 00004 00005 typedef struct __mavlink_pattern_detected_t 00006 { 00007 uint8_t type; ///< 0: Pattern, 1: Letter 00008 float confidence; ///< Confidence of detection 00009 int8_t file[100]; ///< Pattern file name 00010 uint8_t detected; ///< Accepted as true detection, 0 no, 1 yes 00011 00012 } mavlink_pattern_detected_t; 00013 00014 #define MAVLINK_MSG_PATTERN_DETECTED_FIELD_FILE_LEN 100 00015 00016 00017 /** 00018 * @brief Pack a pattern_detected message 00019 * @param system_id ID of this system 00020 * @param component_id ID of this component (e.g. 200 for IMU) 00021 * @param msg The MAVLink message to compress the data into 00022 * 00023 * @param type 0: Pattern, 1: Letter 00024 * @param confidence Confidence of detection 00025 * @param file Pattern file name 00026 * @param detected Accepted as true detection, 0 no, 1 yes 00027 * @return length of the message in bytes (excluding serial stream start sign) 00028 */ 00029 static inline uint16_t mavlink_msg_pattern_detected_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t type, float confidence, const int8_t* file, uint8_t detected) 00030 { 00031 uint16_t i = 0; 00032 msg->msgid = MAVLINK_MSG_ID_PATTERN_DETECTED; 00033 00034 i += put_uint8_t_by_index(type, i, msg->payload); // 0: Pattern, 1: Letter 00035 i += put_float_by_index(confidence, i, msg->payload); // Confidence of detection 00036 i += put_array_by_index(file, 100, i, msg->payload); // Pattern file name 00037 i += put_uint8_t_by_index(detected, i, msg->payload); // Accepted as true detection, 0 no, 1 yes 00038 00039 return mavlink_finalize_message(msg, system_id, component_id, i); 00040 } 00041 00042 /** 00043 * @brief Pack a pattern_detected message 00044 * @param system_id ID of this system 00045 * @param component_id ID of this component (e.g. 200 for IMU) 00046 * @param chan The MAVLink channel this message was sent over 00047 * @param msg The MAVLink message to compress the data into 00048 * @param type 0: Pattern, 1: Letter 00049 * @param confidence Confidence of detection 00050 * @param file Pattern file name 00051 * @param detected Accepted as true detection, 0 no, 1 yes 00052 * @return length of the message in bytes (excluding serial stream start sign) 00053 */ 00054 static inline uint16_t mavlink_msg_pattern_detected_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t type, float confidence, const int8_t* file, uint8_t detected) 00055 { 00056 uint16_t i = 0; 00057 msg->msgid = MAVLINK_MSG_ID_PATTERN_DETECTED; 00058 00059 i += put_uint8_t_by_index(type, i, msg->payload); // 0: Pattern, 1: Letter 00060 i += put_float_by_index(confidence, i, msg->payload); // Confidence of detection 00061 i += put_array_by_index(file, 100, i, msg->payload); // Pattern file name 00062 i += put_uint8_t_by_index(detected, i, msg->payload); // Accepted as true detection, 0 no, 1 yes 00063 00064 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00065 } 00066 00067 /** 00068 * @brief Encode a pattern_detected struct into a message 00069 * 00070 * @param system_id ID of this system 00071 * @param component_id ID of this component (e.g. 200 for IMU) 00072 * @param msg The MAVLink message to compress the data into 00073 * @param pattern_detected C-struct to read the message contents from 00074 */ 00075 static inline uint16_t mavlink_msg_pattern_detected_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_pattern_detected_t* pattern_detected) 00076 { 00077 return mavlink_msg_pattern_detected_pack(system_id, component_id, msg, pattern_detected->type, pattern_detected->confidence, pattern_detected->file, pattern_detected->detected); 00078 } 00079 00080 /** 00081 * @brief Send a pattern_detected message 00082 * @param chan MAVLink channel to send the message 00083 * 00084 * @param type 0: Pattern, 1: Letter 00085 * @param confidence Confidence of detection 00086 * @param file Pattern file name 00087 * @param detected Accepted as true detection, 0 no, 1 yes 00088 */ 00089 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00090 00091 static inline void mavlink_msg_pattern_detected_send(mavlink_channel_t chan, uint8_t type, float confidence, const int8_t* file, uint8_t detected) 00092 { 00093 mavlink_message_t msg; 00094 mavlink_msg_pattern_detected_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, type, confidence, file, detected); 00095 mavlink_send_uart(chan, &msg); 00096 } 00097 00098 #endif 00099 // MESSAGE PATTERN_DETECTED UNPACKING 00100 00101 /** 00102 * @brief Get field type from pattern_detected message 00103 * 00104 * @return 0: Pattern, 1: Letter 00105 */ 00106 static inline uint8_t mavlink_msg_pattern_detected_get_type(const mavlink_message_t* msg) 00107 { 00108 return (uint8_t)(msg->payload)[0]; 00109 } 00110 00111 /** 00112 * @brief Get field confidence from pattern_detected message 00113 * 00114 * @return Confidence of detection 00115 */ 00116 static inline float mavlink_msg_pattern_detected_get_confidence(const mavlink_message_t* msg) 00117 { 00118 generic_32bit r; 00119 r.b[3] = (msg->payload+sizeof(uint8_t))[0]; 00120 r.b[2] = (msg->payload+sizeof(uint8_t))[1]; 00121 r.b[1] = (msg->payload+sizeof(uint8_t))[2]; 00122 r.b[0] = (msg->payload+sizeof(uint8_t))[3]; 00123 return (float)r.f; 00124 } 00125 00126 /** 00127 * @brief Get field file from pattern_detected message 00128 * 00129 * @return Pattern file name 00130 */ 00131 static inline uint16_t mavlink_msg_pattern_detected_get_file(const mavlink_message_t* msg, int8_t* r_data) 00132 { 00133 00134 memcpy(r_data, msg->payload+sizeof(uint8_t)+sizeof(float), 100); 00135 return 100; 00136 } 00137 00138 /** 00139 * @brief Get field detected from pattern_detected message 00140 * 00141 * @return Accepted as true detection, 0 no, 1 yes 00142 */ 00143 static inline uint8_t mavlink_msg_pattern_detected_get_detected(const mavlink_message_t* msg) 00144 { 00145 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(float)+100)[0]; 00146 } 00147 00148 /** 00149 * @brief Decode a pattern_detected message into a struct 00150 * 00151 * @param msg The message to decode 00152 * @param pattern_detected C-struct to decode the message contents into 00153 */ 00154 static inline void mavlink_msg_pattern_detected_decode(const mavlink_message_t* msg, mavlink_pattern_detected_t* pattern_detected) 00155 { 00156 pattern_detected->type = mavlink_msg_pattern_detected_get_type(msg); 00157 pattern_detected->confidence = mavlink_msg_pattern_detected_get_confidence(msg); 00158 mavlink_msg_pattern_detected_get_file(msg, pattern_detected->file); 00159 pattern_detected->detected = mavlink_msg_pattern_detected_get_detected(msg); 00160 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2