Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mavlink_msg_vicon_position_estimate.h Source File

mavlink_msg_vicon_position_estimate.h

00001 // MESSAGE VICON_POSITION_ESTIMATE PACKING
00002 
00003 #define MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE 112
00004 
00005 typedef struct __mavlink_vicon_position_estimate_t 
00006 {
00007     uint64_t usec; ///< Timestamp (milliseconds)
00008     float x; ///< Global X position
00009     float y; ///< Global Y position
00010     float z; ///< Global Z position
00011     float roll; ///< Roll angle in rad
00012     float pitch; ///< Pitch angle in rad
00013     float yaw; ///< Yaw angle in rad
00014 
00015 } mavlink_vicon_position_estimate_t;
00016 
00017 
00018 
00019 /**
00020  * @brief Pack a vicon_position_estimate message
00021  * @param system_id ID of this system
00022  * @param component_id ID of this component (e.g. 200 for IMU)
00023  * @param msg The MAVLink message to compress the data into
00024  *
00025  * @param usec Timestamp (milliseconds)
00026  * @param x Global X position
00027  * @param y Global Y position
00028  * @param z Global Z position
00029  * @param roll Roll angle in rad
00030  * @param pitch Pitch angle in rad
00031  * @param yaw Yaw angle in rad
00032  * @return length of the message in bytes (excluding serial stream start sign)
00033  */
00034 static inline uint16_t mavlink_msg_vicon_position_estimate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw)
00035 {
00036     uint16_t i = 0;
00037     msg->msgid = MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE;
00038 
00039     i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (milliseconds)
00040     i += put_float_by_index(x, i, msg->payload); // Global X position
00041     i += put_float_by_index(y, i, msg->payload); // Global Y position
00042     i += put_float_by_index(z, i, msg->payload); // Global Z position
00043     i += put_float_by_index(roll, i, msg->payload); // Roll angle in rad
00044     i += put_float_by_index(pitch, i, msg->payload); // Pitch angle in rad
00045     i += put_float_by_index(yaw, i, msg->payload); // Yaw angle in rad
00046 
00047     return mavlink_finalize_message(msg, system_id, component_id, i);
00048 }
00049 
00050 /**
00051  * @brief Pack a vicon_position_estimate message
00052  * @param system_id ID of this system
00053  * @param component_id ID of this component (e.g. 200 for IMU)
00054  * @param chan The MAVLink channel this message was sent over
00055  * @param msg The MAVLink message to compress the data into
00056  * @param usec Timestamp (milliseconds)
00057  * @param x Global X position
00058  * @param y Global Y position
00059  * @param z Global Z position
00060  * @param roll Roll angle in rad
00061  * @param pitch Pitch angle in rad
00062  * @param yaw Yaw angle in rad
00063  * @return length of the message in bytes (excluding serial stream start sign)
00064  */
00065 static inline uint16_t mavlink_msg_vicon_position_estimate_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw)
00066 {
00067     uint16_t i = 0;
00068     msg->msgid = MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE;
00069 
00070     i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (milliseconds)
00071     i += put_float_by_index(x, i, msg->payload); // Global X position
00072     i += put_float_by_index(y, i, msg->payload); // Global Y position
00073     i += put_float_by_index(z, i, msg->payload); // Global Z position
00074     i += put_float_by_index(roll, i, msg->payload); // Roll angle in rad
00075     i += put_float_by_index(pitch, i, msg->payload); // Pitch angle in rad
00076     i += put_float_by_index(yaw, i, msg->payload); // Yaw angle in rad
00077 
00078     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
00079 }
00080 
00081 /**
00082  * @brief Encode a vicon_position_estimate struct into a message
00083  *
00084  * @param system_id ID of this system
00085  * @param component_id ID of this component (e.g. 200 for IMU)
00086  * @param msg The MAVLink message to compress the data into
00087  * @param vicon_position_estimate C-struct to read the message contents from
00088  */
00089 static inline uint16_t mavlink_msg_vicon_position_estimate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vicon_position_estimate_t* vicon_position_estimate)
00090 {
00091     return mavlink_msg_vicon_position_estimate_pack(system_id, component_id, msg, vicon_position_estimate->usec, vicon_position_estimate->x, vicon_position_estimate->y, vicon_position_estimate->z, vicon_position_estimate->roll, vicon_position_estimate->pitch, vicon_position_estimate->yaw);
00092 }
00093 
00094 /**
00095  * @brief Send a vicon_position_estimate message
00096  * @param chan MAVLink channel to send the message
00097  *
00098  * @param usec Timestamp (milliseconds)
00099  * @param x Global X position
00100  * @param y Global Y position
00101  * @param z Global Z position
00102  * @param roll Roll angle in rad
00103  * @param pitch Pitch angle in rad
00104  * @param yaw Yaw angle in rad
00105  */
00106 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00107 
00108 static inline void mavlink_msg_vicon_position_estimate_send(mavlink_channel_t chan, uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw)
00109 {
00110     mavlink_message_t msg;
00111     mavlink_msg_vicon_position_estimate_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, x, y, z, roll, pitch, yaw);
00112     mavlink_send_uart(chan, &msg);
00113 }
00114 
00115 #endif
00116 // MESSAGE VICON_POSITION_ESTIMATE UNPACKING
00117 
00118 /**
00119  * @brief Get field usec from vicon_position_estimate message
00120  *
00121  * @return Timestamp (milliseconds)
00122  */
00123 static inline uint64_t mavlink_msg_vicon_position_estimate_get_usec(const mavlink_message_t* msg)
00124 {
00125     generic_64bit r;
00126     r.b[7] = (msg->payload)[0];
00127     r.b[6] = (msg->payload)[1];
00128     r.b[5] = (msg->payload)[2];
00129     r.b[4] = (msg->payload)[3];
00130     r.b[3] = (msg->payload)[4];
00131     r.b[2] = (msg->payload)[5];
00132     r.b[1] = (msg->payload)[6];
00133     r.b[0] = (msg->payload)[7];
00134     return (uint64_t)r.ll;
00135 }
00136 
00137 /**
00138  * @brief Get field x from vicon_position_estimate message
00139  *
00140  * @return Global X position
00141  */
00142 static inline float mavlink_msg_vicon_position_estimate_get_x(const mavlink_message_t* msg)
00143 {
00144     generic_32bit r;
00145     r.b[3] = (msg->payload+sizeof(uint64_t))[0];
00146     r.b[2] = (msg->payload+sizeof(uint64_t))[1];
00147     r.b[1] = (msg->payload+sizeof(uint64_t))[2];
00148     r.b[0] = (msg->payload+sizeof(uint64_t))[3];
00149     return (float)r.f;
00150 }
00151 
00152 /**
00153  * @brief Get field y from vicon_position_estimate message
00154  *
00155  * @return Global Y position
00156  */
00157 static inline float mavlink_msg_vicon_position_estimate_get_y(const mavlink_message_t* msg)
00158 {
00159     generic_32bit r;
00160     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float))[0];
00161     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float))[1];
00162     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float))[2];
00163     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float))[3];
00164     return (float)r.f;
00165 }
00166 
00167 /**
00168  * @brief Get field z from vicon_position_estimate message
00169  *
00170  * @return Global Z position
00171  */
00172 static inline float mavlink_msg_vicon_position_estimate_get_z(const mavlink_message_t* msg)
00173 {
00174     generic_32bit r;
00175     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0];
00176     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1];
00177     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[2];
00178     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[3];
00179     return (float)r.f;
00180 }
00181 
00182 /**
00183  * @brief Get field roll from vicon_position_estimate message
00184  *
00185  * @return Roll angle in rad
00186  */
00187 static inline float mavlink_msg_vicon_position_estimate_get_roll(const mavlink_message_t* msg)
00188 {
00189     generic_32bit r;
00190     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[0];
00191     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[1];
00192     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[2];
00193     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float))[3];
00194     return (float)r.f;
00195 }
00196 
00197 /**
00198  * @brief Get field pitch from vicon_position_estimate message
00199  *
00200  * @return Pitch angle in rad
00201  */
00202 static inline float mavlink_msg_vicon_position_estimate_get_pitch(const mavlink_message_t* msg)
00203 {
00204     generic_32bit r;
00205     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
00206     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
00207     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
00208     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
00209     return (float)r.f;
00210 }
00211 
00212 /**
00213  * @brief Get field yaw from vicon_position_estimate message
00214  *
00215  * @return Yaw angle in rad
00216  */
00217 static inline float mavlink_msg_vicon_position_estimate_get_yaw(const mavlink_message_t* msg)
00218 {
00219     generic_32bit r;
00220     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[0];
00221     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[1];
00222     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[2];
00223     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float))[3];
00224     return (float)r.f;
00225 }
00226 
00227 /**
00228  * @brief Decode a vicon_position_estimate message into a struct
00229  *
00230  * @param msg The message to decode
00231  * @param vicon_position_estimate C-struct to decode the message contents into
00232  */
00233 static inline void mavlink_msg_vicon_position_estimate_decode(const mavlink_message_t* msg, mavlink_vicon_position_estimate_t* vicon_position_estimate)
00234 {
00235     vicon_position_estimate->usec = mavlink_msg_vicon_position_estimate_get_usec(msg);
00236     vicon_position_estimate->x = mavlink_msg_vicon_position_estimate_get_x(msg);
00237     vicon_position_estimate->y = mavlink_msg_vicon_position_estimate_get_y(msg);
00238     vicon_position_estimate->z = mavlink_msg_vicon_position_estimate_get_z(msg);
00239     vicon_position_estimate->roll = mavlink_msg_vicon_position_estimate_get_roll(msg);
00240     vicon_position_estimate->pitch = mavlink_msg_vicon_position_estimate_get_pitch(msg);
00241     vicon_position_estimate->yaw = mavlink_msg_vicon_position_estimate_get_yaw(msg);
00242 }