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_set_mag_offsets.h
00001 // MESSAGE SET_MAG_OFFSETS PACKING 00002 00003 #define MAVLINK_MSG_ID_SET_MAG_OFFSETS 151 00004 00005 typedef struct __mavlink_set_mag_offsets_t 00006 { 00007 uint8_t target_system; ///< System ID 00008 uint8_t target_component; ///< Component ID 00009 int16_t mag_ofs_x; ///< magnetometer X offset 00010 int16_t mag_ofs_y; ///< magnetometer Y offset 00011 int16_t mag_ofs_z; ///< magnetometer Z offset 00012 00013 } mavlink_set_mag_offsets_t; 00014 00015 00016 00017 /** 00018 * @brief Pack a set_mag_offsets 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 target_system System ID 00024 * @param target_component Component ID 00025 * @param mag_ofs_x magnetometer X offset 00026 * @param mag_ofs_y magnetometer Y offset 00027 * @param mag_ofs_z magnetometer Z offset 00028 * @return length of the message in bytes (excluding serial stream start sign) 00029 */ 00030 static inline uint16_t mavlink_msg_set_mag_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z) 00031 { 00032 uint16_t i = 0; 00033 msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS; 00034 00035 i += put_uint8_t_by_index(target_system, i, msg->payload); // System ID 00036 i += put_uint8_t_by_index(target_component, i, msg->payload); // Component ID 00037 i += put_int16_t_by_index(mag_ofs_x, i, msg->payload); // magnetometer X offset 00038 i += put_int16_t_by_index(mag_ofs_y, i, msg->payload); // magnetometer Y offset 00039 i += put_int16_t_by_index(mag_ofs_z, i, msg->payload); // magnetometer Z offset 00040 00041 return mavlink_finalize_message(msg, system_id, component_id, i); 00042 } 00043 00044 /** 00045 * @brief Pack a set_mag_offsets message 00046 * @param system_id ID of this system 00047 * @param component_id ID of this component (e.g. 200 for IMU) 00048 * @param chan The MAVLink channel this message was sent over 00049 * @param msg The MAVLink message to compress the data into 00050 * @param target_system System ID 00051 * @param target_component Component ID 00052 * @param mag_ofs_x magnetometer X offset 00053 * @param mag_ofs_y magnetometer Y offset 00054 * @param mag_ofs_z magnetometer Z offset 00055 * @return length of the message in bytes (excluding serial stream start sign) 00056 */ 00057 static inline uint16_t mavlink_msg_set_mag_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z) 00058 { 00059 uint16_t i = 0; 00060 msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS; 00061 00062 i += put_uint8_t_by_index(target_system, i, msg->payload); // System ID 00063 i += put_uint8_t_by_index(target_component, i, msg->payload); // Component ID 00064 i += put_int16_t_by_index(mag_ofs_x, i, msg->payload); // magnetometer X offset 00065 i += put_int16_t_by_index(mag_ofs_y, i, msg->payload); // magnetometer Y offset 00066 i += put_int16_t_by_index(mag_ofs_z, i, msg->payload); // magnetometer Z offset 00067 00068 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00069 } 00070 00071 /** 00072 * @brief Encode a set_mag_offsets struct into a message 00073 * 00074 * @param system_id ID of this system 00075 * @param component_id ID of this component (e.g. 200 for IMU) 00076 * @param msg The MAVLink message to compress the data into 00077 * @param set_mag_offsets C-struct to read the message contents from 00078 */ 00079 static inline uint16_t mavlink_msg_set_mag_offsets_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_mag_offsets_t* set_mag_offsets) 00080 { 00081 return mavlink_msg_set_mag_offsets_pack(system_id, component_id, msg, set_mag_offsets->target_system, set_mag_offsets->target_component, set_mag_offsets->mag_ofs_x, set_mag_offsets->mag_ofs_y, set_mag_offsets->mag_ofs_z); 00082 } 00083 00084 /** 00085 * @brief Send a set_mag_offsets message 00086 * @param chan MAVLink channel to send the message 00087 * 00088 * @param target_system System ID 00089 * @param target_component Component ID 00090 * @param mag_ofs_x magnetometer X offset 00091 * @param mag_ofs_y magnetometer Y offset 00092 * @param mag_ofs_z magnetometer Z offset 00093 */ 00094 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00095 00096 static inline void mavlink_msg_set_mag_offsets_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z) 00097 { 00098 mavlink_message_t msg; 00099 mavlink_msg_set_mag_offsets_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target_system, target_component, mag_ofs_x, mag_ofs_y, mag_ofs_z); 00100 mavlink_send_uart(chan, &msg); 00101 } 00102 00103 #endif 00104 // MESSAGE SET_MAG_OFFSETS UNPACKING 00105 00106 /** 00107 * @brief Get field target_system from set_mag_offsets message 00108 * 00109 * @return System ID 00110 */ 00111 static inline uint8_t mavlink_msg_set_mag_offsets_get_target_system(const mavlink_message_t* msg) 00112 { 00113 return (uint8_t)(msg->payload)[0]; 00114 } 00115 00116 /** 00117 * @brief Get field target_component from set_mag_offsets message 00118 * 00119 * @return Component ID 00120 */ 00121 static inline uint8_t mavlink_msg_set_mag_offsets_get_target_component(const mavlink_message_t* msg) 00122 { 00123 return (uint8_t)(msg->payload+sizeof(uint8_t))[0]; 00124 } 00125 00126 /** 00127 * @brief Get field mag_ofs_x from set_mag_offsets message 00128 * 00129 * @return magnetometer X offset 00130 */ 00131 static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_x(const mavlink_message_t* msg) 00132 { 00133 generic_16bit r; 00134 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0]; 00135 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[1]; 00136 return (int16_t)r.s; 00137 } 00138 00139 /** 00140 * @brief Get field mag_ofs_y from set_mag_offsets message 00141 * 00142 * @return magnetometer Y offset 00143 */ 00144 static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_y(const mavlink_message_t* msg) 00145 { 00146 generic_16bit r; 00147 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(int16_t))[0]; 00148 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(int16_t))[1]; 00149 return (int16_t)r.s; 00150 } 00151 00152 /** 00153 * @brief Get field mag_ofs_z from set_mag_offsets message 00154 * 00155 * @return magnetometer Z offset 00156 */ 00157 static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_z(const mavlink_message_t* msg) 00158 { 00159 generic_16bit r; 00160 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(int16_t)+sizeof(int16_t))[0]; 00161 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(int16_t)+sizeof(int16_t))[1]; 00162 return (int16_t)r.s; 00163 } 00164 00165 /** 00166 * @brief Decode a set_mag_offsets message into a struct 00167 * 00168 * @param msg The message to decode 00169 * @param set_mag_offsets C-struct to decode the message contents into 00170 */ 00171 static inline void mavlink_msg_set_mag_offsets_decode(const mavlink_message_t* msg, mavlink_set_mag_offsets_t* set_mag_offsets) 00172 { 00173 set_mag_offsets->target_system = mavlink_msg_set_mag_offsets_get_target_system(msg); 00174 set_mag_offsets->target_component = mavlink_msg_set_mag_offsets_get_target_component(msg); 00175 set_mag_offsets->mag_ofs_x = mavlink_msg_set_mag_offsets_get_mag_ofs_x(msg); 00176 set_mag_offsets->mag_ofs_y = mavlink_msg_set_mag_offsets_get_mag_ofs_y(msg); 00177 set_mag_offsets->mag_ofs_z = mavlink_msg_set_mag_offsets_get_mag_ofs_z(msg); 00178 }
Generated on Tue Jul 12 2022 14:09:27 by 1.7.2