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_debug_vect.h
00001 // MESSAGE DEBUG_VECT PACKING 00002 00003 #define MAVLINK_MSG_ID_DEBUG_VECT 251 00004 00005 typedef struct __mavlink_debug_vect_t 00006 { 00007 char name[10]; ///< Name 00008 uint64_t usec; ///< Timestamp 00009 float x; ///< x 00010 float y; ///< y 00011 float z; ///< z 00012 00013 } mavlink_debug_vect_t; 00014 00015 #define MAVLINK_MSG_DEBUG_VECT_FIELD_NAME_LEN 10 00016 00017 00018 /** 00019 * @brief Pack a debug_vect message 00020 * @param system_id ID of this system 00021 * @param component_id ID of this component (e.g. 200 for IMU) 00022 * @param msg The MAVLink message to compress the data into 00023 * 00024 * @param name Name 00025 * @param usec Timestamp 00026 * @param x x 00027 * @param y y 00028 * @param z z 00029 * @return length of the message in bytes (excluding serial stream start sign) 00030 */ 00031 static inline uint16_t mavlink_msg_debug_vect_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* name, uint64_t usec, float x, float y, float z) 00032 { 00033 uint16_t i = 0; 00034 msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT; 00035 00036 i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name 00037 i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp 00038 i += put_float_by_index(x, i, msg->payload); // x 00039 i += put_float_by_index(y, i, msg->payload); // y 00040 i += put_float_by_index(z, i, msg->payload); // z 00041 00042 return mavlink_finalize_message(msg, system_id, component_id, i); 00043 } 00044 00045 /** 00046 * @brief Pack a debug_vect message 00047 * @param system_id ID of this system 00048 * @param component_id ID of this component (e.g. 200 for IMU) 00049 * @param chan The MAVLink channel this message was sent over 00050 * @param msg The MAVLink message to compress the data into 00051 * @param name Name 00052 * @param usec Timestamp 00053 * @param x x 00054 * @param y y 00055 * @param z z 00056 * @return length of the message in bytes (excluding serial stream start sign) 00057 */ 00058 static inline uint16_t mavlink_msg_debug_vect_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const char* name, uint64_t usec, float x, float y, float z) 00059 { 00060 uint16_t i = 0; 00061 msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT; 00062 00063 i += put_array_by_index((const int8_t*)name, sizeof(char)*10, i, msg->payload); // Name 00064 i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp 00065 i += put_float_by_index(x, i, msg->payload); // x 00066 i += put_float_by_index(y, i, msg->payload); // y 00067 i += put_float_by_index(z, i, msg->payload); // z 00068 00069 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00070 } 00071 00072 /** 00073 * @brief Encode a debug_vect struct into a message 00074 * 00075 * @param system_id ID of this system 00076 * @param component_id ID of this component (e.g. 200 for IMU) 00077 * @param msg The MAVLink message to compress the data into 00078 * @param debug_vect C-struct to read the message contents from 00079 */ 00080 static inline uint16_t mavlink_msg_debug_vect_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_debug_vect_t* debug_vect) 00081 { 00082 return mavlink_msg_debug_vect_pack(system_id, component_id, msg, debug_vect->name, debug_vect->usec, debug_vect->x, debug_vect->y, debug_vect->z); 00083 } 00084 00085 /** 00086 * @brief Send a debug_vect message 00087 * @param chan MAVLink channel to send the message 00088 * 00089 * @param name Name 00090 * @param usec Timestamp 00091 * @param x x 00092 * @param y y 00093 * @param z z 00094 */ 00095 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00096 00097 static inline void mavlink_msg_debug_vect_send(mavlink_channel_t chan, const char* name, uint64_t usec, float x, float y, float z) 00098 { 00099 mavlink_message_t msg; 00100 mavlink_msg_debug_vect_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, name, usec, x, y, z); 00101 mavlink_send_uart(chan, &msg); 00102 } 00103 00104 #endif 00105 // MESSAGE DEBUG_VECT UNPACKING 00106 00107 /** 00108 * @brief Get field name from debug_vect message 00109 * 00110 * @return Name 00111 */ 00112 static inline uint16_t mavlink_msg_debug_vect_get_name(const mavlink_message_t* msg, char* r_data) 00113 { 00114 00115 memcpy(r_data, msg->payload, sizeof(char)*10); 00116 return sizeof(char)*10; 00117 } 00118 00119 /** 00120 * @brief Get field usec from debug_vect message 00121 * 00122 * @return Timestamp 00123 */ 00124 static inline uint64_t mavlink_msg_debug_vect_get_usec(const mavlink_message_t* msg) 00125 { 00126 generic_64bit r; 00127 r.b[7] = (msg->payload+sizeof(char)*10)[0]; 00128 r.b[6] = (msg->payload+sizeof(char)*10)[1]; 00129 r.b[5] = (msg->payload+sizeof(char)*10)[2]; 00130 r.b[4] = (msg->payload+sizeof(char)*10)[3]; 00131 r.b[3] = (msg->payload+sizeof(char)*10)[4]; 00132 r.b[2] = (msg->payload+sizeof(char)*10)[5]; 00133 r.b[1] = (msg->payload+sizeof(char)*10)[6]; 00134 r.b[0] = (msg->payload+sizeof(char)*10)[7]; 00135 return (uint64_t)r.ll; 00136 } 00137 00138 /** 00139 * @brief Get field x from debug_vect message 00140 * 00141 * @return x 00142 */ 00143 static inline float mavlink_msg_debug_vect_get_x(const mavlink_message_t* msg) 00144 { 00145 generic_32bit r; 00146 r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[0]; 00147 r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[1]; 00148 r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[2]; 00149 r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t))[3]; 00150 return (float)r.f; 00151 } 00152 00153 /** 00154 * @brief Get field y from debug_vect message 00155 * 00156 * @return y 00157 */ 00158 static inline float mavlink_msg_debug_vect_get_y(const mavlink_message_t* msg) 00159 { 00160 generic_32bit r; 00161 r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[0]; 00162 r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[1]; 00163 r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[2]; 00164 r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float))[3]; 00165 return (float)r.f; 00166 } 00167 00168 /** 00169 * @brief Get field z from debug_vect message 00170 * 00171 * @return z 00172 */ 00173 static inline float mavlink_msg_debug_vect_get_z(const mavlink_message_t* msg) 00174 { 00175 generic_32bit r; 00176 r.b[3] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0]; 00177 r.b[2] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1]; 00178 r.b[1] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[2]; 00179 r.b[0] = (msg->payload+sizeof(char)*10+sizeof(uint64_t)+sizeof(float)+sizeof(float))[3]; 00180 return (float)r.f; 00181 } 00182 00183 /** 00184 * @brief Decode a debug_vect message into a struct 00185 * 00186 * @param msg The message to decode 00187 * @param debug_vect C-struct to decode the message contents into 00188 */ 00189 static inline void mavlink_msg_debug_vect_decode(const mavlink_message_t* msg, mavlink_debug_vect_t* debug_vect) 00190 { 00191 mavlink_msg_debug_vect_get_name(msg, debug_vect->name); 00192 debug_vect->usec = mavlink_msg_debug_vect_get_usec(msg); 00193 debug_vect->x = mavlink_msg_debug_vect_get_x(msg); 00194 debug_vect->y = mavlink_msg_debug_vect_get_y(msg); 00195 debug_vect->z = mavlink_msg_debug_vect_get_z(msg); 00196 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2