Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
MAVlink/include/pixhawk/mavlink_msg_vision_speed_estimate.h@0:a6a169de725f, 2013-05-27 (annotated)
- Committer:
- shimniok
- Date:
- Mon May 27 13:26:03 2013 +0000
- Revision:
- 0:a6a169de725f
Working version with priorities set and update time display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE VISION_SPEED_ESTIMATE PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE 113 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_vision_speed_estimate_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint64_t usec; ///< Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 8 | float x; ///< Global X speed |
shimniok | 0:a6a169de725f | 9 | float y; ///< Global Y speed |
shimniok | 0:a6a169de725f | 10 | float z; ///< Global Z speed |
shimniok | 0:a6a169de725f | 11 | |
shimniok | 0:a6a169de725f | 12 | } mavlink_vision_speed_estimate_t; |
shimniok | 0:a6a169de725f | 13 | |
shimniok | 0:a6a169de725f | 14 | |
shimniok | 0:a6a169de725f | 15 | |
shimniok | 0:a6a169de725f | 16 | /** |
shimniok | 0:a6a169de725f | 17 | * @brief Pack a vision_speed_estimate message |
shimniok | 0:a6a169de725f | 18 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 19 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 20 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 21 | * |
shimniok | 0:a6a169de725f | 22 | * @param usec Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 23 | * @param x Global X speed |
shimniok | 0:a6a169de725f | 24 | * @param y Global Y speed |
shimniok | 0:a6a169de725f | 25 | * @param z Global Z speed |
shimniok | 0:a6a169de725f | 26 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 27 | */ |
shimniok | 0:a6a169de725f | 28 | static inline uint16_t mavlink_msg_vision_speed_estimate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, float x, float y, float z) |
shimniok | 0:a6a169de725f | 29 | { |
shimniok | 0:a6a169de725f | 30 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 31 | msg->msgid = MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE; |
shimniok | 0:a6a169de725f | 32 | |
shimniok | 0:a6a169de725f | 33 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 34 | i += put_float_by_index(x, i, msg->payload); // Global X speed |
shimniok | 0:a6a169de725f | 35 | i += put_float_by_index(y, i, msg->payload); // Global Y speed |
shimniok | 0:a6a169de725f | 36 | i += put_float_by_index(z, i, msg->payload); // Global Z speed |
shimniok | 0:a6a169de725f | 37 | |
shimniok | 0:a6a169de725f | 38 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 39 | } |
shimniok | 0:a6a169de725f | 40 | |
shimniok | 0:a6a169de725f | 41 | /** |
shimniok | 0:a6a169de725f | 42 | * @brief Pack a vision_speed_estimate message |
shimniok | 0:a6a169de725f | 43 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 44 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 45 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 46 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 47 | * @param usec Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 48 | * @param x Global X speed |
shimniok | 0:a6a169de725f | 49 | * @param y Global Y speed |
shimniok | 0:a6a169de725f | 50 | * @param z Global Z speed |
shimniok | 0:a6a169de725f | 51 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 52 | */ |
shimniok | 0:a6a169de725f | 53 | static inline uint16_t mavlink_msg_vision_speed_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) |
shimniok | 0:a6a169de725f | 54 | { |
shimniok | 0:a6a169de725f | 55 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 56 | msg->msgid = MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE; |
shimniok | 0:a6a169de725f | 57 | |
shimniok | 0:a6a169de725f | 58 | i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 59 | i += put_float_by_index(x, i, msg->payload); // Global X speed |
shimniok | 0:a6a169de725f | 60 | i += put_float_by_index(y, i, msg->payload); // Global Y speed |
shimniok | 0:a6a169de725f | 61 | i += put_float_by_index(z, i, msg->payload); // Global Z speed |
shimniok | 0:a6a169de725f | 62 | |
shimniok | 0:a6a169de725f | 63 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 64 | } |
shimniok | 0:a6a169de725f | 65 | |
shimniok | 0:a6a169de725f | 66 | /** |
shimniok | 0:a6a169de725f | 67 | * @brief Encode a vision_speed_estimate struct into a message |
shimniok | 0:a6a169de725f | 68 | * |
shimniok | 0:a6a169de725f | 69 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 70 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 71 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 72 | * @param vision_speed_estimate C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 73 | */ |
shimniok | 0:a6a169de725f | 74 | static inline uint16_t mavlink_msg_vision_speed_estimate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vision_speed_estimate_t* vision_speed_estimate) |
shimniok | 0:a6a169de725f | 75 | { |
shimniok | 0:a6a169de725f | 76 | return mavlink_msg_vision_speed_estimate_pack(system_id, component_id, msg, vision_speed_estimate->usec, vision_speed_estimate->x, vision_speed_estimate->y, vision_speed_estimate->z); |
shimniok | 0:a6a169de725f | 77 | } |
shimniok | 0:a6a169de725f | 78 | |
shimniok | 0:a6a169de725f | 79 | /** |
shimniok | 0:a6a169de725f | 80 | * @brief Send a vision_speed_estimate message |
shimniok | 0:a6a169de725f | 81 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 82 | * |
shimniok | 0:a6a169de725f | 83 | * @param usec Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 84 | * @param x Global X speed |
shimniok | 0:a6a169de725f | 85 | * @param y Global Y speed |
shimniok | 0:a6a169de725f | 86 | * @param z Global Z speed |
shimniok | 0:a6a169de725f | 87 | */ |
shimniok | 0:a6a169de725f | 88 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 89 | |
shimniok | 0:a6a169de725f | 90 | static inline void mavlink_msg_vision_speed_estimate_send(mavlink_channel_t chan, uint64_t usec, float x, float y, float z) |
shimniok | 0:a6a169de725f | 91 | { |
shimniok | 0:a6a169de725f | 92 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 93 | mavlink_msg_vision_speed_estimate_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, x, y, z); |
shimniok | 0:a6a169de725f | 94 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 95 | } |
shimniok | 0:a6a169de725f | 96 | |
shimniok | 0:a6a169de725f | 97 | #endif |
shimniok | 0:a6a169de725f | 98 | // MESSAGE VISION_SPEED_ESTIMATE UNPACKING |
shimniok | 0:a6a169de725f | 99 | |
shimniok | 0:a6a169de725f | 100 | /** |
shimniok | 0:a6a169de725f | 101 | * @brief Get field usec from vision_speed_estimate message |
shimniok | 0:a6a169de725f | 102 | * |
shimniok | 0:a6a169de725f | 103 | * @return Timestamp (milliseconds) |
shimniok | 0:a6a169de725f | 104 | */ |
shimniok | 0:a6a169de725f | 105 | static inline uint64_t mavlink_msg_vision_speed_estimate_get_usec(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 106 | { |
shimniok | 0:a6a169de725f | 107 | generic_64bit r; |
shimniok | 0:a6a169de725f | 108 | r.b[7] = (msg->payload)[0]; |
shimniok | 0:a6a169de725f | 109 | r.b[6] = (msg->payload)[1]; |
shimniok | 0:a6a169de725f | 110 | r.b[5] = (msg->payload)[2]; |
shimniok | 0:a6a169de725f | 111 | r.b[4] = (msg->payload)[3]; |
shimniok | 0:a6a169de725f | 112 | r.b[3] = (msg->payload)[4]; |
shimniok | 0:a6a169de725f | 113 | r.b[2] = (msg->payload)[5]; |
shimniok | 0:a6a169de725f | 114 | r.b[1] = (msg->payload)[6]; |
shimniok | 0:a6a169de725f | 115 | r.b[0] = (msg->payload)[7]; |
shimniok | 0:a6a169de725f | 116 | return (uint64_t)r.ll; |
shimniok | 0:a6a169de725f | 117 | } |
shimniok | 0:a6a169de725f | 118 | |
shimniok | 0:a6a169de725f | 119 | /** |
shimniok | 0:a6a169de725f | 120 | * @brief Get field x from vision_speed_estimate message |
shimniok | 0:a6a169de725f | 121 | * |
shimniok | 0:a6a169de725f | 122 | * @return Global X speed |
shimniok | 0:a6a169de725f | 123 | */ |
shimniok | 0:a6a169de725f | 124 | static inline float mavlink_msg_vision_speed_estimate_get_x(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 125 | { |
shimniok | 0:a6a169de725f | 126 | generic_32bit r; |
shimniok | 0:a6a169de725f | 127 | r.b[3] = (msg->payload+sizeof(uint64_t))[0]; |
shimniok | 0:a6a169de725f | 128 | r.b[2] = (msg->payload+sizeof(uint64_t))[1]; |
shimniok | 0:a6a169de725f | 129 | r.b[1] = (msg->payload+sizeof(uint64_t))[2]; |
shimniok | 0:a6a169de725f | 130 | r.b[0] = (msg->payload+sizeof(uint64_t))[3]; |
shimniok | 0:a6a169de725f | 131 | return (float)r.f; |
shimniok | 0:a6a169de725f | 132 | } |
shimniok | 0:a6a169de725f | 133 | |
shimniok | 0:a6a169de725f | 134 | /** |
shimniok | 0:a6a169de725f | 135 | * @brief Get field y from vision_speed_estimate message |
shimniok | 0:a6a169de725f | 136 | * |
shimniok | 0:a6a169de725f | 137 | * @return Global Y speed |
shimniok | 0:a6a169de725f | 138 | */ |
shimniok | 0:a6a169de725f | 139 | static inline float mavlink_msg_vision_speed_estimate_get_y(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 140 | { |
shimniok | 0:a6a169de725f | 141 | generic_32bit r; |
shimniok | 0:a6a169de725f | 142 | r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float))[0]; |
shimniok | 0:a6a169de725f | 143 | r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float))[1]; |
shimniok | 0:a6a169de725f | 144 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float))[2]; |
shimniok | 0:a6a169de725f | 145 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float))[3]; |
shimniok | 0:a6a169de725f | 146 | return (float)r.f; |
shimniok | 0:a6a169de725f | 147 | } |
shimniok | 0:a6a169de725f | 148 | |
shimniok | 0:a6a169de725f | 149 | /** |
shimniok | 0:a6a169de725f | 150 | * @brief Get field z from vision_speed_estimate message |
shimniok | 0:a6a169de725f | 151 | * |
shimniok | 0:a6a169de725f | 152 | * @return Global Z speed |
shimniok | 0:a6a169de725f | 153 | */ |
shimniok | 0:a6a169de725f | 154 | static inline float mavlink_msg_vision_speed_estimate_get_z(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 155 | { |
shimniok | 0:a6a169de725f | 156 | generic_32bit r; |
shimniok | 0:a6a169de725f | 157 | r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0]; |
shimniok | 0:a6a169de725f | 158 | r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1]; |
shimniok | 0:a6a169de725f | 159 | r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[2]; |
shimniok | 0:a6a169de725f | 160 | r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[3]; |
shimniok | 0:a6a169de725f | 161 | return (float)r.f; |
shimniok | 0:a6a169de725f | 162 | } |
shimniok | 0:a6a169de725f | 163 | |
shimniok | 0:a6a169de725f | 164 | /** |
shimniok | 0:a6a169de725f | 165 | * @brief Decode a vision_speed_estimate message into a struct |
shimniok | 0:a6a169de725f | 166 | * |
shimniok | 0:a6a169de725f | 167 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 168 | * @param vision_speed_estimate C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 169 | */ |
shimniok | 0:a6a169de725f | 170 | static inline void mavlink_msg_vision_speed_estimate_decode(const mavlink_message_t* msg, mavlink_vision_speed_estimate_t* vision_speed_estimate) |
shimniok | 0:a6a169de725f | 171 | { |
shimniok | 0:a6a169de725f | 172 | vision_speed_estimate->usec = mavlink_msg_vision_speed_estimate_get_usec(msg); |
shimniok | 0:a6a169de725f | 173 | vision_speed_estimate->x = mavlink_msg_vision_speed_estimate_get_x(msg); |
shimniok | 0:a6a169de725f | 174 | vision_speed_estimate->y = mavlink_msg_vision_speed_estimate_get_y(msg); |
shimniok | 0:a6a169de725f | 175 | vision_speed_estimate->z = mavlink_msg_vision_speed_estimate_get_z(msg); |
shimniok | 0:a6a169de725f | 176 | } |