SRA Board Components
ESP-IDF component for SRA Board
|
Macros | |
#define | MIN_ACCE_ERROR 5 |
#define | MIN_GYRO_ERROR 5 |
#define | MAX_CALIBRATION_ATTEMPTS 20 |
#define | G_RAW_VALUE 16384 |
Functions | |
esp_err_t | i2c_master_init (void) |
Initialise the ESP32 I2C Driver in Master Mode. More... | |
esp_err_t | enable_mpu6050 (void) |
Initialise MPU-6050 (by sending the appropriate queued commands); Refer this for more information: https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf. More... | |
esp_err_t | mpu6050_read_acce (uint8_t *data_rd, size_t size) |
Get the accelerometer raw values (Ax, Ay, Az) into an 8-bit array Note that these raw values are actually 16-bit, split into MSB (Byte) and LSB (Byte), sent one after the other. More... | |
esp_err_t | mpu6050_read_gyro (uint8_t *data_rd, size_t size) |
Get the gyroscope raw values (Gx, Gy, Gz) into an 8-bit array Note that these raw values are actually 16-bit, split into MSB (Byte) and LSB (Byte), sent one after the other. More... | |
void | combine_msb_lsb_raw_data (uint8_t *buf_1, int16_t *buf_2) |
Combine two 8-bit values to a 16-bit one Note that EVEN indices in the input buffer represent the MSB (Byte) More... | |
void | compute_acce_angle (int16_t ax, int16_t ay, int16_t az, float *acce_angle) |
Compute the Euler angle (Pitch and Roll) from the accelerometer raw values Axes and Angles - X: Roll, Y: Pitch, Z: Yaw. More... | |
void | compute_gyro_angle (int16_t gx, int16_t gy, int16_t gz, float dt, float *gyro_angle) |
Compute the Euler angle (Pitch and Roll) from the gyroscope raw values Axes and Angles - X: Roll, Y: Pitch, Z: Yaw More on this here: https://philsal.co.uk/projects/imu-attitude-estimation. More... | |
esp_err_t | read_mpu6050_raw (int16_t *acce_raw_value, int16_t *gyro_raw_value) |
A wrapper for reading the 8-bit raw values from MPU and then combining them to their final form i.e. 16-bit. More... | |
void | complementary_filter (int16_t *acce_raw_value, int16_t *gyro_raw_value, float *complementary_angle, float *mpu_offset) |
Fuse the gyroscope and accelerometer angle in a complementary fashion More on this here: https://robotics.stackexchange.com/questions/10746/complimentary-filter-issues. More... | |
esp_err_t | avg_sensors (int16_t *acce_raw_value_avg, int16_t *gyro_raw_value_avg, const int16_t *acce_offs, const int16_t *gyro_offs) |
Helper function for the function calibrate_mpu6050() to calculate the average of the raw values. More... | |
esp_err_t | calibrate_mpu6050 () |
Function to calculate the MPU offset for raw values. More... | |
esp_err_t | read_mpu6050 (float *euler_angle, float *mpu_offset) |
The ultimate function (application ready); takes in the input raw values and initial conditions and gives out the complementary pitch and roll angles. More... | |
#define G_RAW_VALUE 16384 |
#define MAX_CALIBRATION_ATTEMPTS 20 |
#define MIN_ACCE_ERROR 5 |
#define MIN_GYRO_ERROR 5 |
esp_err_t avg_sensors | ( | int16_t * | acce_raw_value_avg, |
int16_t * | gyro_raw_value_avg, | ||
const int16_t * | acce_offs, | ||
const int16_t * | gyro_offs | ||
) |
Helper function for the function calibrate_mpu6050() to calculate the average of the raw values.
acce_raw_value_avg | Input array of accelerometer raw values (passed by reference) to be filled by the function. |
gyro_raw_value_avg | Input array of gyroscope raw values (passed by reference) to be filled by the function. |
acce_offs | Offset to be applied to the accelerometer raw values. |
gyro_offs | Offset to be applied to the gyroscope raw values. |
esp_err_t calibrate_mpu6050 | ( | ) |
Function to calculate the MPU offset for raw values.
void combine_msb_lsb_raw_data | ( | uint8_t * | buf_1, |
int16_t * | buf_2 | ||
) |
Combine two 8-bit values to a 16-bit one Note that EVEN indices in the input buffer represent the MSB (Byte)
buf_1 | 8-bit Input array of size 6 |
buf_2 | 16-bit Output array of size 3 |
void complementary_filter | ( | int16_t * | acce_raw_value, |
int16_t * | gyro_raw_value, | ||
float * | complementary_angle, | ||
float * | mpu_offset | ||
) |
Fuse the gyroscope and accelerometer angle in a complementary fashion More on this here: https://robotics.stackexchange.com/questions/10746/complimentary-filter-issues.
acce_raw_value | Raw values from the accelerometer |
gyro_raw_value | Raw values from the gyroscope |
complementary_angle | Resultant fused and filtered angle |
mpu_offset | Offset of the MPU (accelerometer) at rest position |
void compute_acce_angle | ( | int16_t | ax, |
int16_t | ay, | ||
int16_t | az, | ||
float * | acce_angle | ||
) |
Compute the Euler angle (Pitch and Roll) from the accelerometer raw values Axes and Angles - X: Roll, Y: Pitch, Z: Yaw.
ax | Raw accelerometer value (X-axis) |
ay | Raw accelerometer value (Y-axis) |
az | Raw accelerometer value (Z-axis) |
acce_angle | Resultant angle array |
void compute_gyro_angle | ( | int16_t | gx, |
int16_t | gy, | ||
int16_t | gz, | ||
float | dt, | ||
float * | gyro_angle | ||
) |
Compute the Euler angle (Pitch and Roll) from the gyroscope raw values Axes and Angles - X: Roll, Y: Pitch, Z: Yaw More on this here: https://philsal.co.uk/projects/imu-attitude-estimation.
gx | Raw gyroscope value (X-axis) |
gy | Raw gyroscope value (Y-axis) |
gz | Raw gyroscope value (Z-axis) |
dt | Sampling time for gyroscope readings (interval between 2 readings) |
gyro_angle | Resultant angle array |
esp_err_t enable_mpu6050 | ( | void | ) |
Initialise MPU-6050 (by sending the appropriate queued commands); Refer this for more information: https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf.
esp_err_t i2c_master_init | ( | ) |
Initialise the ESP32 I2C Driver in Master Mode.
esp_err_t mpu6050_read_acce | ( | uint8_t * | data_rd, |
size_t | size | ||
) |
Get the accelerometer raw values (Ax, Ay, Az) into an 8-bit array Note that these raw values are actually 16-bit, split into MSB (Byte) and LSB (Byte), sent one after the other.
data_rd | Buffer array for storing raw values |
size | Size of the buffer array (6 in our case) |
esp_err_t mpu6050_read_gyro | ( | uint8_t * | data_rd, |
size_t | size | ||
) |
Get the gyroscope raw values (Gx, Gy, Gz) into an 8-bit array Note that these raw values are actually 16-bit, split into MSB (Byte) and LSB (Byte), sent one after the other.
data_rd | Buffer array for storing raw values |
size | Size of the buffer array (6 in our case) |
esp_err_t read_mpu6050 | ( | float * | euler_angle, |
float * | mpu_offset | ||
) |
The ultimate function (application ready); takes in the input raw values and initial conditions and gives out the complementary pitch and roll angles.
euler_angle | Input array of angles to store the results in (passed by reference) |
mpu_offset | Initial conditions for the accelerometer and gyroscope (Angle at rest position) |
esp_err_t read_mpu6050_raw | ( | int16_t * | acce_raw_value, |
int16_t * | gyro_raw_value | ||
) |
A wrapper for reading the 8-bit raw values from MPU and then combining them to their final form i.e. 16-bit.
acce_raw_value | 16-bit array for storing the accelerometer raw values |
gyro_raw_value | 16-bit array for storing the gyroscope raw values |