Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/common/mavlink_msg_global_position_int.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE GLOBAL_POSITION_INT PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_GLOBAL_POSITION_INT 73 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_global_position_int_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | int32_t lat; ///< Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 8 | int32_t lon; ///< Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 9 | int32_t alt; ///< Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 10 | int16_t vx; ///< Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 11 | int16_t vy; ///< Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 12 | int16_t vz; ///< Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 13 | |
shimniok | 0:826c6171fc1b | 14 | } mavlink_global_position_int_t; |
shimniok | 0:826c6171fc1b | 15 | |
shimniok | 0:826c6171fc1b | 16 | |
shimniok | 0:826c6171fc1b | 17 | |
shimniok | 0:826c6171fc1b | 18 | /** |
shimniok | 0:826c6171fc1b | 19 | * @brief Pack a global_position_int message |
shimniok | 0:826c6171fc1b | 20 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 21 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 22 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 23 | * |
shimniok | 0:826c6171fc1b | 24 | * @param lat Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 25 | * @param lon Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 26 | * @param alt Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 27 | * @param vx Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 28 | * @param vy Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 29 | * @param vz Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 30 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 31 | */ |
shimniok | 0:826c6171fc1b | 32 | static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz) |
shimniok | 0:826c6171fc1b | 33 | { |
shimniok | 0:826c6171fc1b | 34 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 35 | msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT; |
shimniok | 0:826c6171fc1b | 36 | |
shimniok | 0:826c6171fc1b | 37 | i += put_int32_t_by_index(lat, i, msg->payload); // Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 38 | i += put_int32_t_by_index(lon, i, msg->payload); // Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 39 | i += put_int32_t_by_index(alt, i, msg->payload); // Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 40 | i += put_int16_t_by_index(vx, i, msg->payload); // Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 41 | i += put_int16_t_by_index(vy, i, msg->payload); // Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 42 | i += put_int16_t_by_index(vz, i, msg->payload); // Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 43 | |
shimniok | 0:826c6171fc1b | 44 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 45 | } |
shimniok | 0:826c6171fc1b | 46 | |
shimniok | 0:826c6171fc1b | 47 | /** |
shimniok | 0:826c6171fc1b | 48 | * @brief Pack a global_position_int message |
shimniok | 0:826c6171fc1b | 49 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 50 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 51 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 52 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 53 | * @param lat Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 54 | * @param lon Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 55 | * @param alt Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 56 | * @param vx Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 57 | * @param vy Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 58 | * @param vz Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 59 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 60 | */ |
shimniok | 0:826c6171fc1b | 61 | static inline uint16_t mavlink_msg_global_position_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz) |
shimniok | 0:826c6171fc1b | 62 | { |
shimniok | 0:826c6171fc1b | 63 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 64 | msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT; |
shimniok | 0:826c6171fc1b | 65 | |
shimniok | 0:826c6171fc1b | 66 | i += put_int32_t_by_index(lat, i, msg->payload); // Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 67 | i += put_int32_t_by_index(lon, i, msg->payload); // Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 68 | i += put_int32_t_by_index(alt, i, msg->payload); // Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 69 | i += put_int16_t_by_index(vx, i, msg->payload); // Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 70 | i += put_int16_t_by_index(vy, i, msg->payload); // Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 71 | i += put_int16_t_by_index(vz, i, msg->payload); // Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 72 | |
shimniok | 0:826c6171fc1b | 73 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 74 | } |
shimniok | 0:826c6171fc1b | 75 | |
shimniok | 0:826c6171fc1b | 76 | /** |
shimniok | 0:826c6171fc1b | 77 | * @brief Encode a global_position_int struct into a message |
shimniok | 0:826c6171fc1b | 78 | * |
shimniok | 0:826c6171fc1b | 79 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 80 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 81 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 82 | * @param global_position_int C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 83 | */ |
shimniok | 0:826c6171fc1b | 84 | static inline uint16_t mavlink_msg_global_position_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_global_position_int_t* global_position_int) |
shimniok | 0:826c6171fc1b | 85 | { |
shimniok | 0:826c6171fc1b | 86 | return mavlink_msg_global_position_int_pack(system_id, component_id, msg, global_position_int->lat, global_position_int->lon, global_position_int->alt, global_position_int->vx, global_position_int->vy, global_position_int->vz); |
shimniok | 0:826c6171fc1b | 87 | } |
shimniok | 0:826c6171fc1b | 88 | |
shimniok | 0:826c6171fc1b | 89 | /** |
shimniok | 0:826c6171fc1b | 90 | * @brief Send a global_position_int message |
shimniok | 0:826c6171fc1b | 91 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 92 | * |
shimniok | 0:826c6171fc1b | 93 | * @param lat Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 94 | * @param lon Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 95 | * @param alt Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 96 | * @param vx Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 97 | * @param vy Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 98 | * @param vz Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 99 | */ |
shimniok | 0:826c6171fc1b | 100 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 101 | |
shimniok | 0:826c6171fc1b | 102 | static inline void mavlink_msg_global_position_int_send(mavlink_channel_t chan, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz) |
shimniok | 0:826c6171fc1b | 103 | { |
shimniok | 0:826c6171fc1b | 104 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 105 | mavlink_msg_global_position_int_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, lat, lon, alt, vx, vy, vz); |
shimniok | 0:826c6171fc1b | 106 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 107 | } |
shimniok | 0:826c6171fc1b | 108 | |
shimniok | 0:826c6171fc1b | 109 | #endif |
shimniok | 0:826c6171fc1b | 110 | // MESSAGE GLOBAL_POSITION_INT UNPACKING |
shimniok | 0:826c6171fc1b | 111 | |
shimniok | 0:826c6171fc1b | 112 | /** |
shimniok | 0:826c6171fc1b | 113 | * @brief Get field lat from global_position_int message |
shimniok | 0:826c6171fc1b | 114 | * |
shimniok | 0:826c6171fc1b | 115 | * @return Latitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 116 | */ |
shimniok | 0:826c6171fc1b | 117 | static inline int32_t mavlink_msg_global_position_int_get_lat(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 118 | { |
shimniok | 0:826c6171fc1b | 119 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 120 | r.b[3] = (msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 121 | r.b[2] = (msg->payload)[1]; |
shimniok | 0:826c6171fc1b | 122 | r.b[1] = (msg->payload)[2]; |
shimniok | 0:826c6171fc1b | 123 | r.b[0] = (msg->payload)[3]; |
shimniok | 0:826c6171fc1b | 124 | return (int32_t)r.i; |
shimniok | 0:826c6171fc1b | 125 | } |
shimniok | 0:826c6171fc1b | 126 | |
shimniok | 0:826c6171fc1b | 127 | /** |
shimniok | 0:826c6171fc1b | 128 | * @brief Get field lon from global_position_int message |
shimniok | 0:826c6171fc1b | 129 | * |
shimniok | 0:826c6171fc1b | 130 | * @return Longitude, expressed as * 1E7 |
shimniok | 0:826c6171fc1b | 131 | */ |
shimniok | 0:826c6171fc1b | 132 | static inline int32_t mavlink_msg_global_position_int_get_lon(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 133 | { |
shimniok | 0:826c6171fc1b | 134 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 135 | r.b[3] = (msg->payload+sizeof(int32_t))[0]; |
shimniok | 0:826c6171fc1b | 136 | r.b[2] = (msg->payload+sizeof(int32_t))[1]; |
shimniok | 0:826c6171fc1b | 137 | r.b[1] = (msg->payload+sizeof(int32_t))[2]; |
shimniok | 0:826c6171fc1b | 138 | r.b[0] = (msg->payload+sizeof(int32_t))[3]; |
shimniok | 0:826c6171fc1b | 139 | return (int32_t)r.i; |
shimniok | 0:826c6171fc1b | 140 | } |
shimniok | 0:826c6171fc1b | 141 | |
shimniok | 0:826c6171fc1b | 142 | /** |
shimniok | 0:826c6171fc1b | 143 | * @brief Get field alt from global_position_int message |
shimniok | 0:826c6171fc1b | 144 | * |
shimniok | 0:826c6171fc1b | 145 | * @return Altitude in meters, expressed as * 1000 (millimeters) |
shimniok | 0:826c6171fc1b | 146 | */ |
shimniok | 0:826c6171fc1b | 147 | static inline int32_t mavlink_msg_global_position_int_get_alt(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 148 | { |
shimniok | 0:826c6171fc1b | 149 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 150 | r.b[3] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[0]; |
shimniok | 0:826c6171fc1b | 151 | r.b[2] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[1]; |
shimniok | 0:826c6171fc1b | 152 | r.b[1] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[2]; |
shimniok | 0:826c6171fc1b | 153 | r.b[0] = (msg->payload+sizeof(int32_t)+sizeof(int32_t))[3]; |
shimniok | 0:826c6171fc1b | 154 | return (int32_t)r.i; |
shimniok | 0:826c6171fc1b | 155 | } |
shimniok | 0:826c6171fc1b | 156 | |
shimniok | 0:826c6171fc1b | 157 | /** |
shimniok | 0:826c6171fc1b | 158 | * @brief Get field vx from global_position_int message |
shimniok | 0:826c6171fc1b | 159 | * |
shimniok | 0:826c6171fc1b | 160 | * @return Ground X Speed (Latitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 161 | */ |
shimniok | 0:826c6171fc1b | 162 | static inline int16_t mavlink_msg_global_position_int_get_vx(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 163 | { |
shimniok | 0:826c6171fc1b | 164 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 165 | r.b[1] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t))[0]; |
shimniok | 0:826c6171fc1b | 166 | r.b[0] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t))[1]; |
shimniok | 0:826c6171fc1b | 167 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 168 | } |
shimniok | 0:826c6171fc1b | 169 | |
shimniok | 0:826c6171fc1b | 170 | /** |
shimniok | 0:826c6171fc1b | 171 | * @brief Get field vy from global_position_int message |
shimniok | 0:826c6171fc1b | 172 | * |
shimniok | 0:826c6171fc1b | 173 | * @return Ground Y Speed (Longitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 174 | */ |
shimniok | 0:826c6171fc1b | 175 | static inline int16_t mavlink_msg_global_position_int_get_vy(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 176 | { |
shimniok | 0:826c6171fc1b | 177 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 178 | r.b[1] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 179 | r.b[0] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 180 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 181 | } |
shimniok | 0:826c6171fc1b | 182 | |
shimniok | 0:826c6171fc1b | 183 | /** |
shimniok | 0:826c6171fc1b | 184 | * @brief Get field vz from global_position_int message |
shimniok | 0:826c6171fc1b | 185 | * |
shimniok | 0:826c6171fc1b | 186 | * @return Ground Z Speed (Altitude), expressed as m/s * 100 |
shimniok | 0:826c6171fc1b | 187 | */ |
shimniok | 0:826c6171fc1b | 188 | static inline int16_t mavlink_msg_global_position_int_get_vz(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 189 | { |
shimniok | 0:826c6171fc1b | 190 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 191 | r.b[1] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t)+sizeof(int16_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 192 | r.b[0] = (msg->payload+sizeof(int32_t)+sizeof(int32_t)+sizeof(int32_t)+sizeof(int16_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 193 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 194 | } |
shimniok | 0:826c6171fc1b | 195 | |
shimniok | 0:826c6171fc1b | 196 | /** |
shimniok | 0:826c6171fc1b | 197 | * @brief Decode a global_position_int message into a struct |
shimniok | 0:826c6171fc1b | 198 | * |
shimniok | 0:826c6171fc1b | 199 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 200 | * @param global_position_int C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 201 | */ |
shimniok | 0:826c6171fc1b | 202 | static inline void mavlink_msg_global_position_int_decode(const mavlink_message_t* msg, mavlink_global_position_int_t* global_position_int) |
shimniok | 0:826c6171fc1b | 203 | { |
shimniok | 0:826c6171fc1b | 204 | global_position_int->lat = mavlink_msg_global_position_int_get_lat(msg); |
shimniok | 0:826c6171fc1b | 205 | global_position_int->lon = mavlink_msg_global_position_int_get_lon(msg); |
shimniok | 0:826c6171fc1b | 206 | global_position_int->alt = mavlink_msg_global_position_int_get_alt(msg); |
shimniok | 0:826c6171fc1b | 207 | global_position_int->vx = mavlink_msg_global_position_int_get_vx(msg); |
shimniok | 0:826c6171fc1b | 208 | global_position_int->vy = mavlink_msg_global_position_int_get_vy(msg); |
shimniok | 0:826c6171fc1b | 209 | global_position_int->vz = mavlink_msg_global_position_int_get_vz(msg); |
shimniok | 0:826c6171fc1b | 210 | } |