|
| 1 | +/* |
| 2 | + * Copyright (C) 2015-2021 Swift Navigation Inc. |
| 3 | + * Contact: https://support.swiftnav.com |
| 4 | + * |
| 5 | + * This source is subject to the license found in the file 'LICENSE' which must |
| 6 | + * be distributed together with this source. All other rights reserved. |
| 7 | + * |
| 8 | + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, |
| 9 | + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| 10 | + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. |
| 11 | + */ |
| 12 | + |
| 13 | +/***************************************************************************** |
| 14 | + * Automatically generated from yaml/swiftnav/sbp/imu.yaml |
| 15 | + * with generate.py. Please do not hand edit! |
| 16 | + *****************************************************************************/ |
| 17 | + |
| 18 | +#ifndef LIBSBP_IMU_MSG_IMU_COMP_H |
| 19 | +#define LIBSBP_IMU_MSG_IMU_COMP_H |
| 20 | + |
| 21 | +#include <math.h> |
| 22 | +#include <stdarg.h> |
| 23 | +#include <stdbool.h> |
| 24 | +#include <stddef.h> |
| 25 | +#include <stdint.h> |
| 26 | +#include <string.h> |
| 27 | + |
| 28 | +#include <libsbp/common.h> |
| 29 | +#include <libsbp/imu_macros.h> |
| 30 | +#include <libsbp/string/sbp_string.h> |
| 31 | + |
| 32 | +#ifdef __cplusplus |
| 33 | +extern "C" { |
| 34 | +#endif |
| 35 | + |
| 36 | +/****************************************************************************** |
| 37 | + * |
| 38 | + * SBP_MSG_IMU_COMP |
| 39 | + * |
| 40 | + *****************************************************************************/ |
| 41 | +/** Compensated IMU data |
| 42 | + * |
| 43 | + * Data from the Inertial Measurement Unit, containing accelerometer and |
| 44 | + * gyroscope readings compensated for estimated errors and constant physical |
| 45 | + * effects. The output is valid for inertially referenced center of navigation |
| 46 | + * (IMU body frame) represented in vehicle body frame. |
| 47 | + */ |
| 48 | +typedef struct { |
| 49 | + /** |
| 50 | + * Microseconds since reference epoch [microseconds] |
| 51 | + */ |
| 52 | + u64 time; |
| 53 | + |
| 54 | + /** |
| 55 | + * Contains the applied compensation parameters and time synchronization mode |
| 56 | + */ |
| 57 | + u16 flags; |
| 58 | + |
| 59 | + /** |
| 60 | + * Compensated acceleration X axis [1e-6 m/s^2] |
| 61 | + */ |
| 62 | + s32 acc_comp_x; |
| 63 | + |
| 64 | + /** |
| 65 | + * Compensated acceleration Y axis [1e-6 m/s^2] |
| 66 | + */ |
| 67 | + s32 acc_comp_y; |
| 68 | + |
| 69 | + /** |
| 70 | + * Compensated acceleration Z axis [1e-6 m/s^2] |
| 71 | + */ |
| 72 | + s32 acc_comp_z; |
| 73 | + |
| 74 | + /** |
| 75 | + * Compensated angular rate X axis [1e-6 deg/s] |
| 76 | + */ |
| 77 | + s32 gyr_comp_x; |
| 78 | + |
| 79 | + /** |
| 80 | + * Compensated angular rate Y axis [1e-6 deg/s] |
| 81 | + */ |
| 82 | + s32 gyr_comp_y; |
| 83 | + |
| 84 | + /** |
| 85 | + * Compensated angular rate Z axis [1e-6 deg/s] |
| 86 | + */ |
| 87 | + s32 gyr_comp_z; |
| 88 | +} sbp_msg_imu_comp_t; |
| 89 | + |
| 90 | +/** |
| 91 | + * Get encoded size of an instance of sbp_msg_imu_comp_t |
| 92 | + * |
| 93 | + * @param msg sbp_msg_imu_comp_t instance |
| 94 | + * @return Length of on-wire representation |
| 95 | + */ |
| 96 | +static inline size_t sbp_msg_imu_comp_encoded_len( |
| 97 | + const sbp_msg_imu_comp_t *msg) { |
| 98 | + (void)msg; |
| 99 | + return SBP_MSG_IMU_COMP_ENCODED_LEN; |
| 100 | +} |
| 101 | + |
| 102 | +/** |
| 103 | + * Encode an instance of sbp_msg_imu_comp_t to wire representation |
| 104 | + * |
| 105 | + * This function encodes the given instance in to the user provided buffer. The |
| 106 | + * buffer provided to this function must be large enough to store the encoded |
| 107 | + * message otherwise it will return SBP_ENCODE_ERROR without writing anything to |
| 108 | + * the buffer. |
| 109 | + * |
| 110 | + * Specify the length of the destination buffer in the \p len parameter. If |
| 111 | + * non-null the number of bytes written to the buffer will be returned in \p |
| 112 | + * n_written. |
| 113 | + * |
| 114 | + * @param buf Destination buffer |
| 115 | + * @param len Length of \p buf |
| 116 | + * @param n_written If not null, on success will be set to the number of bytes |
| 117 | + * written to \p buf |
| 118 | + * @param msg Instance of sbp_msg_imu_comp_t to encode |
| 119 | + * @return SBP_OK on success, or other libsbp error code |
| 120 | + */ |
| 121 | +SBP_EXPORT s8 sbp_msg_imu_comp_encode(uint8_t *buf, uint8_t len, |
| 122 | + uint8_t *n_written, |
| 123 | + const sbp_msg_imu_comp_t *msg); |
| 124 | + |
| 125 | +/** |
| 126 | + * Decode an instance of sbp_msg_imu_comp_t from wire representation |
| 127 | + * |
| 128 | + * This function decodes the wire representation of a sbp_msg_imu_comp_t message |
| 129 | + * to the given instance. The caller must specify the length of the buffer in |
| 130 | + * the \p len parameter. If non-null the number of bytes read from the buffer |
| 131 | + * will be returned in \p n_read. |
| 132 | + * |
| 133 | + * @param buf Wire representation of the sbp_msg_imu_comp_t instance |
| 134 | + * @param len Length of \p buf |
| 135 | + * @param n_read If not null, on success will be set to the number of bytes read |
| 136 | + * from \p buf |
| 137 | + * @param msg Destination |
| 138 | + * @return SBP_OK on success, or other libsbp error code |
| 139 | + */ |
| 140 | +SBP_EXPORT s8 sbp_msg_imu_comp_decode(const uint8_t *buf, uint8_t len, |
| 141 | + uint8_t *n_read, sbp_msg_imu_comp_t *msg); |
| 142 | +/** |
| 143 | + * Send an instance of sbp_msg_imu_comp_t with the given write function |
| 144 | + * |
| 145 | + * An equivalent of #sbp_message_send which operates specifically on |
| 146 | + * sbp_msg_imu_comp_t |
| 147 | + * |
| 148 | + * The given message will be encoded to wire representation and passed in to the |
| 149 | + * given write function callback. The write callback will be called several |
| 150 | + * times for each invocation of this function. |
| 151 | + * |
| 152 | + * @param s SBP state |
| 153 | + * @param sender_id SBP sender id |
| 154 | + * @param msg Message to send |
| 155 | + * @param write Write function |
| 156 | + * @return SBP_OK on success, or other libsbp error code |
| 157 | + */ |
| 158 | +SBP_EXPORT s8 sbp_msg_imu_comp_send(sbp_state_t *s, u16 sender_id, |
| 159 | + const sbp_msg_imu_comp_t *msg, |
| 160 | + sbp_write_fn_t write); |
| 161 | + |
| 162 | +/** |
| 163 | + * Compare two instances of sbp_msg_imu_comp_t |
| 164 | + * |
| 165 | + * The two instances will be compared and a value returned consistent with the |
| 166 | + * return codes of comparison functions from the C standard library |
| 167 | + * |
| 168 | + * 0 will be returned if \p a and \p b are considered equal |
| 169 | + * A value less than 0 will be returned if \p a is considered to be less than \p |
| 170 | + * b A value greater than 0 will be returned if \p b is considered to be greater |
| 171 | + * than \p b |
| 172 | + * |
| 173 | + * @param a sbp_msg_imu_comp_t instance |
| 174 | + * @param b sbp_msg_imu_comp_t instance |
| 175 | + * @return 0, <0, >0 |
| 176 | + */ |
| 177 | +SBP_EXPORT int sbp_msg_imu_comp_cmp(const sbp_msg_imu_comp_t *a, |
| 178 | + const sbp_msg_imu_comp_t *b); |
| 179 | + |
| 180 | +#ifdef __cplusplus |
| 181 | +} |
| 182 | + |
| 183 | +static inline bool operator==(const sbp_msg_imu_comp_t &lhs, |
| 184 | + const sbp_msg_imu_comp_t &rhs) { |
| 185 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) == 0; |
| 186 | +} |
| 187 | + |
| 188 | +static inline bool operator!=(const sbp_msg_imu_comp_t &lhs, |
| 189 | + const sbp_msg_imu_comp_t &rhs) { |
| 190 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) != 0; |
| 191 | +} |
| 192 | + |
| 193 | +static inline bool operator<(const sbp_msg_imu_comp_t &lhs, |
| 194 | + const sbp_msg_imu_comp_t &rhs) { |
| 195 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) < 0; |
| 196 | +} |
| 197 | + |
| 198 | +static inline bool operator<=(const sbp_msg_imu_comp_t &lhs, |
| 199 | + const sbp_msg_imu_comp_t &rhs) { |
| 200 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) <= 0; |
| 201 | +} |
| 202 | + |
| 203 | +static inline bool operator>(const sbp_msg_imu_comp_t &lhs, |
| 204 | + const sbp_msg_imu_comp_t &rhs) { |
| 205 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) > 0; |
| 206 | +} |
| 207 | + |
| 208 | +static inline bool operator>=(const sbp_msg_imu_comp_t &lhs, |
| 209 | + const sbp_msg_imu_comp_t &rhs) { |
| 210 | + return sbp_msg_imu_comp_cmp(&lhs, &rhs) >= 0; |
| 211 | +} |
| 212 | + |
| 213 | +#endif // ifdef __cplusplus |
| 214 | + |
| 215 | +#endif /* LIBSBP_IMU_MSG_IMU_COMP_H */ |
0 commit comments