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_vfr_hud.h
00001 // MESSAGE VFR_HUD PACKING 00002 00003 #define MAVLINK_MSG_ID_VFR_HUD 74 00004 00005 typedef struct __mavlink_vfr_hud_t 00006 { 00007 float airspeed; ///< Current airspeed in m/s 00008 float groundspeed; ///< Current ground speed in m/s 00009 int16_t heading; ///< Current heading in degrees, in compass units (0..360, 0=north) 00010 uint16_t throttle; ///< Current throttle setting in integer percent, 0 to 100 00011 float alt; ///< Current altitude (MSL), in meters 00012 float climb; ///< Current climb rate in meters/second 00013 00014 } mavlink_vfr_hud_t; 00015 00016 00017 00018 /** 00019 * @brief Pack a vfr_hud 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 airspeed Current airspeed in m/s 00025 * @param groundspeed Current ground speed in m/s 00026 * @param heading Current heading in degrees, in compass units (0..360, 0=north) 00027 * @param throttle Current throttle setting in integer percent, 0 to 100 00028 * @param alt Current altitude (MSL), in meters 00029 * @param climb Current climb rate in meters/second 00030 * @return length of the message in bytes (excluding serial stream start sign) 00031 */ 00032 static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb) 00033 { 00034 uint16_t i = 0; 00035 msg->msgid = MAVLINK_MSG_ID_VFR_HUD; 00036 00037 i += put_float_by_index(airspeed, i, msg->payload); // Current airspeed in m/s 00038 i += put_float_by_index(groundspeed, i, msg->payload); // Current ground speed in m/s 00039 i += put_int16_t_by_index(heading, i, msg->payload); // Current heading in degrees, in compass units (0..360, 0=north) 00040 i += put_uint16_t_by_index(throttle, i, msg->payload); // Current throttle setting in integer percent, 0 to 100 00041 i += put_float_by_index(alt, i, msg->payload); // Current altitude (MSL), in meters 00042 i += put_float_by_index(climb, i, msg->payload); // Current climb rate in meters/second 00043 00044 return mavlink_finalize_message(msg, system_id, component_id, i); 00045 } 00046 00047 /** 00048 * @brief Pack a vfr_hud message 00049 * @param system_id ID of this system 00050 * @param component_id ID of this component (e.g. 200 for IMU) 00051 * @param chan The MAVLink channel this message was sent over 00052 * @param msg The MAVLink message to compress the data into 00053 * @param airspeed Current airspeed in m/s 00054 * @param groundspeed Current ground speed in m/s 00055 * @param heading Current heading in degrees, in compass units (0..360, 0=north) 00056 * @param throttle Current throttle setting in integer percent, 0 to 100 00057 * @param alt Current altitude (MSL), in meters 00058 * @param climb Current climb rate in meters/second 00059 * @return length of the message in bytes (excluding serial stream start sign) 00060 */ 00061 static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb) 00062 { 00063 uint16_t i = 0; 00064 msg->msgid = MAVLINK_MSG_ID_VFR_HUD; 00065 00066 i += put_float_by_index(airspeed, i, msg->payload); // Current airspeed in m/s 00067 i += put_float_by_index(groundspeed, i, msg->payload); // Current ground speed in m/s 00068 i += put_int16_t_by_index(heading, i, msg->payload); // Current heading in degrees, in compass units (0..360, 0=north) 00069 i += put_uint16_t_by_index(throttle, i, msg->payload); // Current throttle setting in integer percent, 0 to 100 00070 i += put_float_by_index(alt, i, msg->payload); // Current altitude (MSL), in meters 00071 i += put_float_by_index(climb, i, msg->payload); // Current climb rate in meters/second 00072 00073 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00074 } 00075 00076 /** 00077 * @brief Encode a vfr_hud struct into a message 00078 * 00079 * @param system_id ID of this system 00080 * @param component_id ID of this component (e.g. 200 for IMU) 00081 * @param msg The MAVLink message to compress the data into 00082 * @param vfr_hud C-struct to read the message contents from 00083 */ 00084 static inline uint16_t mavlink_msg_vfr_hud_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud) 00085 { 00086 return mavlink_msg_vfr_hud_pack(system_id, component_id, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb); 00087 } 00088 00089 /** 00090 * @brief Send a vfr_hud message 00091 * @param chan MAVLink channel to send the message 00092 * 00093 * @param airspeed Current airspeed in m/s 00094 * @param groundspeed Current ground speed in m/s 00095 * @param heading Current heading in degrees, in compass units (0..360, 0=north) 00096 * @param throttle Current throttle setting in integer percent, 0 to 100 00097 * @param alt Current altitude (MSL), in meters 00098 * @param climb Current climb rate in meters/second 00099 */ 00100 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00101 00102 static inline void mavlink_msg_vfr_hud_send(mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb) 00103 { 00104 mavlink_message_t msg; 00105 mavlink_msg_vfr_hud_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, airspeed, groundspeed, heading, throttle, alt, climb); 00106 mavlink_send_uart(chan, &msg); 00107 } 00108 00109 #endif 00110 // MESSAGE VFR_HUD UNPACKING 00111 00112 /** 00113 * @brief Get field airspeed from vfr_hud message 00114 * 00115 * @return Current airspeed in m/s 00116 */ 00117 static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg) 00118 { 00119 generic_32bit r; 00120 r.b[3] = (msg->payload)[0]; 00121 r.b[2] = (msg->payload)[1]; 00122 r.b[1] = (msg->payload)[2]; 00123 r.b[0] = (msg->payload)[3]; 00124 return (float)r.f; 00125 } 00126 00127 /** 00128 * @brief Get field groundspeed from vfr_hud message 00129 * 00130 * @return Current ground speed in m/s 00131 */ 00132 static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg) 00133 { 00134 generic_32bit r; 00135 r.b[3] = (msg->payload+sizeof(float))[0]; 00136 r.b[2] = (msg->payload+sizeof(float))[1]; 00137 r.b[1] = (msg->payload+sizeof(float))[2]; 00138 r.b[0] = (msg->payload+sizeof(float))[3]; 00139 return (float)r.f; 00140 } 00141 00142 /** 00143 * @brief Get field heading from vfr_hud message 00144 * 00145 * @return Current heading in degrees, in compass units (0..360, 0=north) 00146 */ 00147 static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg) 00148 { 00149 generic_16bit r; 00150 r.b[1] = (msg->payload+sizeof(float)+sizeof(float))[0]; 00151 r.b[0] = (msg->payload+sizeof(float)+sizeof(float))[1]; 00152 return (int16_t)r.s; 00153 } 00154 00155 /** 00156 * @brief Get field throttle from vfr_hud message 00157 * 00158 * @return Current throttle setting in integer percent, 0 to 100 00159 */ 00160 static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg) 00161 { 00162 generic_16bit r; 00163 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t))[0]; 00164 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t))[1]; 00165 return (uint16_t)r.s; 00166 } 00167 00168 /** 00169 * @brief Get field alt from vfr_hud message 00170 * 00171 * @return Current altitude (MSL), in meters 00172 */ 00173 static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg) 00174 { 00175 generic_32bit r; 00176 r.b[3] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t))[0]; 00177 r.b[2] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t))[1]; 00178 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t))[2]; 00179 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t))[3]; 00180 return (float)r.f; 00181 } 00182 00183 /** 00184 * @brief Get field climb from vfr_hud message 00185 * 00186 * @return Current climb rate in meters/second 00187 */ 00188 static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg) 00189 { 00190 generic_32bit r; 00191 r.b[3] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t)+sizeof(float))[0]; 00192 r.b[2] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t)+sizeof(float))[1]; 00193 r.b[1] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t)+sizeof(float))[2]; 00194 r.b[0] = (msg->payload+sizeof(float)+sizeof(float)+sizeof(int16_t)+sizeof(uint16_t)+sizeof(float))[3]; 00195 return (float)r.f; 00196 } 00197 00198 /** 00199 * @brief Decode a vfr_hud message into a struct 00200 * 00201 * @param msg The message to decode 00202 * @param vfr_hud C-struct to decode the message contents into 00203 */ 00204 static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud) 00205 { 00206 vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg); 00207 vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg); 00208 vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg); 00209 vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg); 00210 vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg); 00211 vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg); 00212 }
Generated on Tue Jul 12 2022 14:09:27 by 1.7.2