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_mid_lvl_cmds.h
00001 // MESSAGE MID_LVL_CMDS PACKING 00002 00003 #define MAVLINK_MSG_ID_MID_LVL_CMDS 180 00004 00005 typedef struct __mavlink_mid_lvl_cmds_t 00006 { 00007 uint8_t target; ///< The system setting the commands 00008 float hCommand; ///< Commanded Airspeed 00009 float uCommand; ///< Log value 2 00010 float rCommand; ///< Log value 3 00011 00012 } mavlink_mid_lvl_cmds_t; 00013 00014 00015 00016 /** 00017 * @brief Pack a mid_lvl_cmds message 00018 * @param system_id ID of this system 00019 * @param component_id ID of this component (e.g. 200 for IMU) 00020 * @param msg The MAVLink message to compress the data into 00021 * 00022 * @param target The system setting the commands 00023 * @param hCommand Commanded Airspeed 00024 * @param uCommand Log value 2 00025 * @param rCommand Log value 3 00026 * @return length of the message in bytes (excluding serial stream start sign) 00027 */ 00028 static inline uint16_t mavlink_msg_mid_lvl_cmds_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target, float hCommand, float uCommand, float rCommand) 00029 { 00030 uint16_t i = 0; 00031 msg->msgid = MAVLINK_MSG_ID_MID_LVL_CMDS; 00032 00033 i += put_uint8_t_by_index(target, i, msg->payload); // The system setting the commands 00034 i += put_float_by_index(hCommand, i, msg->payload); // Commanded Airspeed 00035 i += put_float_by_index(uCommand, i, msg->payload); // Log value 2 00036 i += put_float_by_index(rCommand, i, msg->payload); // Log value 3 00037 00038 return mavlink_finalize_message(msg, system_id, component_id, i); 00039 } 00040 00041 /** 00042 * @brief Pack a mid_lvl_cmds message 00043 * @param system_id ID of this system 00044 * @param component_id ID of this component (e.g. 200 for IMU) 00045 * @param chan The MAVLink channel this message was sent over 00046 * @param msg The MAVLink message to compress the data into 00047 * @param target The system setting the commands 00048 * @param hCommand Commanded Airspeed 00049 * @param uCommand Log value 2 00050 * @param rCommand Log value 3 00051 * @return length of the message in bytes (excluding serial stream start sign) 00052 */ 00053 static inline uint16_t mavlink_msg_mid_lvl_cmds_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target, float hCommand, float uCommand, float rCommand) 00054 { 00055 uint16_t i = 0; 00056 msg->msgid = MAVLINK_MSG_ID_MID_LVL_CMDS; 00057 00058 i += put_uint8_t_by_index(target, i, msg->payload); // The system setting the commands 00059 i += put_float_by_index(hCommand, i, msg->payload); // Commanded Airspeed 00060 i += put_float_by_index(uCommand, i, msg->payload); // Log value 2 00061 i += put_float_by_index(rCommand, i, msg->payload); // Log value 3 00062 00063 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00064 } 00065 00066 /** 00067 * @brief Encode a mid_lvl_cmds struct into a message 00068 * 00069 * @param system_id ID of this system 00070 * @param component_id ID of this component (e.g. 200 for IMU) 00071 * @param msg The MAVLink message to compress the data into 00072 * @param mid_lvl_cmds C-struct to read the message contents from 00073 */ 00074 static inline uint16_t mavlink_msg_mid_lvl_cmds_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mid_lvl_cmds_t* mid_lvl_cmds) 00075 { 00076 return mavlink_msg_mid_lvl_cmds_pack(system_id, component_id, msg, mid_lvl_cmds->target, mid_lvl_cmds->hCommand, mid_lvl_cmds->uCommand, mid_lvl_cmds->rCommand); 00077 } 00078 00079 /** 00080 * @brief Send a mid_lvl_cmds message 00081 * @param chan MAVLink channel to send the message 00082 * 00083 * @param target The system setting the commands 00084 * @param hCommand Commanded Airspeed 00085 * @param uCommand Log value 2 00086 * @param rCommand Log value 3 00087 */ 00088 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00089 00090 static inline void mavlink_msg_mid_lvl_cmds_send(mavlink_channel_t chan, uint8_t target, float hCommand, float uCommand, float rCommand) 00091 { 00092 mavlink_message_t msg; 00093 mavlink_msg_mid_lvl_cmds_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target, hCommand, uCommand, rCommand); 00094 mavlink_send_uart(chan, &msg); 00095 } 00096 00097 #endif 00098 // MESSAGE MID_LVL_CMDS UNPACKING 00099 00100 /** 00101 * @brief Get field target from mid_lvl_cmds message 00102 * 00103 * @return The system setting the commands 00104 */ 00105 static inline uint8_t mavlink_msg_mid_lvl_cmds_get_target(const mavlink_message_t* msg) 00106 { 00107 return (uint8_t)(msg->payload)[0]; 00108 } 00109 00110 /** 00111 * @brief Get field hCommand from mid_lvl_cmds message 00112 * 00113 * @return Commanded Airspeed 00114 */ 00115 static inline float mavlink_msg_mid_lvl_cmds_get_hCommand(const mavlink_message_t* msg) 00116 { 00117 generic_32bit r; 00118 r.b[3] = (msg->payload+sizeof(uint8_t))[0]; 00119 r.b[2] = (msg->payload+sizeof(uint8_t))[1]; 00120 r.b[1] = (msg->payload+sizeof(uint8_t))[2]; 00121 r.b[0] = (msg->payload+sizeof(uint8_t))[3]; 00122 return (float)r.f; 00123 } 00124 00125 /** 00126 * @brief Get field uCommand from mid_lvl_cmds message 00127 * 00128 * @return Log value 2 00129 */ 00130 static inline float mavlink_msg_mid_lvl_cmds_get_uCommand(const mavlink_message_t* msg) 00131 { 00132 generic_32bit r; 00133 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float))[0]; 00134 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float))[1]; 00135 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float))[2]; 00136 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float))[3]; 00137 return (float)r.f; 00138 } 00139 00140 /** 00141 * @brief Get field rCommand from mid_lvl_cmds message 00142 * 00143 * @return Log value 3 00144 */ 00145 static inline float mavlink_msg_mid_lvl_cmds_get_rCommand(const mavlink_message_t* msg) 00146 { 00147 generic_32bit r; 00148 r.b[3] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[0]; 00149 r.b[2] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[1]; 00150 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[2]; 00151 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(float)+sizeof(float))[3]; 00152 return (float)r.f; 00153 } 00154 00155 /** 00156 * @brief Decode a mid_lvl_cmds message into a struct 00157 * 00158 * @param msg The message to decode 00159 * @param mid_lvl_cmds C-struct to decode the message contents into 00160 */ 00161 static inline void mavlink_msg_mid_lvl_cmds_decode(const mavlink_message_t* msg, mavlink_mid_lvl_cmds_t* mid_lvl_cmds) 00162 { 00163 mid_lvl_cmds->target = mavlink_msg_mid_lvl_cmds_get_target(msg); 00164 mid_lvl_cmds->hCommand = mavlink_msg_mid_lvl_cmds_get_hCommand(msg); 00165 mid_lvl_cmds->uCommand = mavlink_msg_mid_lvl_cmds_get_uCommand(msg); 00166 mid_lvl_cmds->rCommand = mavlink_msg_mid_lvl_cmds_get_rCommand(msg); 00167 }
Generated on Tue Jul 12 2022 14:09:26 by 1.7.2