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/common/mavlink_msg_gps_status.h@25:bb5356402687, 2018-11-30 (annotated)
- Committer:
- shimniok
- Date:
- Fri Nov 30 16:11:53 2018 +0000
- Revision:
- 25:bb5356402687
- Parent:
- 0:a6a169de725f
Initial publish of revised version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE GPS_STATUS PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_GPS_STATUS 27 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_gps_status_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint8_t satellites_visible; ///< Number of satellites visible |
shimniok | 0:a6a169de725f | 8 | int8_t satellite_prn[20]; ///< Global satellite ID |
shimniok | 0:a6a169de725f | 9 | int8_t satellite_used[20]; ///< 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 10 | int8_t satellite_elevation[20]; ///< Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 11 | int8_t satellite_azimuth[20]; ///< Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 12 | int8_t satellite_snr[20]; ///< Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 13 | |
shimniok | 0:a6a169de725f | 14 | } mavlink_gps_status_t; |
shimniok | 0:a6a169de725f | 15 | |
shimniok | 0:a6a169de725f | 16 | #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_PRN_LEN 20 |
shimniok | 0:a6a169de725f | 17 | #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_USED_LEN 20 |
shimniok | 0:a6a169de725f | 18 | #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_ELEVATION_LEN 20 |
shimniok | 0:a6a169de725f | 19 | #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_AZIMUTH_LEN 20 |
shimniok | 0:a6a169de725f | 20 | #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_SNR_LEN 20 |
shimniok | 0:a6a169de725f | 21 | |
shimniok | 0:a6a169de725f | 22 | |
shimniok | 0:a6a169de725f | 23 | /** |
shimniok | 0:a6a169de725f | 24 | * @brief Pack a gps_status message |
shimniok | 0:a6a169de725f | 25 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 26 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 27 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 28 | * |
shimniok | 0:a6a169de725f | 29 | * @param satellites_visible Number of satellites visible |
shimniok | 0:a6a169de725f | 30 | * @param satellite_prn Global satellite ID |
shimniok | 0:a6a169de725f | 31 | * @param satellite_used 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 32 | * @param satellite_elevation Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 33 | * @param satellite_azimuth Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 34 | * @param satellite_snr Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 35 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 36 | */ |
shimniok | 0:a6a169de725f | 37 | static inline uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t satellites_visible, const int8_t* satellite_prn, const int8_t* satellite_used, const int8_t* satellite_elevation, const int8_t* satellite_azimuth, const int8_t* satellite_snr) |
shimniok | 0:a6a169de725f | 38 | { |
shimniok | 0:a6a169de725f | 39 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 40 | msg->msgid = MAVLINK_MSG_ID_GPS_STATUS; |
shimniok | 0:a6a169de725f | 41 | |
shimniok | 0:a6a169de725f | 42 | i += put_uint8_t_by_index(satellites_visible, i, msg->payload); // Number of satellites visible |
shimniok | 0:a6a169de725f | 43 | i += put_array_by_index(satellite_prn, 20, i, msg->payload); // Global satellite ID |
shimniok | 0:a6a169de725f | 44 | i += put_array_by_index(satellite_used, 20, i, msg->payload); // 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 45 | i += put_array_by_index(satellite_elevation, 20, i, msg->payload); // Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 46 | i += put_array_by_index(satellite_azimuth, 20, i, msg->payload); // Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 47 | i += put_array_by_index(satellite_snr, 20, i, msg->payload); // Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 48 | |
shimniok | 0:a6a169de725f | 49 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 50 | } |
shimniok | 0:a6a169de725f | 51 | |
shimniok | 0:a6a169de725f | 52 | /** |
shimniok | 0:a6a169de725f | 53 | * @brief Pack a gps_status message |
shimniok | 0:a6a169de725f | 54 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 55 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 56 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 57 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 58 | * @param satellites_visible Number of satellites visible |
shimniok | 0:a6a169de725f | 59 | * @param satellite_prn Global satellite ID |
shimniok | 0:a6a169de725f | 60 | * @param satellite_used 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 61 | * @param satellite_elevation Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 62 | * @param satellite_azimuth Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 63 | * @param satellite_snr Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 64 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 65 | */ |
shimniok | 0:a6a169de725f | 66 | static inline uint16_t mavlink_msg_gps_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t satellites_visible, const int8_t* satellite_prn, const int8_t* satellite_used, const int8_t* satellite_elevation, const int8_t* satellite_azimuth, const int8_t* satellite_snr) |
shimniok | 0:a6a169de725f | 67 | { |
shimniok | 0:a6a169de725f | 68 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 69 | msg->msgid = MAVLINK_MSG_ID_GPS_STATUS; |
shimniok | 0:a6a169de725f | 70 | |
shimniok | 0:a6a169de725f | 71 | i += put_uint8_t_by_index(satellites_visible, i, msg->payload); // Number of satellites visible |
shimniok | 0:a6a169de725f | 72 | i += put_array_by_index(satellite_prn, 20, i, msg->payload); // Global satellite ID |
shimniok | 0:a6a169de725f | 73 | i += put_array_by_index(satellite_used, 20, i, msg->payload); // 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 74 | i += put_array_by_index(satellite_elevation, 20, i, msg->payload); // Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 75 | i += put_array_by_index(satellite_azimuth, 20, i, msg->payload); // Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 76 | i += put_array_by_index(satellite_snr, 20, i, msg->payload); // Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 77 | |
shimniok | 0:a6a169de725f | 78 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 79 | } |
shimniok | 0:a6a169de725f | 80 | |
shimniok | 0:a6a169de725f | 81 | /** |
shimniok | 0:a6a169de725f | 82 | * @brief Encode a gps_status struct into a message |
shimniok | 0:a6a169de725f | 83 | * |
shimniok | 0:a6a169de725f | 84 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 85 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 86 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 87 | * @param gps_status C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 88 | */ |
shimniok | 0:a6a169de725f | 89 | static inline uint16_t mavlink_msg_gps_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status) |
shimniok | 0:a6a169de725f | 90 | { |
shimniok | 0:a6a169de725f | 91 | return mavlink_msg_gps_status_pack(system_id, component_id, msg, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr); |
shimniok | 0:a6a169de725f | 92 | } |
shimniok | 0:a6a169de725f | 93 | |
shimniok | 0:a6a169de725f | 94 | /** |
shimniok | 0:a6a169de725f | 95 | * @brief Send a gps_status message |
shimniok | 0:a6a169de725f | 96 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 97 | * |
shimniok | 0:a6a169de725f | 98 | * @param satellites_visible Number of satellites visible |
shimniok | 0:a6a169de725f | 99 | * @param satellite_prn Global satellite ID |
shimniok | 0:a6a169de725f | 100 | * @param satellite_used 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 101 | * @param satellite_elevation Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 102 | * @param satellite_azimuth Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 103 | * @param satellite_snr Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 104 | */ |
shimniok | 0:a6a169de725f | 105 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 106 | |
shimniok | 0:a6a169de725f | 107 | static inline void mavlink_msg_gps_status_send(mavlink_channel_t chan, uint8_t satellites_visible, const int8_t* satellite_prn, const int8_t* satellite_used, const int8_t* satellite_elevation, const int8_t* satellite_azimuth, const int8_t* satellite_snr) |
shimniok | 0:a6a169de725f | 108 | { |
shimniok | 0:a6a169de725f | 109 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 110 | mavlink_msg_gps_status_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, satellites_visible, satellite_prn, satellite_used, satellite_elevation, satellite_azimuth, satellite_snr); |
shimniok | 0:a6a169de725f | 111 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 112 | } |
shimniok | 0:a6a169de725f | 113 | |
shimniok | 0:a6a169de725f | 114 | #endif |
shimniok | 0:a6a169de725f | 115 | // MESSAGE GPS_STATUS UNPACKING |
shimniok | 0:a6a169de725f | 116 | |
shimniok | 0:a6a169de725f | 117 | /** |
shimniok | 0:a6a169de725f | 118 | * @brief Get field satellites_visible from gps_status message |
shimniok | 0:a6a169de725f | 119 | * |
shimniok | 0:a6a169de725f | 120 | * @return Number of satellites visible |
shimniok | 0:a6a169de725f | 121 | */ |
shimniok | 0:a6a169de725f | 122 | static inline uint8_t mavlink_msg_gps_status_get_satellites_visible(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 123 | { |
shimniok | 0:a6a169de725f | 124 | return (uint8_t)(msg->payload)[0]; |
shimniok | 0:a6a169de725f | 125 | } |
shimniok | 0:a6a169de725f | 126 | |
shimniok | 0:a6a169de725f | 127 | /** |
shimniok | 0:a6a169de725f | 128 | * @brief Get field satellite_prn from gps_status message |
shimniok | 0:a6a169de725f | 129 | * |
shimniok | 0:a6a169de725f | 130 | * @return Global satellite ID |
shimniok | 0:a6a169de725f | 131 | */ |
shimniok | 0:a6a169de725f | 132 | static inline uint16_t mavlink_msg_gps_status_get_satellite_prn(const mavlink_message_t* msg, int8_t* r_data) |
shimniok | 0:a6a169de725f | 133 | { |
shimniok | 0:a6a169de725f | 134 | |
shimniok | 0:a6a169de725f | 135 | memcpy(r_data, msg->payload+sizeof(uint8_t), 20); |
shimniok | 0:a6a169de725f | 136 | return 20; |
shimniok | 0:a6a169de725f | 137 | } |
shimniok | 0:a6a169de725f | 138 | |
shimniok | 0:a6a169de725f | 139 | /** |
shimniok | 0:a6a169de725f | 140 | * @brief Get field satellite_used from gps_status message |
shimniok | 0:a6a169de725f | 141 | * |
shimniok | 0:a6a169de725f | 142 | * @return 0: Satellite not used, 1: used for localization |
shimniok | 0:a6a169de725f | 143 | */ |
shimniok | 0:a6a169de725f | 144 | static inline uint16_t mavlink_msg_gps_status_get_satellite_used(const mavlink_message_t* msg, int8_t* r_data) |
shimniok | 0:a6a169de725f | 145 | { |
shimniok | 0:a6a169de725f | 146 | |
shimniok | 0:a6a169de725f | 147 | memcpy(r_data, msg->payload+sizeof(uint8_t)+20, 20); |
shimniok | 0:a6a169de725f | 148 | return 20; |
shimniok | 0:a6a169de725f | 149 | } |
shimniok | 0:a6a169de725f | 150 | |
shimniok | 0:a6a169de725f | 151 | /** |
shimniok | 0:a6a169de725f | 152 | * @brief Get field satellite_elevation from gps_status message |
shimniok | 0:a6a169de725f | 153 | * |
shimniok | 0:a6a169de725f | 154 | * @return Elevation (0: right on top of receiver, 90: on the horizon) of satellite |
shimniok | 0:a6a169de725f | 155 | */ |
shimniok | 0:a6a169de725f | 156 | static inline uint16_t mavlink_msg_gps_status_get_satellite_elevation(const mavlink_message_t* msg, int8_t* r_data) |
shimniok | 0:a6a169de725f | 157 | { |
shimniok | 0:a6a169de725f | 158 | |
shimniok | 0:a6a169de725f | 159 | memcpy(r_data, msg->payload+sizeof(uint8_t)+20+20, 20); |
shimniok | 0:a6a169de725f | 160 | return 20; |
shimniok | 0:a6a169de725f | 161 | } |
shimniok | 0:a6a169de725f | 162 | |
shimniok | 0:a6a169de725f | 163 | /** |
shimniok | 0:a6a169de725f | 164 | * @brief Get field satellite_azimuth from gps_status message |
shimniok | 0:a6a169de725f | 165 | * |
shimniok | 0:a6a169de725f | 166 | * @return Direction of satellite, 0: 0 deg, 255: 360 deg. |
shimniok | 0:a6a169de725f | 167 | */ |
shimniok | 0:a6a169de725f | 168 | static inline uint16_t mavlink_msg_gps_status_get_satellite_azimuth(const mavlink_message_t* msg, int8_t* r_data) |
shimniok | 0:a6a169de725f | 169 | { |
shimniok | 0:a6a169de725f | 170 | |
shimniok | 0:a6a169de725f | 171 | memcpy(r_data, msg->payload+sizeof(uint8_t)+20+20+20, 20); |
shimniok | 0:a6a169de725f | 172 | return 20; |
shimniok | 0:a6a169de725f | 173 | } |
shimniok | 0:a6a169de725f | 174 | |
shimniok | 0:a6a169de725f | 175 | /** |
shimniok | 0:a6a169de725f | 176 | * @brief Get field satellite_snr from gps_status message |
shimniok | 0:a6a169de725f | 177 | * |
shimniok | 0:a6a169de725f | 178 | * @return Signal to noise ratio of satellite |
shimniok | 0:a6a169de725f | 179 | */ |
shimniok | 0:a6a169de725f | 180 | static inline uint16_t mavlink_msg_gps_status_get_satellite_snr(const mavlink_message_t* msg, int8_t* r_data) |
shimniok | 0:a6a169de725f | 181 | { |
shimniok | 0:a6a169de725f | 182 | |
shimniok | 0:a6a169de725f | 183 | memcpy(r_data, msg->payload+sizeof(uint8_t)+20+20+20+20, 20); |
shimniok | 0:a6a169de725f | 184 | return 20; |
shimniok | 0:a6a169de725f | 185 | } |
shimniok | 0:a6a169de725f | 186 | |
shimniok | 0:a6a169de725f | 187 | /** |
shimniok | 0:a6a169de725f | 188 | * @brief Decode a gps_status message into a struct |
shimniok | 0:a6a169de725f | 189 | * |
shimniok | 0:a6a169de725f | 190 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 191 | * @param gps_status C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 192 | */ |
shimniok | 0:a6a169de725f | 193 | static inline void mavlink_msg_gps_status_decode(const mavlink_message_t* msg, mavlink_gps_status_t* gps_status) |
shimniok | 0:a6a169de725f | 194 | { |
shimniok | 0:a6a169de725f | 195 | gps_status->satellites_visible = mavlink_msg_gps_status_get_satellites_visible(msg); |
shimniok | 0:a6a169de725f | 196 | mavlink_msg_gps_status_get_satellite_prn(msg, gps_status->satellite_prn); |
shimniok | 0:a6a169de725f | 197 | mavlink_msg_gps_status_get_satellite_used(msg, gps_status->satellite_used); |
shimniok | 0:a6a169de725f | 198 | mavlink_msg_gps_status_get_satellite_elevation(msg, gps_status->satellite_elevation); |
shimniok | 0:a6a169de725f | 199 | mavlink_msg_gps_status_get_satellite_azimuth(msg, gps_status->satellite_azimuth); |
shimniok | 0:a6a169de725f | 200 | mavlink_msg_gps_status_get_satellite_snr(msg, gps_status->satellite_snr); |
shimniok | 0:a6a169de725f | 201 | } |